View | Details | Raw Unified | Return to bug 46339 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-5 / +24 lines)
Lines 6-12 Link Here
6
#
6
#
7
7
8
PORTNAME=	upclient
8
PORTNAME=	upclient
9
PORTVERSION=	5.0.b5
9
PORTVERSION=	5.0.b6
10
CATEGORIES=	misc
10
CATEGORIES=	misc
11
MASTER_SITES=	http://uptimes.wonko.com/files/
11
MASTER_SITES=	http://uptimes.wonko.com/files/
12
DISTNAME=	${PORTNAME}-${PORTVERSION:R}${PORTVERSION:E}
12
DISTNAME=	${PORTNAME}-${PORTVERSION:R}${PORTVERSION:E}
Lines 16-22 Link Here
16
# Global variables
16
# Global variables
17
#
17
#
18
18
19
LIB_DEPENDS=	intl.4:${PORTSDIR}/devel/gettext
20
19
USE_REINPLACE=	yes
21
USE_REINPLACE=	yes
22
USE_GMAKE=	yes
20
ALL_TARGET=	bsd
23
ALL_TARGET=	bsd
21
BUILD_WRKSRC=	${WRKSRC}/src
24
BUILD_WRKSRC=	${WRKSRC}/src
22
25
Lines 29-38 Link Here
29
#
32
#
30
33
31
DOC_FILES=	AUTHORS COPYING FAQ HISTORY INSTALL README TODO
34
DOC_FILES=	AUTHORS COPYING FAQ HISTORY INSTALL README TODO
35
DOC_FILES+=	doc/UptimesProtocol5
32
DOC_FILES+=	HISTORY-BETA
36
DOC_FILES+=	HISTORY-BETA
33
37
34
.include <bsd.port.pre.mk>
38
.include <bsd.port.pre.mk>
35
39
40
# Post-extract
41
#
42
43
post-extract: rename-doc
44
45
rename-doc:
46
	@${MV} ${WRKSRC}/doc/"Uptimes Protocol 5" ${WRKSRC}/doc/UptimesProtocol5
47
36
# Post-patch
48
# Post-patch
37
#
49
#
38
50
Lines 40-46 Link Here
40
52
41
patch-prefix:
53
patch-prefix:
42
	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
54
	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
43
		${WRKSRC}/scripts/upchk ${WRKSRC}/src/Makefile
55
		-e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
56
		${WRKSRC}/scripts/upchk ${WRKSRC}/scripts/clientchk \
57
		${WRKSRC}/src/Makefile
44
58
45
patch-pkgmessage:
59
patch-pkgmessage:
46
	@${SED} 's|%%PREFIX%%|${PREFIX}|g' ${MSG_FILE} > ${PKGMESSAGE}
60
	@${SED} 's|%%PREFIX%%|${PREFIX}|g' ${MSG_FILE} > ${PKGMESSAGE}
Lines 48-58 Link Here
48
# Install
62
# Install
49
#
63
#
50
64
51
do-install: install-program install-man install-sample install-script
65
do-install: install-program install-man install-sample install-script \
66
	install-locale
52
67
53
install-program:
68
install-program:
54
	@${INSTALL_PROGRAM} -g kmem -m 2555 ${WRKSRC}/src/products/upclient \
69
	@${INSTALL_PROGRAM} -g kmem -m 2555 ${WRKSRC}/src/products/upclient \
55
		${PREFIX}/sbin/upclient
70
		${PREFIX}/sbin
56
71
57
install-man:
72
install-man:
58
	@${INSTALL_MAN} ${WRKSRC}/src/products/upclient.8 \
73
	@${INSTALL_MAN} ${WRKSRC}/src/products/upclient.8 \
Lines 63-69 Link Here
63
		${PREFIX}/etc/upclient.conf.sample
78
		${PREFIX}/etc/upclient.conf.sample
64
79
65
install-script:
80
install-script:
66
	@${INSTALL_SCRIPT} ${WRKSRC}/scripts/upchk ${PREFIX}/sbin/upchk
81
	@${INSTALL_SCRIPT} ${WRKSRC}/scripts/upchk ${WRKSRC}/scripts/clientchk \
82
		${PREFIX}/sbin
83
84
install-locale:
85
	@cd ${WRKSRC}/src; ${GMAKE} install-locales
67
86
68
# Post-install
87
# Post-install
69
#
88
#
(-)distinfo (-1 / +1 lines)
Line 1 Link Here
1
MD5 (upclient-5.0b5.tar.gz) = fa6a74f146eacf47f4b0773a835a570e
1
MD5 (upclient-5.0b6.tar.gz) = 3d4c45addb947a51deabf2205188b82e
(-)pkg-plist (+9 lines)
Lines 3-10 Link Here
3
@unexec if cmp -s %D/etc/upclient.conf %D/etc/upclient.conf.sample; then rm -f %D/etc/upclient.conf; fi
3
@unexec if cmp -s %D/etc/upclient.conf %D/etc/upclient.conf.sample; then rm -f %D/etc/upclient.conf; fi
4
etc/upclient.conf.sample
4
etc/upclient.conf.sample
5
@exec [ -f %D/etc/upclient.conf ] || cp -p %D/etc/upclient.conf.sample %D/etc/upclient.conf
5
@exec [ -f %D/etc/upclient.conf ] || cp -p %D/etc/upclient.conf.sample %D/etc/upclient.conf
6
sbin/clientchk
6
sbin/upchk
7
sbin/upchk
7
sbin/upclient
8
sbin/upclient
9
share/locale/de/LC_MESSAGES/upclient.mo
10
share/locale/fr/LC_MESSAGES/upclient.mo
11
@unexec rmdir share/locale/de/LC_MESSAGES 2> /dev/null || :
12
@unexec rmdir share/locale/de 2> /dev/null || :
13
@unexec rmdir share/locale/fr/LC_MESSAGES 2> /dev/null || :
14
@unexec rmdir share/locale/fr 2> /dev/null || :
15
@unexec rmdir share/locale 2> /dev/null || :
8
%%PORTDOCS%%share/doc/upclient/AUTHORS
16
%%PORTDOCS%%share/doc/upclient/AUTHORS
9
%%PORTDOCS%%share/doc/upclient/COPYING
17
%%PORTDOCS%%share/doc/upclient/COPYING
10
%%PORTDOCS%%share/doc/upclient/FAQ
18
%%PORTDOCS%%share/doc/upclient/FAQ
Lines 13-16 Link Here
13
%%PORTDOCS%%share/doc/upclient/INSTALL
21
%%PORTDOCS%%share/doc/upclient/INSTALL
14
%%PORTDOCS%%share/doc/upclient/README
22
%%PORTDOCS%%share/doc/upclient/README
15
%%PORTDOCS%%share/doc/upclient/TODO
23
%%PORTDOCS%%share/doc/upclient/TODO
24
%%PORTDOCS%%share/doc/upclient/UptimesProtocol5
16
%%PORTDOCS%%@dirrm share/doc/upclient
25
%%PORTDOCS%%@dirrm share/doc/upclient
(-)files/patch-aa (-2 / +24 lines)
Lines 1-5 Link Here
1
--- src/Makefile.orig	Thu Oct 10 04:36:35 2002
1
--- src/Makefile.orig	Sat Nov 30 03:29:55 2002
2
+++ src/Makefile	Sat Oct 19 23:21:49 2002
2
+++ src/Makefile	Wed Dec 18 01:29:34 2002
3
@@ -34,7 +34,7 @@
4
 #
5
   PROGRAMNAME = upclient
6
 # UPCLIENT_VERSION = "5.0b6"
7
-  UPCLIENT_VERSION = `grep '\#define UPCLIENT_VERSION ' version.h | sed -e 's@\#define UPCLIENT_VERSION @@g' | tr -d '"'`
8
+  UPCLIENT_VERSION = `sed -n 's/"//g;/\#define UPCLIENT_VERSION /s///p' version.h`
9
 ################################################################################
10
 
11
 binname = upclient
3
@@ -44,7 +44,7 @@
12
@@ -44,7 +44,7 @@
4
 
13
 
5
 
14
 
Lines 18-20 Link Here
18
 
27
 
19
 # Further Reading
28
 # Further Reading
20
 # Filesystem Hierarchy Standard 2.2 May 24, 2001
29
 # Filesystem Hierarchy Standard 2.2 May 24, 2001
30
@@ -82,9 +82,9 @@
31
 
32
 ## [x86] FreeBSD (4.7-RC)
33
 ## assumes gettext installed in /usr/local
34
-#localedir = ${datadir}/locale
35
-#LOCALEFLAGS = -DLOCALEPATH=\"$(localedir)\" -I/usr/local/include
36
-#LOCALELIBS = -L/usr/local/lib -lintl
37
+localedir = ${datadir}/locale
38
+LOCALEFLAGS = -DLOCALEPATH=\"$(localedir)\" -I%%LOCALBASE%%/include
39
+LOCALELIBS = -L%%LOCALBASE%%/lib -lintl
40
 
41
 ## [Sparc - R220] Sun Solaris (5.8)
42
 ## not sure whether this locale dir is correct
(-)files/patch-ab (-3 / +12 lines)
Lines 1-5 Link Here
1
--- src/conf/upclient.conf.orig	Thu Oct 10 04:36:24 2002
1
--- src/conf/upclient.conf.orig	Sat Nov 30 03:27:16 2002
2
+++ src/conf/upclient.conf	Sat Oct 19 19:41:36 2002
2
+++ src/conf/upclient.conf	Wed Dec 18 02:31:09 2002
3
@@ -9,7 +9,7 @@
3
@@ -9,7 +9,7 @@
4
 
4
 
5
 AuthKey = <your_authkey>	# Your Authorization key
5
 AuthKey = <your_authkey>	# Your Authorization key
Lines 8-11 Link Here
8
+Interval     = 550			# Transmit interval
8
+Interval     = 550			# Transmit interval
9
 UptimeServer = @UPTIMES_SERVER@	# Uptimes Project's data server
9
 UptimeServer = @UPTIMES_SERVER@	# Uptimes Project's data server
10
 
10
 
11
 SendIdleTime = 1	# Send your idle time
11
 SendIdle      = 1	# Send CPU idle percent
12
@@ -20,7 +20,7 @@
13
 SendCPUDetail = 1	# (BSD, Linux, Solaris & Irix only)
14
 			#   0 = send generic CPU architecture
15
 			#   1 = send specific CPU model
16
-SendLoadAvg  = 0	# Send 15-minute Load-average (unix only) (not implemented)
17
+SendLoadAvg   = 1	# Send 15-minute Load-average (unix only)
18
 
19
 # Fill in if you're behind a proxy server.
20
 #ProxyServer	= <your.proxy.server.com>
(-)files/patch-options.c (-10 / +10 lines)
Lines 1-11 Link Here
1
--- src/options.c.orig	Wed Oct  2 06:50:49 2002
1
--- src/options.c.orig	Sat Nov 30 03:27:15 2002
2
+++ src/options.c	Sat Oct 19 22:54:06 2002
2
+++ src/options.c	Wed Dec 18 01:43:00 2002
3
@@ -55,7 +55,7 @@
3
@@ -60,7 +60,7 @@
4
  * Minimum value is enforced. A warning is logged if greater than upper limit.
4
  */
5
  */
5
 char cfg_authkey[AUTHKEY_REQUIRED_LEN+1]	= "";
6
 #define MINIMUM_INTERVAL  30    /* enforced */
6
 char cfg_upserver[UPSERVER_MAXLEN+1]		= "uptimes.wonko.com";
7
-#define DEFAULT_INTERVAL 300
7
-int  cfg_interval				= 300;
8
+#define DEFAULT_INTERVAL 550
8
+int  cfg_interval				= 550;
9
 #define UPPER_INTERVAL   600    /* warning if exceeded */
9
 char cfg_pidfile[PIDFILE_MAXLEN+1]		= PIDFILE;
10
 
10
 char cfg_proxyserver[PROXYSERVER_MAXLEN+1]	= "";
11
 /* Macros */
11
 int  cfg_udpport				= 49153;
(-)files/patch-stats-bsd.c (-285 / +134 lines)
Lines 1-294 Link Here
1
--- src/stats-bsd.c.orig	Mon Sep 30 02:58:36 2002
1
--- src/stats-bsd.c.orig	Sat Nov 30 03:27:16 2002
2
+++ src/stats-bsd.c	Sat Oct 19 22:50:30 2002
2
+++ src/stats-bsd.c	Wed Dec 18 03:28:16 2002
3
@@ -41,139 +41,171 @@
3
@@ -64,6 +64,8 @@
4
 #include "upclient.h"
5
 #include "options.h"
6
 #include "stats.h"
7
-#include "uplog.h" /* wrapper for <syslog.h> */
8
 
9
 /* System includes */
10
-#include <kvm.h>
11
-#include <stdio.h>
12
+#include <err.h>
13
 #include <errno.h>
14
 #include <fcntl.h>
15
+#include <kvm.h>
16
 #include <limits.h>
17
-#include <sys/time.h>
18
-#include <sys/param.h>
19
+#include <stdio.h>
20
+#include <syslog.h>
21
 #include <sys/dkstat.h>
22
+#include <sys/param.h>
23
 #include <sys/sysctl.h>
24
+#include <sys/time.h>
25
 #include <sys/utsname.h>
26
 
4
 
5
 #include "locale.h"     /* gettext */
6
 
7
+void logcalc(char *, char *);
8
+
27
 /**
9
 /**
28
  * @desc	Get statistics
10
  * @desc    Verbose level 2 logging of calulations
29
  */
11
  */
30
-void getstats(unsigned long *puptime, double *pload, int *pidle, char *os, char *oslevel, char *cpu) {
12
@@ -81,12 +83,13 @@
31
-    struct utsname uts;
13
 void
32
-    struct timeval boottime;
14
 initCPU(char *cpu)
33
+void
15
 {
34
+getstats(unsigned long *puptime, double *pload, int *pidle,
16
-    char   buf[CPU_SIZE] = "";
35
+	 char *os, char *oslevel, char *cpu)
17
     static int initialized = 0;
36
+{
37
+  size_t size;
38
+  int mib[2];
39
+
40
+  {					/* ========== uptime ========== */
41
+    static struct timeval boottime;
42
+    static int initialized = 0;
43
     time_t now;
44
-    size_t size;
18
-    size_t size;
45
-    double loadavgs[2];
19
-    int    mib[2];
46
-    int mib[2];
20
 
47
-
21
     if (!initialized) {
48
-    /* Get uptime */
22
+	char   buf[CPU_SIZE] = "";
49
-    time(&now);
23
+	size_t size;
50
-    mib[0] = CTL_KERN;
24
+	int    mib[2];
51
-    mib[1] = KERN_BOOTTIME;
52
-    size = sizeof(boottime);
53
-    if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && (boottime.tv_sec != 0)) {
54
-        *puptime = now - boottime.tv_sec;
55
-        *puptime /= 60;
56
-    }
57
-
58
-    if (cfg_sendload) {
59
-        /* Get load average */
60
-        getloadavg(loadavgs, 3);
61
-        /* Use the 3rd element (15 minute load average) */
62
-        *pload = loadavgs[2];
63
-    }
64
-
65
-    if (cfg_sendos) {
66
-        /* Get os info */
67
-        uname(&uts);
68
-    }
69
-
70
-    if (cfg_sendcpu) {
71
-        /* Get CPU info */
72
-        mib[0] = CTL_HW;
73
-        if (cfg_sendcpulevel == 1) {
74
-            mib[1] = HW_MACHINE; /* Send architecture */
75
-        }
76
-        else {
77
-            mib[1] = HW_MODEL;   /* Send architecture's specific model */
78
-        }
79
-        size = CPU_SIZE;
80
-        sysctl(mib, 2, cpu, &size, NULL, 0);
81
-    }
82
-
83
-    if (cfg_sendos) {
84
-        strncpy(os, uts.sysname, OS_SIZE - 1);
85
-        if (cfg_sendoslevel) {
86
-            strncpy(oslevel, uts.release, OSLEVEL_SIZE - 1);
87
-        }
88
-    }
89
-
90
-    if (cfg_sendidle) {
91
-        static kvm_t *kp;
92
-        static int initialized = 0;
93
-        static struct nlist namelist [] = {
94
+
95
+    if (!initialized) {
96
+      initialized = 1;
97
+
98
+      mib[0] = CTL_KERN;
99
+      mib[1] = KERN_BOOTTIME;
100
+      size = sizeof(boottime);
101
+
102
+      if (sysctl(mib, 2, &boottime, &size, NULL, 0) == -1) {
103
+	uplog(LOG_ERR, "sysctl: kern.boottime");
104
+	err(1, "sysctl: kern.boottime");
105
+      }
106
+    }
107
+
108
+    if (boottime.tv_sec) {
109
+      time_t now;
110
+
111
+      time (&now);
112
+
113
+      *puptime = now - boottime.tv_sec;
114
+      *puptime /= 60;
115
+    }
116
+  }
117
+
118
+  if (cfg_sendload) {			/* ========== loadavg ========== */
119
+    double loadavgs[3] = { 0. };
120
+
121
+    getloadavg(loadavgs, 3);
122
+    /* Use the 3rd element (15 minute load average) */
123
+    *pload = loadavgs[2];
124
+  }
125
+
126
+  if (cfg_sendcpu) {			/* ========== cpu ========== */
127
+    static char buf[CPU_SIZE] = "";
128
+    static int initialized = 0;
129
+
130
+    if (!initialized) {
131
+      initialized = 1;
132
+
133
+      mib[0] = CTL_HW;
134
+      if (cfg_sendcpulevel == 1)
135
+	mib[1] = HW_MACHINE; /* Send architecture */
136
+      else
137
+	mib[1] = HW_MODEL;   /* Send architecture's specific model */
138
+      size = CPU_SIZE;
139
+
140
+      if (sysctl(mib, 2, buf, &size, NULL, 0) == -1) {
141
+	uplog(LOG_WARNING, "sysctl: hw.model");
142
+	/* warn("sysctl: hw.model"); */
143
+      }
144
+    }
145
+
146
+    strlcpy(cpu, buf, CPU_SIZE);
147
+  }
148
+
149
+  if (cfg_sendos) {
150
+    static struct utsname uts;
151
+    static int initialized = 0;
152
+
153
+    if (!initialized) {
154
+      initialized = 1;
155
+	    
156
+      uname(&uts);
157
+    }
158
+
159
+    strlcpy(os, uts.sysname, OS_SIZE);
160
+
161
+    if (cfg_sendoslevel)
162
+      strlcpy(oslevel, uts.release, OSLEVEL_SIZE);
163
+  }
164
+
25
+
165
+  if (cfg_sendidle) {			/* ========== idle_time ========== */
26
         initialized = 1;
166
+    static kvm_t *kp;
27
 
167
+    static int initialized = 0;
28
         mib[0] = CTL_HW;
168
+    static struct nlist namelist[] = {
29
@@ -98,7 +101,6 @@
169
 #define X_CP_TIME 0
30
 
170
-        { "_cp_time" },
31
         if (sysctl(mib, 2, buf, &size, NULL, 0) == -1) {
171
-        { NULL },
32
             uplog(LOG_WARNING, "sysctl: hw.model");
172
-        };
33
-           /* warn("sysctl: hw.model"); */
173
-
34
         }
174
-        if (!initialized) {
35
         strlcpy(cpu, buf, CPU_SIZE);
175
-            char errbuf[_POSIX2_LINE_MAX];
36
         logcalc(_("CPU"), cpu);
176
-            initialized = 1;
37
@@ -154,7 +156,6 @@
177
-
38
             err(1, "sysctl: kern.boottime");
178
-            setgid(getgid());
39
         }
179
-
40
         boottimesecs = boottime.tv_sec;
180
-            kp = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
41
-       /* logcalc(_("boot time"), boottimesecs); */
181
-
42
 #if defined DEBUG
182
-            if (!kp) {
43
         uplog(LOG_DEBUG, "initBoottime() initialized %d", boottimesecs);
183
-                uplog(LOG_WARNING, "kvm_openfiles: %s. (Did you forget to start upclient as root?)", errbuf);
44
 #endif /* DEBUG */
184
-//            warn("kvm_openfiles: %s", errbuf);
45
@@ -173,19 +174,18 @@
185
-            }
46
               _("%s %s not implemented for this operating system %s"),
186
-            else if (kvm_nlist(kp,namelist) == -1) {
47
               _("WARNING:"), _("Load-average"), strerror(errno));
187
-                uplog(LOG_WARNING, "kvm_nlist: %s", kvm_geterr(kp));
48
         cfg_SendUsage = 0;
188
-//            warn("kvm_nlist: %s", kvm_geterr(kp));
49
-        return;
189
-            }
50
     }
190
-        }
51
     else if (loads < 0) {
191
-
52
         uplog(LOG_WARNING, _("%s Could not get load-average %s"), _("WARNING:"),
192
-        if (kp) {
53
               strerror(errno));
193
-            long ctime[CPUSTATES];
54
-        return;
194
-            static long stime[CPUSTATES];
55
     }
195
-            static int first_time = 1;
196
-
197
-            if (first_time) {
198
-                first_time = 0;
199
-
200
-                if (kvm_read(kp, namelist[X_CP_TIME].n_value, stime, sizeof(stime)) == -1) {
201
-                    uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
202
-//                    warn("kvm_read: %s", kvm_geterr(kp));
203
-                }
204
-                else
205
-                    sleep(1); /* to avoid the initial 0 idle value */
206
-            }
207
-
208
-            if (kvm_read(kp, namelist[X_CP_TIME].n_value, ctime, sizeof(ctime)) == -1) {
209
-                uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
210
-//                warn("kvm_read: %s", kvm_geterr(kp));
211
-            }
212
-            else {
213
-                int state;
214
-                double time = 0.;
215
-
216
-                for(state = 0; state < CPUSTATES; state++)
217
-                    time += ctime[state] - stime[state];
218
-
219
-                if (time == 0.)
220
-                    time = 1.;
221
-
222
-                *pidle = (ctime[CP_IDLE] - stime[CP_IDLE]) * 100. / time;
223
-
56
-
224
-                for(state = 0; state < CPUSTATES; state++)
57
-   /* Use the 3rd element (15 minute Load-average) */
225
-                    stime[state] = ctime[state];
58
-    *loadavg = loadavgs[2];
226
-            }
59
+    else {
227
-        }
60
+	/* Use the 3rd element (15 minute Load-average) */
228
-        else {
61
+	*loadavg = loadavgs[2];
229
-            cfg_sendidle = 0;
62
 #if defined DEBUG
230
-        }
63
-    uplog(LOG_DEBUG, "getLoadavg() %.2f", *loadavg);
231
+      { "_cp_time" },
64
+	uplog(LOG_DEBUG, "getLoadavg() %.2f", *loadavg);
232
+      { NULL },
65
 #endif /* DEBUG */
233
+    };
234
+
235
+    if (!initialized) {
236
+      char errbuf[_POSIX2_LINE_MAX];
237
+      initialized = 1;
238
+
239
+      setgid(getgid());
240
+
241
+      kp = kvm_openfiles(NULL,NULL,NULL,O_RDONLY,errbuf);
242
+
243
+      if (!kp) {
244
+	uplog(LOG_WARNING, "kvm_openfiles: %s",errbuf);
245
+	/* warn("kvm_openfiles: %s",errbuf); */
246
+      } else if (kvm_nlist(kp,namelist) == -1) {
247
+	uplog(LOG_WARNING, "kvm_nlist: %s",kvm_geterr(kp));
248
+	/* warn("kvm_nlist: %s",kvm_geterr(kp)); */
249
+      }
250
+    }
66
+    }
251
+
67
 }
252
+    if (kp) {
68
 
253
+      long ctime[CPUSTATES];
69
 #if !defined __MACH__   /* Mach kernel stuff is in stats-mach.c */
254
+      static long stime[CPUSTATES];
70
@@ -245,7 +245,7 @@
255
+      static int first_time = 1;
71
 
256
+
72
             for (state = 0; state < CPUSTATES; state++) {
257
+      if (first_time) {
73
                 time += ctime[state] - stime[state];
258
+	first_time = 0;
74
-                if (!(state == CPU_STATE_IDLE)) {
259
+
75
+                if (!(state == CP_IDLE)) {
260
+	if (kvm_read(kp, namelist[X_CP_TIME].n_value,
76
                     nonidlecpu += (float)(ctime[state] - stime[state]);
261
+		     stime, sizeof(stime)) == -1) {
77
                 }
262
+	  uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
78
             }
263
+	  /* warn("kvm_read: %s", kvm_geterr(kp)); */
79
@@ -258,6 +258,10 @@
264
+	} else
80
 
265
+	  sleep(1); /* to avoid the initial 0 idle value */
81
             for (state = 0; state < CPUSTATES; state++)
266
+      }
82
                 stime[state] = ctime[state];
267
+
83
+#if defined DEBUG
268
+      if (kvm_read(kp, namelist[X_CP_TIME].n_value,
84
+	    uplog(LOG_DEBUG, "getLoadIdle() load=%.1f idle=%.1f", *UsagePercent,
269
+		   ctime, sizeof(ctime)) == -1) {
85
+		  *IdlePercent);
270
+	 uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
86
+#endif /* DEBUG */
271
+	 /* warn("kvm_read: %s", kvm_geterr(kp)); */
87
         }
272
+      } else {
273
+	int state;
274
+	double time = 0.;
275
+
276
+	for (state = 0; state < CPUSTATES; state++)
277
+	  time += ctime[state] - stime[state];
278
+
279
+	if (time == 0.)
280
+	  time = 1.;
281
+
282
+	*pidle = (ctime[CP_IDLE] - stime[CP_IDLE]) * 100. / time;
283
+
284
+	for (state = 0; state < CPUSTATES; state++)
285
+	  stime[state] = ctime[state];
286
+      }
287
+    } else {
288
+      cfg_sendidle = 0;
289
     }
88
     }
290
+  }
89
     else {
90
@@ -268,17 +272,13 @@
91
         cfg_SendUsage = 0;
92
         cfg_SendIdle = 0;
93
     }
94
-#if defined DEBUG
95
-    uplog(LOG_DEBUG, "getLoadIdle() load=%.1f idle=%.1f", *UsagePercent,
96
-          *IdlePercent);
97
-#endif /* DEBUG */
291
 }
98
 }
292
-#endif /* PLATFORM_BSD */
99
 #endif /* !__MACH__ */
293
+
100
 
294
+#endif /* PLATFORM_BSD */                                                       
101
 void
102
 getUptime(unsigned long *uptimeminutes)
103
 {
104
-    static time_t boottimesecs;
105
+    time_t boottimesecs;
106
 
107
     boottimesecs = initBoottime();
108
 
109
@@ -293,7 +293,7 @@
110
 #endif /* DEBUG */
111
     }
112
     else {
113
-        uplog(LOG_INFO, _("%s: %s failed"), _("ERROR:"),
114
+        uplog(LOG_ERR, _("%s %s failed"), _("ERROR:"),
115
               "getUptime() boottime.tv_sec");
116
     }
117
 }
118
@@ -306,19 +306,18 @@
119
          double *IdlePercent, char *osname, char *osversion, char *cpu,
120
          double *loadavg)
121
 {
122
-    getUptime(&*uptimeminutes);
123
+    getUptime(uptimeminutes);
124
 
125
     if (cfg_SendUsage || cfg_SendIdle)
126
-        getLoadIdle(&*UsagePercent, &*IdlePercent);
127
+        getLoadIdle(UsagePercent, IdlePercent);
128
 
129
     if (cfg_sendosname || cfg_sendosversion)
130
-        initOS(&*osname, &*osversion);
131
+        initOS(osname, osversion);
132
 
133
     if (cfg_sendcpu)
134
-        initCPU(&*cpu);
135
-
136
-   /* if (cfg_sendloadavg) */
137
-    getLoadavg(&*loadavg);
138
+        initCPU(cpu);
139
 
140
+    if (cfg_sendloadavg)
141
+	getLoadavg(loadavg);
142
 }
143
 #endif /* PLATFORM_BSD */
(-)files/patch-upchk (-1 / +1 lines)
Lines 1-5 Link Here
1
--- scripts/upchk.orig	Mon Sep 23 19:28:31 2002
1
--- scripts/upchk.orig	Mon Sep 23 19:28:31 2002
2
+++ scripts/upchk	Sat Oct 19 22:52:27 2002
2
+++ scripts/upchk	Wed Dec 18 02:40:31 2002
3
@@ -24,7 +24,7 @@
3
@@ -24,7 +24,7 @@
4
 #
4
 #
5
 
5
 
(-)files/upclient.sh (-1 / +11 lines)
Lines 22-27 Link Here
22
config_file=${program_file}.conf
22
config_file=${program_file}.conf
23
config_path=${config_dir}/${config_file}
23
config_path=${config_dir}/${config_file}
24
24
25
sample_path=${config_path}.sample
26
25
pid_dir=/var/run
27
pid_dir=/var/run
26
pid_file=${program_file}.pid
28
pid_file=${program_file}.pid
27
pid_path=${pid_dir}/${pid_file}
29
pid_path=${pid_dir}/${pid_file}
Lines 54-60 Link Here
54
			"${config_path}."
56
			"${config_path}."
55
                exit 72
57
                exit 72
56
	fi
58
	fi
57
        ${program_path} &&
59
	kw="IdleTime|OS|(OS|CPU)Level"
60
	if egrep -qs "^[$ws]*Send($kw)[$ws]*=" ${config_path}
61
	then
62
		logger -sp ${syslog_facility} -t ${program_file} \
63
			"unable to start: ${config_path} needs to be updated" \
64
			"from ${sample_path}."
65
                exit 72
66
	fi
67
        ${program_path} 2> /dev/null &&
58
        echo -n " ${program_file}"
68
        echo -n " ${program_file}"
59
        ;;
69
        ;;
60
stop)
70
stop)

Return to bug 46339