summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2bc0368)
raw | patch | inline | side by side (parent: 2bc0368)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 1 Aug 2002 04:54:18 +0000 (04:54 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 1 Aug 2002 04:54:18 +0000 (04:54 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@67 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_snmp.c | patch | blob | history |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index bfc49aa8e7d7e78adcf1748a94fb7f0e83d70e71..13e12ff8f567459c63b4a55bb29d7b2d6c09bf9f 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
/* create the command line to execute */
command_line = ssprintf
(command_line,
- "%s -m ALL -v 1 %s %s %s",
- PATH_TO_SNMPGET, server_address, community, oid);
+ "%s -p %s -m ALL -v 1 %s -c %s %s",
+ PATH_TO_SNMPGET, port, server_address, community, oid);
/* run the command */
child_process = spopen (command_line);
p2 = strpbrk (p2, "0123456789");
response_value[i] = strtoul (p2, NULL, 10);
iresult = check_num (i);
- show = ssprintf (show, "%lu", response_value[i]);
+ /*For consistency- full SNMP response every time */
+ show = ssprintf (show, "%d", response);
}
else if (eval_method[i] & CRIT_STRING) {
iresult = STATE_WARNING;
}
- result = max_state (result, iresult);
+ result = max (result, iresult);
if (nlabels > 1 && i < nlabels && labels[i] != NULL)
outbuff = ssprintf
/* WARNING if output found on stderr */
if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max_state (result, STATE_WARNING);
+ result = max (result, STATE_WARNING);
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max_state (result, STATE_WARNING);
+ result = max (result, STATE_WARNING);
if (nunits > 0)
printf ("%s %s -%s\n", label, state_text (result), outbuff);
if (port == NULL)
port = strscpy(NULL,"161");
- if (port == NULL)
- port = strscpy(NULL,"161");
-
return c;
}
{"eregi", required_argument, 0, 'R'},
{"label", required_argument, 0, 'l'},
{"units", required_argument, 0, 'u'},
+ {"port", required_argument, 0, 'p'},
{0, 0, 0, 0}
};
#endif
while (1) {
#ifdef HAVE_GETOPT_H
c =
- getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:",
+ getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:",
long_options, &option_index);
#else
- c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:");
+ c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:");
#endif
if (c == -1 || c == EOF)
unitv[nunits - 1] = ptr;
}
break;
+ case 'p': /* TCP port number */
+ port = strscpy(port, optarg);
+ break;
+
}
}
return i;
printf
("Usage: check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n"
" [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n"
- " [-l label] [-u units] [-d delimiter] [-D output-delimiter]\n"
+ " [-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"
" check_snmp --help\n" " check_snmp --version\n");
}
" -u, --units=STRING\n"
" Units label(s) for output data (e.g., 'sec.').\n"
" -p, --port=STRING\n"
- " TCP port number target is listening on.\n"
+ " UDP port number target is listening on.\n"
" -d, --delimiter=STRING\n"
" Delimiter to use when parsing returned data. Default is \"%s\"\n"
" Any data on the right hand side of the delimiter is considered\n"