summaryrefslogtreecommitdiff
path: root/net-mgmt/nagios-plugins
diff options
context:
space:
mode:
authorDmitry Sivachenko <demon@FreeBSD.org>2005-06-20 05:48:16 +0000
committerDmitry Sivachenko <demon@FreeBSD.org>2005-06-20 05:48:16 +0000
commit990a0dd8e57f621afe31ca2f78fc3d7ab14e750a (patch)
tree41ebfc90d4d3346992679bac56cd99a6696ed121 /net-mgmt/nagios-plugins
parentUpgrade to version 2.12.2. (diff)
Fix check_nagios plugin to work with nagios-2.x.
The format of status file changed a lot since nagios-1.x, so we just check that mtime is fresh enough. Reviewed by: maintainer
Notes
Notes: svn path=/head/; revision=137744
Diffstat (limited to 'net-mgmt/nagios-plugins')
-rw-r--r--net-mgmt/nagios-plugins/Makefile2
-rw-r--r--net-mgmt/nagios-plugins/files/patch-check_nagios.c53
2 files changed, 54 insertions, 1 deletions
diff --git a/net-mgmt/nagios-plugins/Makefile b/net-mgmt/nagios-plugins/Makefile
index b3cf3cde2a3e..54281c2d90f6 100644
--- a/net-mgmt/nagios-plugins/Makefile
+++ b/net-mgmt/nagios-plugins/Makefile
@@ -7,7 +7,7 @@
PORTNAME= nagios-plugins
PORTVERSION= 1.4
-PORTREVISION= 2
+PORTREVISION= 3
PORTEPOCH= 1
CATEGORIES= net-mgmt
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_EXTENDED}
diff --git a/net-mgmt/nagios-plugins/files/patch-check_nagios.c b/net-mgmt/nagios-plugins/files/patch-check_nagios.c
new file mode 100644
index 000000000000..9413d92dabd7
--- /dev/null
+++ b/net-mgmt/nagios-plugins/files/patch-check_nagios.c
@@ -0,0 +1,53 @@
+--- plugins/check_nagios.c.orig Sun Jun 19 09:51:52 2005
++++ plugins/check_nagios.c Sun Jun 19 09:53:28 2005
+@@ -26,6 +26,8 @@
+ #include "common.h"
+ #include "popen.h"
+ #include "utils.h"
++#include <sys/types.h>
++#include <sys/stat.h>
+
+ int process_arguments (int, char **);
+ void print_help (void);
+@@ -42,12 +44,12 @@
+ {
+ int result = STATE_UNKNOWN;
+ char input_buffer[MAX_INPUT_BUFFER];
+- unsigned long latest_entry_time = 0L;
+- unsigned long temp_entry_time = 0L;
++ unsigned long latest_entry_time;
+ int proc_entries = 0;
+ time_t current_time;
+ char *temp_ptr;
+- FILE *fp;
++ struct stat sb;
++ int err;
+ int procuid = 0;
+ int procppid = 0;
+ int procvsz = 0;
+@@ -78,21 +80,14 @@
+ alarm (timeout_interval);
+
+ /* open the status log */
+- fp = fopen (status_log, "r");
+- if (fp == NULL) {
+- printf (_("CRITICAL - Cannot open status log for reading!\n"));
++ err = stat(status_log, &sb);
++ if (err) {
++ printf (_("CRITICAL - Cannot get modification time of status log!\n"));
+ return STATE_CRITICAL;
+ }
+
+ /* get the date/time of the last item updated in the log */
+- while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
+- temp_ptr = strtok (input_buffer, "]");
+- temp_entry_time =
+- (temp_ptr == NULL) ? 0L : strtoul (temp_ptr + 1, NULL, 10);
+- if (temp_entry_time > latest_entry_time)
+- latest_entry_time = temp_entry_time;
+- }
+- fclose (fp);
++ latest_entry_time = sb.st_mtime;
+
+ if (verbose >= 2)
+ printf(_("command: %s\n"), PS_COMMAND);