/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netdir.h>
#include <rpc/pmap_clnt.h>
int machinecmp();
int loadcmp();
int uptimecmp();
static int collectnames();
int singlehost(); /* returns 1 if rup of given host fails */
void printsinglehosts();
void printnames();
static void putline();
void usage(void);
struct entry {
char *machine;
};
int total_entries;
int curentry;
int debug;
int
{
/*
* set number of slots to be 256 to begin with,
* this is large enough for most subnets but not all
*/
curentry = 0;
while (argc > 1) {
single++;
} else {
case 'l':
lflag++;
break;
case 't':
tflag++;
break;
case 'h':
hflag++;
break;
case 'd':
dflag++;
if (argc < 3)
usage();
argc--;
argv++;
break;
default:
usage();
}
}
argv++;
argc--;
}
if (single > 0) {
} else {
exit(0);
}
}
printf("collecting responses... ");
}
/*
* Null out pointers in the statsvar struct
* so that we don't follow a random pointer
* somewhere when we get our results back.
* Set lengths to zero so we don't allocate
* some random amount of space we don't need
* (in the case where the reply was program
* not registered).
*/
(resultproc_t)collectnames, (char *)0);
#ifdef TESTING
if (bstat != RPC_SUCCESS)
printf("rpc_broadcast for rstat version %d returned %s\n",
#endif
(resultproc_t)collectnames, (char *)0);
#ifdef TESTING
if (bstat != RPC_SUCCESS)
printf("rpc_broadcast for rstat version %d returned %s\n",
#endif
printnames();
return (0);
}
int
char *host;
{
static int debugcnt;
if (curentry >= total_entries) {
total_entries += SLOTS;
* total_entries);
return (1);
}
}
if (err == RPC_SUCCESS) {
is_var_vers = TRUE;
} else if (err == RPC_PROGVERSMISMATCH) {
if (err != RPC_SUCCESS)
goto error;
} else
goto error;
debugcnt++;
if (is_var_vers == TRUE)
else
return (0); /* success */
} else {
} else { /* RSTATVERS_VAR */
AVENSIZE);
}
}
curentry++;
return (1);
return (0);
/*
* clnt_perrno now prints a newline
*/
/* fprintf(stderr, "\n"); */
return (1); /* a failure */
}
static void
long avenrun[];
{
uptime += 30;
if (uptime < 0) /* unsynchronized clocks */
uptime = 0;
printf(" up");
if (days > 0)
else
printf(" ");
if (hrs > 0)
else
/*
* Print 1, 5, and 15 minute load averages.
* (Found by looking in kernel for avenrun).
*/
printf(" load average:");
if (i > 0)
printf(",");
}
printf("\n");
}
static int
char *resultsp;
{
static int debugcnt;
extern struct netconfig *netconfigdup();
extern int netbufeq();
/*
* need to realloc more space if we have more than 256 machines
* that responded to the broadcast
*/
if (curentry >= total_entries) {
total_entries += SLOTS;
* total_entries);
return (1);
}
}
/*
* weed out duplicates
*/
return (0);
if (vers == RSTATVERS_TIME) {
} else if (vers == RSTATVERS_VAR) {
} else {
return (0); /* we don't handle this version */
}
debugcnt++;
/*
* if raw, print this entry out immediately
* otherwise store for later sorting
*/
else {
if (uaddr) {
uaddr);
} else
"unknown");
}
if (vers == RSTATVERS_TIME) {
} else if (vers == RSTATVERS_VAR) {
}
} else {
if (vers == RSTATVERS_TIME) {
} else if (vers == RSTATVERS_VAR) {
}
}
curentry++;
return (1);
return (0);
}
void
{
register int i;
if (hflag)
else if (lflag)
else
for (i = 0; i < curentry; i++) {
}
}
void
{
register int i;
for (i = 0; i < curentry; i++) {
else {
if (uaddr) {
} else
}
}
printf("\n");
}
int
{
}
int
{
else
}
int
{
register int i;
return (0);
}
struct netbuf *
{
if (np) {
}
return (np);
}
struct netconfig *
{
register int nlookupdirs;
extern char *strdup();
if (nnp) {
if (onp->nc_nlookups == 0)
nnp->nc_lookups = (char **)0;
else {
register int i;
sizeof (char *));
if (nnp->nc_lookups)
for (i = 0; i < onp->nc_nlookups; i++)
nnp->nc_lookups[i] =
}
}
return (nnp);
}
int
{
}
void
usage(void)
{
exit(1);
}