summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ef88c82)
raw | patch | inline | side by side (parent: ef88c82)
author | octo <octo> | |
Sat, 28 Jan 2006 08:11:39 +0000 (08:11 +0000) | ||
committer | octo <octo> | |
Sat, 28 Jan 2006 08:11:39 +0000 (08:11 +0000) |
src/df.c | patch | blob | history | |
src/ping.c | patch | blob | history |
diff --git a/src/df.c b/src/df.c
index eda9f959e5f26982a8b41e4199eee8f5da029442..69dc2994121ed2500b91a260f8e3f4c2e58455df 100644 (file)
--- a/src/df.c
+++ b/src/df.c
static char *filename_template = "df-%s.rrd";
-/* 104857600 == 100 MB */
static char *ds_def[] =
{
"DS:used:GAUGE:25:0:U",
diff --git a/src/ping.c b/src/ping.c
index 661aa65f07fd39d20104c9d1bc00e6697b12b2cc..f80cab517182437ec2291885dc4c7d14458f25f1 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
#define MAX_PINGHOSTS 32
-static char *hosts[MAX_PINGHOSTS];
-static int hosts_flags[MAX_PINGHOSTS];
-static int hosts_disable[MAX_PINGHOSTS];
-static int hosts_backoff[MAX_PINGHOSTS];
-static int num_pinghosts;
+typedef struct
+{
+ char *name;
+ int flags;
+ int disable; /* How long (how many iterations) this host is still disabled */
+ int backoff; /* How long the host will be disabled, if it failes again */
+} pinghost_t;
+
+static pinghost_t hosts[MAX_PINGHOSTS];
+static int num_pinghosts;
static char *file_template = "ping-%s.rrd";
for (i = 0; i < MAX_PINGHOSTS; i++)
{
- hosts_flags[i] = 0;
- hosts_disable[i] = 0;
- hosts_backoff[i] = 1;
+ hosts[i].flags = 0;
+ hosts[i].disable = 0;
+ hosts[i].backoff = 1;
}
return;
{
return (1);
}
- else if ((hosts[num_pinghosts] = strdup (value)) == NULL)
+ else if ((hosts[num_pinghosts].name = strdup (value)) == NULL)
{
return (2);
}
else
{
- hosts_flags[num_pinghosts] = 0;
num_pinghosts++;
return (0);
}
{
char buf[BUFSIZE];
- if (snprintf (buf, BUFSIZE, "%u:%u", (unsigned int) curtime, ping_time) >= BUFSIZE)
+ if (snprintf (buf, BUFSIZE, "%u:%i", (unsigned int) curtime, ping_time) >= BUFSIZE)
return;
plugin_submit (MODULE_NAME, host, buf);
for (i = 0; i < num_pinghosts; i++)
{
- if (hosts_disable[i] > 0)
+ if (hosts[i].disable > 0)
{
- hosts_disable[i]--;
+ hosts[i].disable--;
continue;
}
- ping = tpinghost (hosts[i]);
+ ping = tpinghost (hosts[i].name);
switch (ping)
{
case 0:
- if (!(hosts_flags[i] & 0x01))
- syslog (LOG_WARNING, "ping %s: Connection timed out.", hosts[i]);
- hosts_flags[i] |= 0x01;
+ if (!(hosts[i].flags & 0x01))
+ syslog (LOG_WARNING, "ping %s: Connection timed out.", hosts[i].name);
+ hosts[i].flags |= 0x01;
break;
case -1:
- if (!(hosts_flags[i] & 0x02))
- syslog (LOG_WARNING, "ping %s: Host or service is not reachable.", hosts[i]);
- hosts_flags[i] |= 0x02;
+ if (!(hosts[i].flags & 0x02))
+ syslog (LOG_WARNING, "ping %s: Host or service is not reachable.", hosts[i].name);
+ hosts[i].flags |= 0x02;
break;
case -2:
syslog (LOG_ERR, "ping %s: Socket error. Ping will be disabled for %i iteration(s).",
- hosts[i], hosts_backoff[i]);
- hosts_disable[i] = hosts_backoff[i];
- if (hosts_backoff[i] < 8192) /* 22 3/4 hours */
- hosts_backoff[i] *= 2;
- hosts_flags[i] |= 0x10;
+ hosts[i].name, hosts[i].backoff);
+ hosts[i].disable = hosts[i].backoff;
+ if (hosts[i].backoff < 8192) /* 22 3/4 hours */
+ hosts[i].backoff *= 2;
+ hosts[i].flags |= 0x10;
break;
case -3:
- if (!(hosts_flags[i] & 0x04))
- syslog (LOG_WARNING, "ping %s: Connection refused.", hosts[i]);
- hosts_flags[i] |= 0x04;
+ if (!(hosts[i].flags & 0x04))
+ syslog (LOG_WARNING, "ping %s: Connection refused.", hosts[i].name);
+ hosts[i].flags |= 0x04;
break;
default:
- if (hosts_flags[i] != 0x00)
- syslog (LOG_NOTICE, "ping %s: Back to normal: %ims.", hosts[i], ping);
- hosts_flags[i] = 0x00;
- hosts_backoff[i] = 1;
- ping_submit (ping, hosts[i]);
+ if (hosts[i].flags != 0x00)
+ syslog (LOG_NOTICE, "ping %s: Back to normal: %ims.", hosts[i].name, ping);
+ hosts[i].flags = 0x00;
+ hosts[i].backoff = 1;
+ ping_submit (ping, hosts[i].name);
} /* switch (ping) */
} /* for (i = 0; i < num_pinghosts; i++) */
}