aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--LEGAL10
-rw-r--r--Makefile.am2
-rw-r--r--NEWS17
-rw-r--r--configure.ac14
-rw-r--r--doc/RELEASING38
-rw-r--r--lib/utils_cmd.c14
-rw-r--r--plugins-root/check_icmp.c75
-rw-r--r--plugins/check_mrtgtraf.c14
-rw-r--r--plugins/check_nt.c51
-rw-r--r--plugins/check_real.c8
-rw-r--r--plugins/check_snmp.c54
-rw-r--r--plugins/check_ssh.c12
-rw-r--r--plugins/check_swap.c3
14 files changed, 214 insertions, 99 deletions
diff --git a/.gitignore b/.gitignore
index 8ea2d8e5..3093c6ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ NP-VERSION-FILE
/build-aux/install-sh
/build-aux/missing
/build-aux/mkinstalldirs
+/build-aux/test-driver
# /doc/
/doc/developer-guidelines.html
diff --git a/LEGAL b/LEGAL
deleted file mode 100644
index 147fc989..00000000
--- a/LEGAL
+++ /dev/null
@@ -1,10 +0,0 @@
-
-All source code, binaries, documentation, and information contained
-in this distribution are provided AS IS with NO WARRANTY OF ANY KIND,
-INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR
-A PARTICULAR PURPOSE.
-
-Nagios and the Nagios logo are trademarks of Ethan Galstad. All
-other trademarks, servicemarks, registered trademarks, and
-registered servicemarks are the property of their respective owner(s).
-
diff --git a/Makefile.am b/Makefile.am
index 9ee0800e..7e0d4131 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
EXTRA_DIST = config.rpath \
- ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ LEGAL NEWS \
+ ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm pkg \
config_test/Makefile config_test/run_tests config_test/child_test.c \
diff --git a/NEWS b/NEWS
index c999e515..70ee6591 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,22 @@
This file documents the major additions and syntax changes between releases.
+2.2 [...]
+ 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
+
+ FIXES
+ Let check_real terminate lines with CRLF when talking to the server, as
+ mandated by 2326
+ Fix check_procs on HP-UX
+
+ WARNINGS
+ The format of the performance data emitted by check_mrtgtraf has been
+ changed to comply with the development guidelines
+ check_ssh not returns CRITICAL for protocal/version errors
+
2.1.1 2nd December 2014
FIXES
Fix check_ntp's jitter checking
diff --git a/configure.ac b/configure.ac
index 2429e990..a6c9e79a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -610,6 +610,7 @@ AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
dnl #### Process table test
AC_PATH_PROG(PATH_TO_PS,ps)
+AC_PATH_PROG(PATH_TO_ENV,env)
AC_MSG_CHECKING(for ps syntax)
AC_ARG_WITH(ps_command,
@@ -931,6 +932,19 @@ then
ac_cv_ps_cols=6
AC_MSG_RESULT([$ac_cv_ps_command])
+dnl HP-UX:
+dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND COMMAND
+dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X
+dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
+elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
+ egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
+then
+ ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
+ ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
+ ac_cv_ps_format="%s %d %d %d %d %f %s %n"
+ ac_cv_ps_cols=8
+ AC_MSG_RESULT([$ac_cv_ps_command])
+
dnl AIX 4.1:
dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
diff --git a/doc/RELEASING b/doc/RELEASING
index 1eaec9de..eee53d7b 100644
--- a/doc/RELEASING
+++ b/doc/RELEASING
@@ -1,4 +1,4 @@
-NOTES ON RELEASING NEW VERSION OF NAGIOSPLUG
+NOTES ON RELEASING NEW VERSION OF MONITORING-PLUGINS
*** Pre-release
git pull
@@ -6,25 +6,23 @@ git pull
check compilation, check tinderbox screens
*** Prepare and commit files
-Update BUGS, NEWS file
+Update NEWS file
Update AUTHORS if new members
-Update configure.in, package.def and NP-VERSION-GEN with version
-Run git2cl (get from http://josefsson.org/git2cl/):
-git2cl >Changelog
-commit BUGS NEWS configure.in package.def ChangeLog
+Update configure.ac and NP-VERSION-GEN with version
+commit NEWS configure.ac NP-VERSION-GEN
*** Create new annotated tag
-git tag -a release-1.4.14 -m release-1.4.14
+git tag -a v2.1.1 -m v2.1.1
*** Push the code and tag to origin
git push origin master
-git push origin release-1.4.14
+git push origin v2.1.1
*** Checkout new version
rm -fr /tmp/monitoringlug
# If you need to checkout the tag, don't forget to "checkout master" later to
# get back to your development branch:
-git checkout tags/release-1.4.14
+git checkout tags/v2.1.1
# Beware: the trailing slash of --prefix is REQUIRED
git checkout-index --prefix=/tmp/monitoringlug/ -a
@@ -34,27 +32,7 @@ tools/setup
./configure
make dist
-*** Upload generated tarball to sourceforge
-sftp frs.sourceforge.net
-SF username and password
-cd /uploads
-put file
-
-SF -> Submit News about release. Make sure it is called "Monitoring Plugins" (with those caps)
-Link to download at http://sourceforge.net/project/showfiles.php?group_id=29880
-Include contents of NEWS for this release
-List all people on team involved.
-Add acknowledgement to contributors
-Submit. Get URL to news item
-
-SF -> Admin -> File Releases
-Add a release to nagiosplug and create a file release
-Name: 1.4.14
-Create release
-Step 1: Add release notes pointing to news item
-Step 2: add file
-Step 3: *.tar.gz, Platform Independent, Source .gz
-Step 4: Send notice
+*** Upload generated tarball to our Project Site
*** Announce new release
Send email to help, announce with the news text
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 9e214bd4..7eb9a3a0 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -79,12 +79,14 @@ static pid_t *_cmd_pids = NULL;
* If that fails and the macro isn't defined, we fall back to an educated
* guess. There's no guarantee that our guess is adequate and the program
* will die with SIGSEGV if it isn't and the upper boundary is breached. */
+#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
+#define MAXFD_LIMIT 8192 /* upper limit of open files */
#ifdef _SC_OPEN_MAX
static long maxfd = 0;
#elif defined(OPEN_MAX)
# define maxfd OPEN_MAX
#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
-# define maxfd 256
+# define maxfd DEFAULT_MAXFD
#endif
@@ -112,10 +114,18 @@ cmd_init (void)
if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
/* possibly log or emit a warning here, since there's no
* guarantee that our guess at maxfd will be adequate */
- maxfd = 256;
+ maxfd = DEFAULT_MAXFD;
}
#endif
+ /* if maxfd is unnaturally high, we force it to a lower value
+ * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
+ * a segfault when following calloc is called ... ) */
+
+ if ( maxfd > MAXFD_LIMIT ) {
+ maxfd = MAXFD_LIMIT;
+ }
+
if (!_cmd_pids)
_cmd_pids = calloc (maxfd, sizeof (pid_t));
}
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 8b563e40..44c6826c 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -184,7 +184,7 @@ static u_int get_timevar(const char *);
static u_int get_timevaldiff(struct timeval *, struct timeval *);
static in_addr_t get_ip_address(const char *);
static int wait_for_reply(int, u_int);
-static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *);
+static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
static int send_icmp_ping(int, struct rta_host *);
static int get_threshold(char *str, threshold *th);
static void run_checks(void);
@@ -378,6 +378,9 @@ main(int argc, char **argv)
int icmp_sockerrno, udp_sockerrno, tcp_sockerrno;
int result;
struct rta_host *host;
+#ifdef SO_TIMESTAMP
+ int on = 1;
+#endif
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -402,6 +405,11 @@ main(int argc, char **argv)
/* now drop privileges (no effect if not setsuid or geteuid() == 0) */
setuid(getuid());
+#ifdef SO_TIMESTAMP
+ if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
+ if(debug) printf("Warning: no SO_TIMESTAMP support\n");
+#endif // SO_TIMESTAMP
+
/* POSIXLY_CORRECT might break things, so unset it (the portable way) */
environ = NULL;
@@ -462,13 +470,13 @@ main(int argc, char **argv)
/* parse the arguments */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) {
- long size;
+ unsigned short size;
switch(arg) {
case 'v':
debug++;
break;
case 'b':
- size = strtol(optarg,NULL,0);
+ size = (unsigned short)strtol(optarg,NULL,0);
if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) &&
size < MAX_PING_DATA) {
icmp_data_size = size;
@@ -727,7 +735,7 @@ wait_for_reply(int sock, u_int t)
/* reap responses until we hit a timeout */
n = recvfrom_wto(sock, buf, sizeof(buf),
- (struct sockaddr *)&resp_addr, &t);
+ (struct sockaddr *)&resp_addr, &t, &now);
if(!n) {
if(debug > 1) {
printf("recvfrom_wto() timed out during a %u usecs wait\n",
@@ -777,11 +785,10 @@ wait_for_reply(int sock, u_int t)
/* this is indeed a valid response */
memcpy(&data, icp.icmp_data, sizeof(data));
if (debug > 2)
- printf("ICMP echo-reply of len %u, id %u, seq %u, cksum 0x%X\n",
+ printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n",
sizeof(data), ntohs(icp.icmp_id), ntohs(icp.icmp_seq), icp.icmp_cksum);
host = table[ntohs(icp.icmp_seq)/packets];
- gettimeofday(&now, &tz);
tdiff = get_timevaldiff(&data.stime, &now);
host->time_waited += tdiff;
@@ -823,6 +830,8 @@ send_icmp_ping(int sock, struct rta_host *host)
} packet = { NULL };
long int len;
struct icmp_ping_data data;
+ struct msghdr hdr;
+ struct iovec iov;
struct timeval tv;
struct sockaddr *addr;
@@ -855,11 +864,20 @@ send_icmp_ping(int sock, struct rta_host *host)
packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size);
if (debug > 2)
- printf("Sending ICMP echo-request of len %u, id %u, seq %u, cksum 0x%X to host %s\n",
+ printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
sizeof(data), ntohs(packet.icp->icmp_id), ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum, host->name);
- len = sendto(sock, packet.buf, icmp_pkt_size, 0, (struct sockaddr *)addr,
- sizeof(struct sockaddr));
+ memset(&iov, 0, sizeof(iov));
+ iov.iov_base = packet.buf;
+ iov.iov_len = icmp_pkt_size;
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.msg_name = addr;
+ hdr.msg_namelen = sizeof(struct sockaddr);
+ hdr.msg_iov = &iov;
+ hdr.msg_iovlen = 1;
+
+ len = sendmsg(sock, &hdr, MSG_CONFIRM);
if(len < 0 || (unsigned int)len != icmp_pkt_size) {
if(debug) printf("Failed to send ping to %s\n",
@@ -875,12 +893,18 @@ send_icmp_ping(int sock, struct rta_host *host)
static int
recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
- u_int *timo)
+ u_int *timo, struct timeval* tv)
{
u_int slen;
- int n;
+ int n, ret;
struct timeval to, then, now;
fd_set rd, wr;
+ char ans_data[4096];
+ struct msghdr hdr;
+ struct iovec iov;
+#ifdef SO_TIMESTAMP
+ struct cmsghdr* chdr;
+#endif
if(!*timo) {
if(debug) printf("*timo is not\n");
@@ -904,7 +928,32 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
slen = sizeof(struct sockaddr);
- return recvfrom(sock, buf, len, 0, saddr, &slen);
+ memset(&iov, 0, sizeof(iov));
+ iov.iov_base = buf;
+ iov.iov_len = len;
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.msg_name = saddr;
+ hdr.msg_namelen = slen;
+ hdr.msg_iov = &iov;
+ hdr.msg_iovlen = 1;
+ hdr.msg_control = ans_data;
+ hdr.msg_controllen = sizeof(ans_data);
+
+ ret = recvmsg(sock, &hdr, 0);
+#ifdef SO_TIMESTAMP
+ for(chdr = CMSG_FIRSTHDR(&hdr); chdr; chdr = CMSG_NXTHDR(&hdr, chdr)) {
+ if(chdr->cmsg_level == SOL_SOCKET
+ && chdr->cmsg_type == SO_TIMESTAMP
+ && chdr->cmsg_len >= CMSG_LEN(sizeof(struct timeval))) {
+ memcpy(tv, CMSG_DATA(chdr), sizeof(*tv));
+ break ;
+ }
+ }
+ if (!chdr)
+#endif // SO_TIMESTAMP
+ gettimeofday(tv, &tz);
+ return (ret);
}
static void
@@ -1183,7 +1232,7 @@ static u_int
get_timevar(const char *str)
{
char p, u, *ptr;
- unsigned int len;
+ size_t len;
u_int i, d; /* integer and decimal, respectively */
u_int factor = 1000; /* default to milliseconds */
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index 32ba0507..3b038cf1 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -148,37 +148,37 @@ main (int argc, char **argv)
/* report incoming traffic in Bytes/sec */
if (incoming_rate < 1024) {
- strcpy (incoming_speed_rating, "B/s");
+ strcpy (incoming_speed_rating, "B");
adjusted_incoming_rate = (double) incoming_rate;
}
/* report incoming traffic in KBytes/sec */
else if (incoming_rate < (1024 * 1024)) {
- strcpy (incoming_speed_rating, "KB/s");
+ strcpy (incoming_speed_rating, "KB");
adjusted_incoming_rate = (double) (incoming_rate / 1024.0);
}
/* report incoming traffic in MBytes/sec */
else {
- strcpy (incoming_speed_rating, "MB/s");
+ strcpy (incoming_speed_rating, "MB");
adjusted_incoming_rate = (double) (incoming_rate / 1024.0 / 1024.0);
}
/* report outgoing traffic in Bytes/sec */
if (outgoing_rate < 1024) {
- strcpy (outgoing_speed_rating, "B/s");
+ strcpy (outgoing_speed_rating, "B");
adjusted_outgoing_rate = (double) outgoing_rate;
}
/* report outgoing traffic in KBytes/sec */
else if (outgoing_rate < (1024 * 1024)) {
- strcpy (outgoing_speed_rating, "KB/s");
+ strcpy (outgoing_speed_rating, "KB");
adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0);
}
/* report outgoing traffic in MBytes/sec */
else {
- strcpy (outgoing_speed_rating, "MB/s");
+ strcpy (outgoing_speed_rating, "MB");
adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0 / 1024.0);
}
@@ -191,7 +191,7 @@ main (int argc, char **argv)
result = STATE_WARNING;
}
- xasprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"),
+ xasprintf (&error_message, _("%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"),
(use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate,
incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"),
adjusted_outgoing_rate, outgoing_speed_rating,
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index fefbfb7a..f621b0a8 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -197,19 +197,40 @@ int main(int argc, char **argv){
case CHECK_UPTIME:
- xasprintf(&send_buffer, "%s&3", req_password);
- fetch_data (server_address, server_port, send_buffer);
- uptime=strtoul(recv_buffer,NULL,10);
- updays = uptime / 86400;
- uphours = (uptime % 86400) / 3600;
- upminutes = ((uptime % 86400) % 3600) / 60;
- xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)|uptime=%lu"), updays, uphours, upminutes, uptime);
- if (check_critical_value==TRUE && uptime <= critical_value)
- return_code=STATE_CRITICAL;
- else if (check_warning_value==TRUE && uptime <= warning_value)
- return_code=STATE_WARNING;
- else
- return_code=STATE_OK;
+ if (value_list == NULL) {
+ value_list = "minutes";
+ }
+ if (strncmp(value_list, "seconds", strlen("seconds") + 1 ) &&
+ strncmp(value_list, "minutes", strlen("minutes") + 1) &&
+ strncmp(value_list, "hours", strlen("hours") + 1) &&
+ strncmp(value_list, "days", strlen("days") + 1)) {
+
+ output_message = strdup (_("wrong -l argument"));
+ } else {
+ xasprintf(&send_buffer, "%s&3", req_password);
+ fetch_data (server_address, server_port, send_buffer);
+ uptime=strtoul(recv_buffer,NULL,10);
+ updays = uptime / 86400;
+ uphours = (uptime % 86400) / 3600;
+ upminutes = ((uptime % 86400) % 3600) / 60;
+
+ if (!strncmp(value_list, "minutes", strlen("minutes")))
+ uptime = uptime / 60;
+ else if (!strncmp(value_list, "hours", strlen("hours")))
+ uptime = uptime / 3600;
+ else if (!strncmp(value_list, "days", strlen("days")))
+ uptime = uptime / 86400;
+ /* else uptime in seconds, nothing to do */
+
+ xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime);
+
+ if (check_critical_value==TRUE && uptime <= critical_value)
+ return_code=STATE_CRITICAL;
+ else if (check_warning_value==TRUE && uptime <= warning_value)
+ return_code=STATE_WARNING;
+ else
+ return_code=STATE_OK;
+ }
break;
case CHECK_USEDDISKSPACE:
@@ -713,7 +734,9 @@ void print_help(void)
printf (" %s\n", "ie: -l 60,90,95,120,90,95");
printf (" %s\n", "UPTIME =");
printf (" %s\n", _("Get the uptime of the machine."));
- printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
+ printf (" %s\n", _("-l <unit> "));
+ printf (" %s\n", _("<unit> = seconds, minutes, hours, or days. (default: minutes)"));
+ printf (" %s\n", _("Thresholds will use the unit specified above."));
printf (" %s\n", "USEDDISKSPACE =");
printf (" %s\n", _("Size and percentage of disk use."));
printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
diff --git a/plugins/check_real.c b/plugins/check_real.c
index 1816bf56..00bd4d20 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -163,17 +163,17 @@ main (int argc, char **argv)
/* Part I - Server Check */
- /* send the OPTIONS request */
- sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\n", host_name,
+ /* send the DESCRIBE request */
+ sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\r\n", host_name,
server_port, server_url);
result = send (sd, buffer, strlen (buffer), 0);
/* send the header sync */
- sprintf (buffer, "CSeq: 2\n");
+ sprintf (buffer, "CSeq: 2\r\n");
result = send (sd, buffer, strlen (buffer), 0);
/* send a newline so the server knows we're done with the request */
- sprintf (buffer, "\n");
+ sprintf (buffer, "\r\n");
result = send (sd, buffer, strlen (buffer), 0);
/* watch for the REAL connection string */
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 2c62a230..9d966faa 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -104,6 +104,8 @@ int errcode, excode;
char *server_address = NULL;
char *community = NULL;
+char **contextargs = NULL;
+char *context = NULL;
char **authpriv = NULL;
char *proto = NULL;
char *seclevel = NULL;
@@ -128,6 +130,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;
@@ -297,8 +300,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");
@@ -310,23 +313,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] = contextargs[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);
@@ -567,6 +574,18 @@ main (int argc, char **argv)
len = sizeof(perfstr)-strlen(perfstr)-1;
strncat(perfstr, show, len>ptr-show ? ptr-show : len);
+ if (warning_thresholds) {
+ strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
+ }
+
+ if (critical_thresholds) {
+ if (!warning_thresholds)
+ strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
+ }
+
if (type)
strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
@@ -646,6 +665,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'},
@@ -675,7 +695,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)
@@ -713,6 +733,9 @@ process_arguments (int argc, char **argv)
case 'P': /* SNMP protocol version */
proto = optarg;
break;
+ case 'N': /* SNMPv3 context */
+ context = optarg;
+ break;
case 'L': /* security level */
seclevel = optarg;
break;
@@ -960,6 +983,13 @@ validate_arguments ()
authpriv[1] = strdup (community);
}
else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
+ if (!(context == NULL)) {
+ numcontext = 2;
+ contextargs = calloc (numcontext, sizeof (char *));
+ contextargs[0] = strdup ("-n");
+ contextargs[1] = strdup (context);
+ }
+
if (seclevel == NULL)
xasprintf(&seclevel, "noAuthNoPriv");
@@ -1103,6 +1133,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]");
@@ -1210,6 +1242,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");
}
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index b6187d61..3658965e 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -253,18 +253,18 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol
if (remote_version && strcmp(remote_version, ssh_server)) {
printf
- (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
+ (_("SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"),
ssh_server, ssh_proto, remote_version);
close(sd);
- exit (STATE_WARNING);
+ exit (STATE_CRITICAL);
}
if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
printf
- (_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
+ (_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
ssh_server, ssh_proto, remote_protocol);
close(sd);
- exit (STATE_WARNING);
+ exit (STATE_CRITICAL);
}
elapsed_time = (double)deltime(tv) / 1.0e6;
@@ -307,10 +307,10 @@ print_help (void)
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
printf (" %s\n", "-r, --remote-version=STRING");
- printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
+ printf (" %s\n", _("Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
printf (" %s\n", "-P, --remote-protocol=STRING");
- printf (" %s\n", _("Warn if protocol doesn't match expected protocol version (ex: 2.0)"));
+ printf (" %s\n", _("Alert if protocol doesn't match expected protocol version (ex: 2.0)"));
printf (UT_VERBOSE);
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 88a2a2ad..25e0bacd 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,6 +1,6 @@
/*****************************************************************************
*
-* Monitoring check_disk plugin
+* Monitoring check_swap plugin
*
* License: GPL
* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
@@ -352,6 +352,7 @@ main (int argc, char **argv)
percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
} else {
percent_used = 100;
+ status = "- Swap is either disabled, not present, or of zero size. ";
}
result = max_state (result, check_swap (percent_used, free_swap_mb));