packages: nagios-snmp-plugins/check_snmp_load.patch - prettier print for Lo...

glen glen at pld-linux.org
Tue Sep 15 11:29:13 CEST 2009


Author: glen                         Date: Tue Sep 15 09:29:13 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- prettier print for Load OK

---- Files affected:
packages/nagios-snmp-plugins:
   check_snmp_load.patch (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: packages/nagios-snmp-plugins/check_snmp_load.patch
diff -u packages/nagios-snmp-plugins/check_snmp_load.patch:1.2 packages/nagios-snmp-plugins/check_snmp_load.patch:1.3
--- packages/nagios-snmp-plugins/check_snmp_load.patch:1.2	Tue Sep 15 10:36:27 2009
+++ packages/nagios-snmp-plugins/check_snmp_load.patch	Tue Sep 15 11:29:08 2009
@@ -26,8 +26,8 @@
  check_snmp_swap.o: check_snmp_swap.c snmp_common.h
 +check_snmp_load.o: check_snmp_load.c snmp_common.h
 --- /dev/null	2006-03-28 14:00:37.000000000 +0300
-+++ nagios-snmp-plugins-1.2/check_snmp_load.c	2009-09-15 11:34:52.330223445 +0300
-@@ -0,0 +1,191 @@
++++ nagios-snmp-plugins-1.2/check_snmp_load.c	2009-09-15 12:26:05.637055549 +0300
+@@ -0,0 +1,204 @@
 +/*************************************************************************
 + *
 + * plugins for Nagios
@@ -57,6 +57,8 @@
 +#define RCS_VERSION "$Revision$ ($Date$)"
 +
 +#define LOAD_INDEX_MIB       ".1.3.6.1.4.1.2021.10.1.1"
++#define LOAD_LOADAVG_MIB     ".1.3.6.1.4.1.2021.10.1.3"
++#define LOAD_CONFIG_MIB      ".1.3.6.1.4.1.2021.10.1.4"
 +#define LOAD_ERRORFLAG_MIB   ".1.3.6.1.4.1.2021.10.1.100"
 +#define LOAD_ERRORMSG_MIB    ".1.3.6.1.4.1.2021.10.1.101"
 +
@@ -157,7 +159,6 @@
 +static int report_load() {
 +	int cnt;
 +	long *errors;
-+	void *pnt;
 +	int i, j;
 +	int nerrors = 0;
 +	char **errormsg = NULL;
@@ -167,8 +168,8 @@
 +		return STATE_UNKNOWN;
 +	}
 +
-+	if (!cnt) {
-+		printf("%s: Not configured.\n", bn);
++	if (cnt != 3) {
++		printf("%s: Invalid count for Index MIB (%d).\n", bn, cnt);
 +		return STATE_WARNING;
 +	}
 +
@@ -177,8 +178,7 @@
 +		return STATE_CRITICAL;
 +	}
 +
-+	pnt = errors;
-+	if (fetch_table(LOAD_ERRORFLAG_MIB, integer_callback, pnt, cnt) < 0) {
++	if (fetch_table(LOAD_ERRORFLAG_MIB, integer_callback, errors, cnt) < 0) {
 +		printf("%s: Could not fetch error list!\n", bn);
 +		return STATE_UNKNOWN;
 +	}
@@ -194,7 +194,21 @@
 +	}
 +
 +	if (nerrors == 0) {
-+		printf("Checked load for %d entries.\n", cnt);
++		char **loadavg = calloc(sizeof(char **), cnt);
++		char **loadcfg = calloc(sizeof(char **), cnt);
++		if (!loadavg || !loadcfg) {
++			printf("%s: Could not allocate memory for loadavg\n", bn);
++			return STATE_CRITICAL;
++		}
++		if (fetch_table(LOAD_LOADAVG_MIB, string_callback, loadavg, cnt) < 0) {
++			printf("%s: Could not fetch current loadavg!\n", bn);
++			return STATE_UNKNOWN;
++		}
++		if (fetch_table(LOAD_CONFIG_MIB, string_callback, loadcfg, cnt) < 0) {
++			printf("%s: Could not fetch configured loadavg!\n", bn);
++			return STATE_UNKNOWN;
++		}
++		printf("Load OK: %s, %s, %s (max: %s, %s, %s).\n", loadavg[0], loadavg[1], loadavg[2], loadcfg[0], loadcfg[1], loadcfg[2]);
 +		return STATE_OK;
 +	}
 +
@@ -204,8 +218,7 @@
 +		return STATE_CRITICAL;
 +	}
 +
-+	pnt = errormsg;
-+	if (fetch_table(LOAD_ERRORMSG_MIB, string_callback, pnt, cnt) < 0) {
++	if (fetch_table(LOAD_ERRORMSG_MIB, string_callback, errormsg, cnt) < 0) {
 +		printf("%s: Could not fetch error messages\n", bn);
 +		return STATE_CRITICAL;
 +	}
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-snmp-plugins/check_snmp_load.patch?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list