void handle_freebsd_client(char *hostname, char *clienttype, enum ostype_t os, void *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *meminfostr; char *swapinfostr; char *vmtotalstr; char *msgsstr; char *netstatstr; char *ifstatstr; char *portsstr; char *vmstatstr; char *p; char fromline[1024]; unsigned long memphystotal = 0, memphysfree = 0, memphysused = 0; unsigned long memswaptotal = 0, memswapfree = 0, memswapused = 0; int found = 0; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clockstr"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); meminfostr = getdata("meminfo"); swapinfostr = getdata("swapinfo"); msgsstr = getdata("msgs"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); portsstr = getdata("ports"); vmstatstr = getdata("vmstat"); vmtotalstr = getdata("vmtotal"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, 0, psstr, 0, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Avail", "Capacity", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "COMMAND", NULL, psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if (meminfostr) { p = strstr(meminfostr, "Total:"); if (p) { memphystotal = atol(p+6); found++; } } if (vmtotalstr) { p = strstr(vmtotalstr, "\nFree Memory Pages:"); if (p) { memphysfree = atol(p + 18); found++; } } if ((found == 1) && meminfostr) { p = strstr(meminfostr, "Free:"); if (p) { memphysfree = atol(p+5); found++; } memphysused = memphystotal - memphysfree; } if (swapinfostr) { found++; p = strchr(swapinfostr, '\n'); /* Skip the header line */ while (p) { long stot, sused, sfree; char *bol; bol = p+1; p = strchr(bol, '\n'); if (p) *p = '\0'; if (sscanf(bol, "%*s %ld %ld %ld", &stot, &sused, &sfree) == 3) { memswaptotal += stot; memswapused += sused; memswapfree += sfree; } if (p) *p = '\n'; } memswaptotal /= 1024; memswapused /= 1024; memswapfree /= 1024; } if (found >= 2) { unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, memphystotal, memphysused, -1, memswaptotal, memswapused); } }
void handle_netbsd_client(char *hostname, char *clienttype, enum ostype_t os, void *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *meminfostr; char *msgsstr; char *netstatstr; char *ifstatstr; char *portsstr; char *vmstatstr; char *p; char fromline[1024]; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clock"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); meminfostr = getdata("meminfo"); msgsstr = getdata("msgsstr"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); portsstr = getdata("ports"); vmstatstr = getdata("vmstat"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, 0, psstr, 0, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Avail", "Capacity", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "COMMAND", NULL, psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); deltacount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if (meminfostr) { unsigned long memphystotal, memphysfree, memphysused; unsigned long memswaptotal, memswapfree, memswapused; int found = 0; memphystotal = memphysfree = memphysused = 0; memswaptotal = memswapfree = memswapused = 0; p = strstr(meminfostr, "Total:"); if (p) { memphystotal = atol(p+6); found++; } p = strstr(meminfostr, "Free:"); if (p) { memphysfree = atol(p+5); found++; } memphysused = memphystotal - memphysfree; p = strstr(meminfostr, "Swaptotal:"); if (p) { memswaptotal = atol(p+10); found++; } p = strstr(meminfostr, "Swapused:"); if (p) { memswapused = atol(p+9); found++; } memswapfree = memswaptotal - memswapused; if (found == 4) { unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, memphystotal, memphysused, -1, -1, memswaptotal, memswapused); } } splitmsg_done(); }
void handle_linux_client(char *hostname, char *clienttype, enum ostype_t os, void *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *freestr; char *msgsstr; char *netstatstr; char *vmstatstr; char *ifstatstr; char *portsstr; char fromline[1024]; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clock"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); freestr = getdata("free"); msgsstr = getdata("msgs"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); vmstatstr = getdata("vmstat"); portsstr = getdata("ports"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, 0, psstr, 0, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Available", "Capacity", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "CMD", NULL, psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if (freestr) { char *p; long memphystotal, memphysused, memphysfree, memactused, memactfree, memswaptotal, memswapused, memswapfree; memphystotal = memswaptotal = memphysused = memswapused = memactused = memactfree = -1; p = strstr(freestr, "\nMem:"); if (p && (sscanf(p, "\nMem: %ld %ld %ld", &memphystotal, &memphysused, &memphysfree) == 3)) { memphystotal /= 1024; memphysused /= 1024; memphysfree /= 1024; } p = strstr(freestr, "\nSwap:"); if (p && (sscanf(p, "\nSwap: %ld %ld %ld", &memswaptotal, &memswapused, &memswapfree) == 3)) { memswaptotal /= 1024; memswapused /= 1024; memswapfree /= 1024; } p = strstr(freestr, "\n-/+ buffers/cache:"); if (p && (sscanf(p, "\n-/+ buffers/cache: %ld %ld", &memactused, &memactfree) == 2)) { memactused /= 1024; memactfree /= 1024; } unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, memphystotal, memphysused, memactused, memswaptotal, memswapused); } splitmsg_done(); }
void handle_aix_client(char *hostname, char *clienttype, enum ostype_t os, namelist_t *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *msgsstr; char *netstatstr; char *ifstatstr; char *portsstr; char *vmstatstr; char *realmemstr; char *freememstr; char *swapmemstr; char fromline[1024]; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clock"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); msgsstr = getdata("msgs"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); portsstr = getdata("ports"); vmstatstr = getdata("vmstat"); realmemstr = getdata("realmem"); freememstr = getdata("freemem"); swapmemstr = getdata("swap"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, psstr, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Free", "%Used", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "COMMAND", "CMD", psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if (realmemstr && freememstr && swapmemstr) { long memphystotal, memphysused, memphysfree, memswaptotal, memswappct; char *p; memphystotal = memphysused = memswaptotal = memswappct = 0; if (strncmp(realmemstr, "realmem ", 8) == 0) memphystotal = atoi(realmemstr+8) / 1024; if (sscanf(freememstr, "%*d %*d %*d %ld", &memphysfree) == 1) memphysfree /= 256; p = strchr(swapmemstr, '\n'); if (p) p++; if (p && (sscanf(p, " %ldMB %ld%%", &memswaptotal, &memswappct) != 2)) { memswaptotal = memswappct = -1; } unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, memphystotal, (memphystotal - memphysfree), -1, memswaptotal, ((memswaptotal * memswappct) / 100)); } }
void handle_sco_sv_client(char *hostname, char *clienttype, enum ostype_t os, void *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *freememstr; char *memsizestr; char *swapstr; char *msgsstr; char *netstatstr; char *vmstatstr; char *ifstatstr; char *portsstr; char fromline[1024]; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clock"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); memsizestr = getdata("memsize"); freememstr = getdata("freemem"); swapstr = getdata("swap"); msgsstr = getdata("msgs"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); vmstatstr = getdata("vmstat"); portsstr = getdata("ports"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, 0, psstr, 0, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Available", "Capacity", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "COMMAND", NULL, psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if(freememstr && memsizestr && swapstr) { long memphystotal, memphysfree, memswaptotal, memswapfree; char *p; memphystotal = memphysfree = 0; memphystotal = (atoi(memsizestr) / 1048576); if(sscanf(freememstr, "%*s %ld %ld %*d %*d", &memphysfree, &memswapfree) == 2) memphysfree /= 256; /* comes in 4kb pages */ else memphysfree = -1; memswaptotal = memswapfree = 0; if (swapstr) { p = strchr(swapstr, '\n'); /* Skip the header line */ while (p) { long stot, sfree; char *bol; bol = p+1; p = strchr(bol, '\n'); if (p) *p = '\0'; if (sscanf(bol, "%*s %*s %*d %ld %ld", &stot, &sfree) == 2) { memswaptotal += stot; memswapfree += sfree; } if (p) *p = '\n'; } memswaptotal /= 2048 ; memswapfree /= 2048; } unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, memphystotal, (memphystotal - memphysfree), -1, memswaptotal, (memswaptotal - memswapfree)); } splitmsg_done(); }
void handle_osf_client(char *hostname, char *clienttype, enum ostype_t os, void *hinfo, char *sender, time_t timestamp, char *clientdata) { char *timestr; char *uptimestr; char *clockstr; char *msgcachestr; char *whostr; char *psstr; char *topstr; char *dfstr; char *msgsstr; char *netstatstr; char *ifstatstr; char *portsstr; char *vmstatstr; char *memorystr; char *swapstr; char fromline[1024]; sprintf(fromline, "\nStatus message received from %s\n", sender); splitmsg(clientdata); timestr = getdata("date"); uptimestr = getdata("uptime"); clockstr = getdata("clock"); msgcachestr = getdata("msgcache"); whostr = getdata("who"); psstr = getdata("ps"); topstr = getdata("top"); dfstr = getdata("df"); msgsstr = getdata("msgs"); netstatstr = getdata("netstat"); ifstatstr = getdata("ifstat"); portsstr = getdata("ports"); vmstatstr = getdata("vmstat"); memorystr = getdata("memory"); swapstr = getdata("swap"); unix_cpu_report(hostname, clienttype, os, hinfo, fromline, timestr, uptimestr, clockstr, msgcachestr, whostr, 0, psstr, 0, topstr); unix_disk_report(hostname, clienttype, os, hinfo, fromline, timestr, "Available", "Capacity", "Mounted", dfstr); unix_procs_report(hostname, clienttype, os, hinfo, fromline, timestr, "CMD", "COMMAND", psstr); unix_ports_report(hostname, clienttype, os, hinfo, fromline, timestr, 3, 4, 5, portsstr); msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr); file_report(hostname, clienttype, os, hinfo, fromline, timestr); linecount_report(hostname, clienttype, os, hinfo, fromline, timestr); deltacount_report(hostname, clienttype, os, hinfo, fromline, timestr); unix_netstat_report(hostname, clienttype, os, hinfo, fromline, timestr, netstatstr); unix_ifstat_report(hostname, clienttype, os, hinfo, fromline, timestr, ifstatstr); unix_vmstat_report(hostname, clienttype, os, hinfo, fromline, timestr, vmstatstr); if (memorystr && swapstr) { char *p, *bol; long phystotal, physfree, swaptotal, swapfree, pagecnt, pagesize; /* * Total Physical Memory = 5120.00 M * = 655360 pages * * ... * * Managed Pages Break Down: * * free pages = 499488 * */ phystotal = physfree = swaptotal = swapfree = -1; pagesize = 8; /* Default - appears to be the OSF/1 standard */ bol = strstr(memorystr, "\nTotal Physical Memory ="); if (bol) { p = strchr(bol, '='); phystotal = atol(p+1); bol = strchr(p, '\n'); if (bol) { bol++; bol += strspn(bol, " \t"); if (*bol == '=') { pagecnt = atol(bol+1); pagesize = (phystotal * 1024) / pagecnt; } } } bol = strstr(memorystr, "\nManaged Pages Break Down:"); if (bol) { bol = strstr(bol, "free pages ="); if (bol) { p = strchr(bol, '='); physfree = atol(p+1) * pagesize / 1024; } } bol = strstr(swapstr, "\nTotal swap allocation:"); if (bol) { unsigned long swappages, freepages; int n1, n2; n1 = n2 = 0; p = strstr(bol, "Allocated space:"); if (p) n1 = sscanf(p, "Allocated space: %lu pages", &swappages); p = strstr(bol, "Available space:"); if (p) n2 = sscanf(p, "Available space: %lu pages", &freepages); if ((n1 == 1) && (n2 == 1)) { swaptotal = swappages * pagesize / 1024; swapfree = freepages * pagesize / 1024; } } unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr, phystotal, (phystotal - physfree), -1, -1, swaptotal, (swaptotal - swapfree)); } splitmsg_done(); }