[nagiosplug] check_snmp -l label is now used for performance ...
"Ton Voon" <[email protected]>
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: ton/state Commit: 4a0b843173640562bed1c7f65771eea47163c32a Author: Ton Voon <[email protected]> Date: Tue Jun 22 12:45:09 2010 +0100 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=4a0b843 check_snmp -l label is now used for performance label --- NEWS | 1 + plugins/check_snmp.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5ed4cf0..79601f3 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,7 @@ This file documents the major additions and syntax changes between releases. Updated developer documentation to say that performance labels should not have an equals sign or single quote in the label check_http 1.4.14 introduced SSL SNI support - you now have to enable it explicitly with "--sni" + check_snmp -l label option is also used for the performance label, which may change history from previous uses 1.4.14 16th September 2009 check_http has options to specify the HTTP method (#2155152) diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 82d77c4..5a02503 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -166,6 +166,7 @@ main (int argc, char **argv) time_t current_time; double temp_double; time_t duration; + char *conv = "12345678"; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -304,7 +305,10 @@ main (int argc, char **argv) } for (line=0, i=0; line < chld_out.lines; line++, i++) { - const char *conv = "%.0f"; + if(calculate_rate) + conv = "%.1f"; + else + conv = "%.0f"; ptr = chld_out.line[line]; oidname = strpcpy (oidname, ptr, delimiter); @@ -449,7 +453,7 @@ main (int argc, char **argv) result = max_state (result, iresult); /* Prepend a label for this OID if there is one */ - if (nlabels > (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) + if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) asprintf (&outbuff, "%s%s%s %s%s%s", outbuff, (i == 0) ? " " : output_delim, labels[i], mark (iresult), show, mark (iresult)); @@ -465,7 +469,11 @@ main (int argc, char **argv) ptr = NULL; strtod(show, &ptr); if (ptr > show) { - strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1); + if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) + temp_string=labels[i]; + else + temp_string=oidname; + strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); len = sizeof(perfstr)-strlen(perfstr)-1; strncat(perfstr, show, len>ptr-show ? ptr-show : len); @@ -704,7 +712,6 @@ process_arguments (int argc, char **argv) output_delim = strscpy (output_delim, optarg); break; case 'l': /* label */ - label = optarg; nlabels++; if (nlabels >= labels_size) { labels_size += 8; ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo