Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2012-07-26 12:25:50 UTC (rev 9621)
+++ trunk/CHANGES 2012-07-26 12:29:44 UTC (rev 9622)
@@ -17,6 +17,7 @@
Updated Nagios::Plugin and dependencies
Log the full query_host command into opsview-web.log if there is an error picked up
Updated Perl modules as of July 2012
+ Allow check_snmp performance data units to be overridden
NOTICES:
Opsview Web does not install new monitor packs on start - use install_all_opspacks command line utility
Renamed install_monitor_pack to install_opspack and create_monitor_pack to create_opspack
Modified: trunk/opsview-base/Makefile
===================================================================
--- trunk/opsview-base/Makefile 2012-07-26 12:25:50 UTC (rev 9621)
+++ trunk/opsview-base/Makefile 2012-07-26 12:29:44 UTC (rev 9622)
@@ -563,6 +563,7 @@
# Below added due to not being able to compile on Ubuntu12. This has an impact of using pm only for all agents on all platforms,
# but this is okay
cd ${NAGIOSPLUG} && patch -p1 < ../patches/nagios_plugins_params_validate_noxs.patch
+ cd ${NAGIOSPLUG} && patch -p1 < ../patches/nagiosplug_check_snmp_override_perfstat_units.patch
if [ `uname -s` = Linux ] ; then \
cd ${NAGIOSPLUG} && PATH="/usr/bin:/usr/sbin:$$PATH" CFLAGS="${CFLAGS}" ./configure --with-mysql --with-nagios-user=$(NAGIOS_USER) --with-nagios-group=$(NAGIOS_GROUP) ${NAGIOSPLUG_CONFIGURE_PERL_MODULES} --localstatedir=/usr/local/nagios/var/plugins && make ; \
elif [ `uname -s` = Darwin ] ; then \
Added: trunk/opsview-base/patches/nagiosplug_check_snmp_override_perfstat_units.patch
===================================================================
--- trunk/opsview-base/patches/nagiosplug_check_snmp_override_perfstat_units.patch (rev 0)
+++ trunk/opsview-base/patches/nagiosplug_check_snmp_override_perfstat_units.patch 2012-07-26 12:29:44 UTC (rev 9622)
@@ -0,0 +1,113 @@
+diff -ur nagios-plugins-1.4.15.orig/plugins/check_snmp.c nagios-plugins-1.4.15/plugins/check_snmp.c
+--- nagios-plugins-1.4.15.orig/plugins/check_snmp.c 2012-07-18 10:17:59.000000000 +0000
++++ nagios-plugins-1.4.15/plugins/check_snmp.c 2012-07-26 12:00:10.000000000 +0000
+@@ -113,16 +113,20 @@
+ char **oids = NULL;
+ char *label;
+ char *units;
++char *unittypes;
+ char *port;
+ char *snmpcmd;
+ char string_value[MAX_INPUT_BUFFER] = "";
+ int invert_search=0;
+ char **labels = NULL;
+ char **unitv = NULL;
++char **unittypesv = NULL;
+ size_t nlabels = 0;
+ size_t labels_size = 8;
+ size_t nunits = 0;
+ size_t unitv_size = 8;
++size_t nunittypes = 0;
++size_t unittypesv_size = 8;
+ int numoids = 0;
+ int numauthpriv = 0;
+ int verbose = 0;
+@@ -181,11 +185,13 @@
+
+ labels = malloc (labels_size);
+ unitv = malloc (unitv_size);
++ unittypesv = malloc (unittypesv_size);
+ for (i = 0; i < MAX_OIDS; i++)
+ eval_method[i] = CHECK_UNDEF;
+
+ label = strdup ("SNMP");
+ units = strdup ("");
++ unittypes = strdup ("");
+ port = strdup (DEFAULT_PORT);
+ outbuff = strdup ("");
+ delimiter = strdup (" = ");
+@@ -396,6 +402,12 @@
+ else
+ show = response;
+
++ if(!calculate_rate) {
++ if (nunittypes > (size_t)0 && (size_t)i < nunittypes && unittypesv[i] != NULL)
++ //asprintf (&outbuff, "%s %s", outbuff, unitsv[i]);
++ strcpy(type, unittypesv[i]);
++ }
++
+ iresult = STATE_DEPENDENT;
+
+ /* Process this block for numeric comparisons */
+@@ -569,6 +581,7 @@
+ {"eregi", required_argument, 0, 'R'},
+ {"label", required_argument, 0, 'l'},
+ {"units", required_argument, 0, 'u'},
++ {"unit_type", required_argument, 0, 'T'},
+ {"port", required_argument, 0, 'p'},
+ {"retries", required_argument, 0, 'e'},
+ {"miblist", required_argument, 0, 'm'},
+@@ -600,7 +613,7 @@
+ }
+
+ while (1) {
+- c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:",
++ c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:T:",
+ longopts, &option);
+
+ if (c == -1 || c == EOF)
+@@ -786,6 +799,35 @@
+ unitv[nunits - 1] = ptr;
+ }
+ break;
++ case 'T': /* units */
++ unittypes = optarg;
++ nunittypes++;
++ if (nunittypes >= unittypesv_size) {
++ unittypesv_size += 8;
++ unittypesv = realloc (unittypesv, unittypesv_size);
++ if (unittypesv == NULL)
++ die (STATE_UNKNOWN, _("Could not reallocate unit types [%d]\n"), (int)nunittypes);
++ }
++ unittypesv[nunittypes - 1] = optarg;
++ ptr = thisarg (optarg);
++ unittypesv[nunittypes - 1] = ptr;
++ if (strstr (ptr, "'") == ptr)
++ unittypesv[nunittypes - 1] = ptr + 1;
++ while (ptr && (ptr = nextarg (ptr))) {
++ if (nunittypes >= unittypesv_size) {
++ unittypesv_size += 8;
++ unittypesv = realloc (unittypesv, unittypesv_size);
++ if (unittypes == NULL)
++ die (STATE_UNKNOWN, _("Could not realloc() unit types\n"));
++ }
++ nunittypes++;
++ ptr = thisarg (ptr);
++ if (strstr (ptr, "'") == ptr)
++ unittypesv[nunittypes - 1] = ptr + 1;
++ else
++ unittypesv[nunittypes - 1] = ptr;
++ }
++ break;
+ case L_CALCULATE_RATE:
+ if(calculate_rate==0)
+ np_enable_state(NULL, 1);
+@@ -1056,6 +1098,8 @@
+ printf (" %s\n", _("Prefix label for output from plugin"));
+ printf (" %s\n", "-u, --units=STRING");
+ printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
++ printf (" %s\n", "-T, --unit_type=STRING");
++ printf (" %s\n", _("Override calculated performance data unit type(s) for output data"));
+ printf (" %s\n", "-D, --output-delimiter=STRING");
+ printf (" %s\n", _("Separates output on multiple OID requests"));
+