#include #include #include "rstat.h" /* Generated by rpcgen */ /* CpSc 824 Desc: sample program that shows an rpc call to the rstat rpc on another host. Usage: callrstat hostname Notes: the rstat rpc returns substantial information on current status of a host (see rstat.h). In this example the 3 load average values are displayed and can be compared against what is returned by "rup hostname" -- a standard unix utility that does the same thing. The rpcgen interface file (.x) for rstat may be found in /usr/inlude/rpcsvc/rstat.x. This was used in this case to produce the xdr routines and the .h file. */ main (argc,argv) int argc; char *argv[]; { enum clnt_stat status; statsvar *rstatvals; if (argc != 2 ) { printf("Usage: countmain node\n"); exit(1); } /* Allocate space to receive results */ rstatvals = (statsvar *) malloc(sizeof(struct statsvar)); memset((char *) rstatvals, 0, sizeof(struct statsvar)); /* Invoke rstat on designated node */ printf("Getting ready to call rstat\n"); if ((status=rpc_call(argv[1], RSTATPROG, RSTATVERS_VAR, RSTATPROC_STATS, (xdrproc_t) xdr_void, NULL, (xdrproc_t) xdr_statsvar, (caddr_t) rstatvals, "netpath")) != RPC_SUCCESS) { clnt_perrno(status); exit(1); } printf("Back from rstat call\n"); /* Load average is returned in integer units */ printf("Load on %s: %f %f %f\n", argv[1], rstatvals->avenrun[0]/256.0, rstatvals->avenrun[1]/256.0, rstatvals->avenrun[2]/256.0); printf("Done\n");fflush(stdout); exit(0); }