mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-09 00:32:05 -04:00
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
This commit is contained in:
parent
1945dffb8d
commit
5d7f904c20
1 changed files with 18 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue