/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* ss - list local network system status
*/
static const char usage[] =
"[-?\n@(#)$Id: ss (AT&T Research) 1995-05-09 $\n]"
"[+NAME?ss - list local network system status]"
"[+DESCRIPTION?\bss\b writes the system status of hosts on the local network"
" to the standard output. The option order determines the listing sort"
" keys, from left to right, hightest to lowest precedence. If one or"
" more \ahost\a operands are given then only the status to those hosts"
" is listed, otherwise the status for all hosts on the local network is"
" listed.]"
"[+?Static information for hosts in the local network is in the file"
" Dynamic status for each active host is maintained in the file"
" each host. This information is updated once a minute, plus or minus"
" a random part of a minute. \bss\b starts an \bssd\bs as necessary. An"
" \bssd\b may be killed by removing the corresponding host status file.]"
"[c:cpu?Sort by cpu utilization.]"
"[i:idle?Sort by user idle time.]"
"[l:load?Sort by load average.]"
"[r:reverse?Reverse the sort order.]"
"[t:time?Sort by system up time.]"
"[u:users?Sort by number of active users.]"
"\n"
"\n[ host ... ]\n"
"\n"
"[+FILES]{"
"}"
"[+SEE ALSO?\bcs\b(1)]"
;
#include <ast.h>
#include <cs.h>
#include <dirent.h>
#include <error.h>
typedef struct
{
char* name;
char* fail;
} Sys_t;
static struct
{
int keys;
int rev;
} state;
/*
* enter system name into the system vector
* alloc!=0 allocate space for name
*/
static void
{
register int n;
{
}
}
/*
* sys sort
*/
static int
{
register int k;
register long n;
switch (k & SORT)
{
case CPU:
break;
case IDLE:
break;
case LOAD:
break;
case TIME:
break;
case USERS:
break;
}
}
int
{
int n;
{
switch (n)
{
case 'c':
n = CPU;
break;
case 'i':
n = IDLE;
break;
case 'l':
n = LOAD;
break;
case 'r':
continue;
case 't':
n = TIME;
break;
case 'u':
n = USERS;
break;
case '?':
continue;
case ':':
continue;
}
}
if (error_info.errors)
while (*argv)
else
{
}
{
else
sfprintf(sfstdout, "%-12s%4s%7s,%3d user%s idle%7s, load%3d.%02d, %%usr%3d, %%sys%3d\n", sp->name, sp->stat.up < 0 ? "down" : "up", fmtelapsed(sp->stat.up < 0 ? -sp->stat.up : sp->stat.up, 1), sp->stat.users, sp->stat.users == 1 ? ", " : "s,", sp->stat.idle > sp->stat.up ? "%" : fmtelapsed(sp->stat.idle, 1), sp->stat.load / 100, sp->stat.load % 100, sp->stat.pctusr, sp->stat.pctsys);
}
return error_info.errors != 0;
}