aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-04-05 21:26:56 +0000
committerGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-04-05 21:26:56 +0000
commit5d7f904c200d74365b36ef5f75817204cc7899a8 (patch)
tree12b918f782dafd85af2d679dbdfd19cefd34baed
parent1945dffb8d95a7ba5429c2a46cbccac9383651a4 (diff)
downloadmonitoring-plugins-5d7f904c200d74365b36ef5f75817204cc7899a8.tar.gz
This is a first cut at adding performance data to check_snmp. I wasn't sure
how to handle UOM so only values that return SNMP type Counter32: are labled with "c". All other values have a blank UOM. I also left off warn, crit, max and min values in the performance data until we come up with a way to handle them. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1157 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_snmp.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 0ef0c653..d66d834e 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -82,6 +82,7 @@ regex_t preg;
regmatch_t pmatch[10];
char timestamp[10] = "";
char errbuf[MAX_INPUT_BUFFER];
+char perfstr[MAX_INPUT_BUFFER];
int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
int eflags = 0;
int errcode, excode;
@@ -136,6 +137,7 @@ main (int argc, char **argv)
char *ptr = NULL;
char *p2 = NULL;
char *show = NULL;
+ char type[8];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -153,7 +155,7 @@ main (int argc, char **argv)
port = strdup (DEFAULT_PORT);
outbuff = strdup ("");
output = strdup ("");
- delimiter = strdup (DEFAULT_DELIMITER);
+ delimiter = strdup (" = ");
output_delim = strdup (DEFAULT_OUTPUT_DELIMITER);
miblist = strdup (DEFAULT_MIBLIST);
timeout_interval = DEFAULT_TIMEOUT;
@@ -189,9 +191,14 @@ main (int argc, char **argv)
ptr = output;
+ strcat(perfstr, "| ");
while (ptr) {
+ char *foo;
+
+ foo = strstr (ptr, delimiter);
+ strncat(perfstr, ptr, foo-ptr);
+ ptr = foo;
- ptr = strstr (ptr, delimiter);
if (ptr == NULL)
break;
@@ -227,8 +234,10 @@ main (int argc, char **argv)
show = strstr (response, "Gauge: ") + 7;
else if (strstr (response, "Gauge32: "))
show = strstr (response, "Gauge32: ") + 9;
- else if (strstr (response, "Counter32: "))
+ else if (strstr (response, "Counter32: ")) {
show = strstr (response, "Counter32: ") + 11;
+ strcpy(type, "c");
+ }
else if (strstr (response, "INTEGER: "))
show = strstr (response, "INTEGER: ") + 9;
else if (strstr (response, "STRING: "))
@@ -317,7 +326,11 @@ main (int argc, char **argv)
i++;
- } /* end while (ptr) */
+ char *str[MAX_INPUT_BUFFER];
+ asprintf(str, "=%s%s;;;; ", show, type ? type : "");
+ strcat(perfstr, *str);
+
+ } /* end while (ptr) */
if (found == 0)
die (STATE_UNKNOWN,
@@ -339,7 +352,7 @@ main (int argc, char **argv)
/* if (nunits == 1 || i == 1) */
/* printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units); */
/* else */
- printf ("%s %s -%s\n", label, state_text (result), outbuff);
+ printf ("%s %s -%s %s \n", label, state_text (result), outbuff, perfstr);
return result;
}