#include <errno.h>
#include <sys/sysctl.h>
#include <sys/types.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
int port=TOPD_SERVER_DEFAULT_PORT;
int i;
- MassiveUnit *mu;
- TCMsg *pmsg = (TCMsg*)malloc( TCMSGHDRSZ );
+ TCMsg *pmsg;
TC_Connection cs;
- pmsg->type = TOPGETTYPE;
- pmsg->len = TCMSGHDRSZ;
+ opentlog( TL_OPEN_STDERR, TL_INFO, NULL);
while( (ch=getopt(argc, argv, "Dh:p:"))!=-1) {
switch(ch) {
opentlog( TL_OPEN_STDERR, (debug) ? TL_DEBUG : TL_INFO, NULL);
TC_fillConnection(&cs, host, port);
- cs.buf = (char*)pmsg;
- cs.len = pmsg->len;
- if ( TC_Talk(&cs) == CS_OK ) {
- pmsg = (TCMsg*) cs.buf;
+
+ pmsg = (TCMsg*)tmalloc( TCMSGHDRSZ );
+ pmsg->type = TOPGETTYPE;
+ pmsg->len = TCMSGHDRSZ;
+ cs.buf = pmsg;
+
+ if ( TC_Talk(&cs, 0) == CS_OK ) {
+ MassiveUnit *mu;
+
+ pmsg = cs.buf;
mu = (MassiveUnit*)pmsg->data;
- printf("\tIP\tLoad\tFree\tTotal\tData\n");
+ tlog(TL_DEBUG,"Got packet len:%db type:%08x n:%d", pmsg->len, pmsg->type, mu->number);
+
+ printf("\tIP\tLoad\tFree\tTotal\tDate\n");
for(i=0; i<mu->number; i++)
printf("%s\t%.2f\t%.1fM\t%.1fM\t%s",
inet_ntoa(mu->units[i].ip),
mu->units[i].top.load,
((float) mu->units[i].top.freemem)/( 1024*1024.0 ),
- ((float) mu->units[i].top.usermem)/( 1024*1024.0 ),
+ ((float) mu->units[i].top.physmem)/( 1024*1024.0 ),
ctime( &(mu->units[i].stamp) )
);
}