fix 'last changed' display on BE LP64, from Simon Kuhnle, thanks!

This commit is contained in:
sthen 2011-03-04 11:21:45 +00:00
parent 40caa64017
commit b6c1951ace
3 changed files with 47 additions and 30 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.11 2011/03/03 12:33:06 sthen Exp $
# $OpenBSD: Makefile,v 1.12 2011/03/04 11:21:45 sthen Exp $
COMMENT = console interface for nagios
DISTNAME = cnagios-0.27
REVISION = 0
CATEGORIES = net
HOMEPAGE = http://noc.hep.wisc.edu/cnagios.txt

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-readv1_c,v 1.1 2009/10/01 14:09:55 sthen Exp $
--- readv1.c.orig Sat Apr 12 16:21:29 2008
+++ readv1.c Thu Oct 1 14:52:05 2009
@@ -32,11 +32,13 @@ extern int color;
$OpenBSD: patch-readv1_c,v 1.2 2011/03/04 11:21:45 sthen Exp $
--- readv1.c.orig Sat Oct 16 15:47:56 2010
+++ readv1.c Fri Mar 4 12:08:21 2011
@@ -32,10 +32,11 @@ extern int color;
/*------------------------------------------------------------------*/
@ -10,19 +10,25 @@ $OpenBSD: patch-readv1_c,v 1.1 2009/10/01 14:09:55 sthen Exp $
{
FILE *fp;
- int i, j, k;
- int line_num, stamp;
+ int i, k;
+ int line_num;
+ long stamp;
int line_num, stamp;
char buffer[MAX_CHARS_PER_LINE];
char *str_match;
char entry_type[MAX_STATUS_TYPE_LEN];
@@ -88,7 +90,7 @@ debug("status file is %s",STATUS_FILE);
continue;
}
- if ( sscanf(str_match,"[%d] %s",&stamp,entry_type) != 2 ) {
+ if ( sscanf(str_match,"[%ld] %s",&stamp,entry_type) != 2 ) {
endwin();
fprintf(stderr,"warning: ignoring %s line %d: could not parse entry\r\n",
STATUS_FILE,line_num);
@@ -124,7 +125,7 @@ debug("status file is %s",STATUS_FILE);
strncpy(host_list[host_list_size][LAST_STATE_CHANGE]," not applicable ",strlen(str_match)+1);
host_list[host_list_size][DURATION] = (char *)calc_duration(stamp);
} else {
- sscanf(str_match,"%ld",&stamp);
+ sscanf(str_match,"%d",&stamp);
host_list[host_list_size][LAST_STATE_CHANGE_INT] = (char *)stamp;
host_list[host_list_size][LAST_STATE_CHANGE] = malloc(17); /* "DOW Mon DD HH:MM\0" */
strncpy(host_list[host_list_size][LAST_STATE_CHANGE],ctime((time_t *)&stamp),16);
@@ -195,7 +196,7 @@ debug("status file is %s",STATUS_FILE);
service_list[service_list_size][DURATION] = malloc(1);
service_list[service_list_size][DURATION] = (char *)calc_duration(stamp);
} else {
- sscanf(str_match,"%ld",&stamp);
+ sscanf(str_match,"%d",&stamp);
service_list[service_list_size][LAST_STATE_CHANGE_INT] = (char *)stamp;
strncpy(service_list[service_list_size][LAST_STATE_CHANGE],ctime((time_t *)&stamp),16);
service_list[service_list_size][DURATION] = (char *)calc_duration(stamp);

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-readv23_c,v 1.2 2011/03/03 12:33:06 sthen Exp $
--- readv23.c.orig Sat Oct 16 14:47:56 2010
+++ readv23.c Fri Feb 11 10:53:15 2011
@@ -37,14 +37,18 @@ struct status_dot_dat_entry {
$OpenBSD: patch-readv23_c,v 1.3 2011/03/04 11:21:45 sthen Exp $
--- readv23.c.orig Sat Oct 16 15:47:56 2010
+++ readv23.c Fri Mar 4 12:14:16 2011
@@ -37,8 +37,11 @@ struct status_dot_dat_entry {
char *rhs;
};
@ -13,15 +13,25 @@ $OpenBSD: patch-readv23_c,v 1.2 2011/03/03 12:33:06 sthen Exp $
read_v23_status()
{
FILE *fp;
char buffer[MAX_CHARS_PER_LINE];
struct status_dot_dat_entry ent;
- int stamp, i;
+ int i;
+ long stamp;
@@ -157,7 +160,7 @@ debug(" plugin_output (post-munge) is %s",host_list[h
for (i=0; i < 11; i++) { fgets(buffer,sizeof(buffer),fp); }
}
parse_entry(&ent,buffer);
- sscanf(ent.rhs,"%ld",&stamp);
+ sscanf(ent.rhs,"%d",&stamp);
#ifdef _DEBUG_
debug("read_v23_status()...");
@@ -375,6 +379,7 @@ debug(" OUT plugin_output after munge is %s",service_
if ( (stamp == 0) && (host_list[host_list_size][PLUGIN_OUTPUT][0] == '\0') ) {
/* PENDING... is really UP with NULL plugin output on Jan 1 1970... */
@@ -277,7 +280,7 @@ debug(" OUT current_state is %s",service_list[service
for (i=0; i < 11; i++) { fgets(buffer,sizeof(buffer),fp); }
}
parse_entry(&ent,buffer);
- sscanf(ent.rhs,"%ld",&stamp);
+ sscanf(ent.rhs,"%d",&stamp);
service_list[service_list_size][LAST_STATE_CHANGE_INT] = (char *)stamp;
service_list[service_list_size][LAST_STATE_CHANGE] = malloc(17); /* "DOW Mon DD HH:MM\0" */
strncpy(service_list[service_list_size][LAST_STATE_CHANGE],ctime((time_t *)&stamp),16);
@@ -375,6 +378,7 @@ debug(" OUT plugin_output after munge is %s",service_
/*------------------------------------------------------------------------------*/