1
0
monitoring-plugins/monitoring-plugins.check_snmp.snmpv3-context.patch
Lars Vogdt 2fc871a63d - remove monitoring-plugins-postgresql.patch : fixed upstream
- add patch comments to spec file as requested by rpmlint
- rebase all patches to current code stream
  ENHANCEMENTS
  + check_snmp's performance data now also includes warning/critical
    thresholds
  + New check_snmp "-N" option to specify SNMPv3 context name
  + New check_nt "-l" parameters: seconds|minutes|hours|days
  + New check_mailq -s option which tells the plugin to use sudo(8)
  + New -W/-C option for check_ldap to check number of entries (Gerhard Lausser)
  + The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2"
    to force TLSv1.1 and TLSv1.2 connections, respectively
  + The check_http -S/--ssl option now allows for specifying the desired
    protocol with a "+" suffix to also accept newer versions
  + Let check_real terminate lines with CRLF when talking to the server, as
    mandated by 2326
  + Fix check_procs on HP-UX
  + check_smtp's -e/--expect option can now be combined with -S/--starttls
  WARNINGS
  + The format of the performance data emitted by check_mrtgtraf has been
    changed to comply with the development guidelines
  + check_ssh now returns CRITICAL for protocol/version errors
  + If a plugin is invoked with -h/--help or -V/--version, the exit status
    is now UNKNOWN
  + The superseded check_ntp.pl was removed, please use check_ntp_peer or
    check_ntp_time instead
  + plugins.negate.validate_arguments.patch

OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins?expand=0&rev=21
2015-10-26 16:38:39 +00:00

126 lines
4.9 KiB
Diff

Index: monitoring-plugins-2.1.2/plugins/check_snmp.c
===================================================================
--- monitoring-plugins-2.1.2.orig/plugins/check_snmp.c
+++ monitoring-plugins-2.1.2/plugins/check_snmp.c
@@ -103,6 +103,8 @@ int errcode, excode;
char *server_address = NULL;
char *community = NULL;
+char **context = NULL;
+char *v3context = NULL;
char **authpriv = NULL;
char *proto = NULL;
char *seclevel = NULL;
@@ -127,6 +129,7 @@ size_t nunits = 0;
size_t unitv_size = OID_COUNT_STEP;
int numoids = 0;
int numauthpriv = 0;
+int numcontext = 0;
int verbose = 0;
int usesnmpgetnext = FALSE;
char *warning_thresholds = NULL;
@@ -296,8 +299,8 @@ main (int argc, char **argv)
snmpcmd = strdup (PATH_TO_SNMPGET);
}
- /* 10 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */
- command_line = calloc (10 + numauthpriv + 1 + numoids + 1, sizeof (char *));
+ /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */
+ command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
command_line[0] = snmpcmd;
command_line[1] = strdup ("-Le");
command_line[2] = strdup ("-t");
@@ -309,23 +312,27 @@ main (int argc, char **argv)
command_line[8] = "-v";
command_line[9] = strdup (proto);
+ for (i = 0; i < numcontext; i++) {
+ command_line[10 + i] = context[i];
+ }
+
for (i = 0; i < numauthpriv; i++) {
- command_line[10 + i] = authpriv[i];
+ command_line[10 + numcontext + i] = authpriv[i];
}
- xasprintf (&command_line[10 + numauthpriv], "%s:%s", server_address, port);
+ xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port);
/* This is just for display purposes, so it can remain a string */
- xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s:%s",
- snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]",
+ xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s",
+ snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]",
server_address, port);
for (i = 0; i < numoids; i++) {
- command_line[10 + numauthpriv + 1 + i] = oids[i];
+ command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
}
- command_line[10 + numauthpriv + 1 + numoids] = NULL;
+ command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
if (verbose)
printf ("%s\n", cl_hidden_auth);
@@ -645,6 +652,7 @@ process_arguments (int argc, char **argv
{"retries", required_argument, 0, 'e'},
{"miblist", required_argument, 0, 'm'},
{"protocol", required_argument, 0, 'P'},
+ {"context", required_argument, 0, 'N'},
{"seclevel", required_argument, 0, 'L'},
{"secname", required_argument, 0, 'U'},
{"authproto", required_argument, 0, 'a'},
@@ -674,7 +682,7 @@ process_arguments (int argc, char **argv
}
while (1) {
- c = getopt_long (argc, argv, "nhvVOt: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, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:",
longopts, &option);
if (c == -1 || c == EOF)
@@ -712,6 +720,9 @@ process_arguments (int argc, char **argv
case 'P': /* SNMP protocol version */
proto = optarg;
break;
+ case 'N': /* SNMPv3 context */
+ v3context = optarg;
+ break;
case 'L': /* security level */
seclevel = optarg;
break;
@@ -959,6 +970,13 @@ validate_arguments ()
authpriv[1] = strdup (community);
}
else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
+ if (!(v3context == NULL)) {
+ numcontext = 2;
+ context = calloc (numcontext, sizeof (char *));
+ context[0] = strdup ("-n");
+ context[1] = strdup (v3context);
+ }
+
if (seclevel == NULL)
xasprintf(&seclevel, "noAuthNoPriv");
@@ -1102,6 +1120,8 @@ print_help (void)
printf (" %s\n", _("Use SNMP GETNEXT instead of SNMP GET"));
printf (" %s\n", "-P, --protocol=[1|2c|3]");
printf (" %s\n", _("SNMP protocol version"));
+ printf (" %s\n", "-N, --context=CONTEXT");
+ printf (" %s\n", _("SNMPv3 context"));
printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]");
printf (" %s\n", _("SNMPv3 securityLevel"));
printf (" %s\n", "-a, --authproto=[MD5|SHA]");
@@ -1209,6 +1229,6 @@ print_usage (void)
printf ("%s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]\n",progname);
printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
- printf ("[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n");
- printf ("[-A authpasswd] [-x privproto] [-X privpasswd]\n");
+ printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
+ printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n");
}