[hobbit] Windows memory trending
Henrik Stoerner
henrik at hswn.dk
Tue Jul 19 22:43:44 CEST 2005
On Tue, Jul 19, 2005 at 03:52:08PM -0400, Larry.Barber at usda.gov wrote:
> We're just running the NT client, I have enough trouble getting the NT
> admins to just install that, let alone anything else. It probably is the
> memory size that's causing problems. Here's a sample of the return from
> the cpu test:
Thanks, testing this clearly shows that it overflows the "unsigned long"
calculations being done by Hobbit. The attached patch should solve this,
hopefully also on those platforms that don't have a built-in strtoll()
routine.
This is for Hobbit 4.0.4 - the next version will have a (slightly
different) version of this included.
Regards,
Henrik
-------------- next part --------------
--- hobbit-4.0.4/hobbitd/larrd/do_la.c.orig 2005-05-08 21:36:09.000000000 +0200
+++ hobbit-4.0.4/hobbitd/larrd/do_la.c 2005-07-19 22:37:33.794305038 +0200
@@ -10,6 +10,26 @@
static char la_rcsid[] = "$Id: do_la.c,v 1.15 2005/05/08 19:35:29 henrik Exp $";
+static long long str2ll(char *s, char **errptr)
+{
+ long long result = 0;
+ int negative = 0;
+ char *inp;
+
+ inp = s + strspn(s, " \t");
+ if (*inp == '-') { negative = 1; inp++; }
+ while (isdigit((int)*inp)) {
+ result = 10*result + (*inp - '0');
+ inp++;
+ }
+
+ if (errptr && (*inp != '\0') && (!isspace((int)*inp))) *errptr = inp;
+
+ if (negative) result = -result;
+
+ return result;
+}
+
int do_la_larrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
static char *la_params[] = { "rrdcreate", rrdfn, "DS:la:GAUGE:600:0:U", rra1, rra2, rra3, rra4, NULL };
@@ -189,27 +209,27 @@
if (memhosts_init && (rbtFind(memhosts, hostname) == rbtEnd(memhosts))) {
/* Pick up memory statistics */
int found, realuse, swapuse;
- unsigned long phystotal, physavail, pagetotal, pageavail;
+ long long phystotal, physavail, pagetotal, pageavail;
found = realuse = swapuse = 0;
phystotal = physavail = pagetotal = pageavail = 0;
p = strstr(msg, "Total Physical memory:");
- if (p) { found++; phystotal = atol(strchr(p, ':') + 1); }
+ if (p) { found++; phystotal = str2ll(strchr(p, ':') + 1, NULL); }
if (found == 1) {
p = strstr(msg, "Available Physical memory:");
- if (p) { found++; physavail = atol(strchr(p, ':') + 1); }
+ if (p) { found++; physavail = str2ll(strchr(p, ':') + 1, NULL); }
}
if (found == 2) {
p = strstr(msg, "Total PageFile size:");
- if (p) { found++; pagetotal = atol(strchr(p, ':') + 1); }
+ if (p) { found++; pagetotal = str2ll(strchr(p, ':') + 1, NULL); }
}
if (found == 2) {
p = strstr(msg, "Available PageFile size:");
- if (p) { found++; pageavail = atol(strchr(p, ':') + 1); }
+ if (p) { found++; pageavail = str2ll(strchr(p, ':') + 1, NULL); }
}
if (found == 4) {
More information about the Xymon
mailing list