mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 17:59:20 -04:00
* Upgrade to 5.0.b5.
* Changed MASTER_SITES. * Respect PREFIX correctly. PR: 44283 Submitted by: maintainer
This commit is contained in:
parent
e9f358b982
commit
6aee96b6e7
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=68386
9 changed files with 311 additions and 119 deletions
|
@ -6,9 +6,10 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
PORTNAME= upclient
|
PORTNAME= upclient
|
||||||
PORTVERSION= 4.2.1.23
|
PORTVERSION= 5.0.b5
|
||||||
CATEGORIES= misc
|
CATEGORIES= misc
|
||||||
MASTER_SITES= http://uptimes.atomicvoid.net/files/
|
MASTER_SITES= http://uptimes.wonko.com/files/
|
||||||
|
DISTNAME= ${PORTNAME}-${PORTVERSION:R}${PORTVERSION:E}
|
||||||
|
|
||||||
MAINTAINER= cyrille.lefevre@laposte.net
|
MAINTAINER= cyrille.lefevre@laposte.net
|
||||||
|
|
||||||
|
@ -22,20 +23,24 @@ BUILD_WRKSRC= ${WRKSRC}/src
|
||||||
MSG_FILE= ${PKGDIR}/pkg-message
|
MSG_FILE= ${PKGDIR}/pkg-message
|
||||||
PKGMESSAGE= ${WRKDIR}/pkg-message
|
PKGMESSAGE= ${WRKDIR}/pkg-message
|
||||||
|
|
||||||
|
MAN8= upclient.8
|
||||||
|
|
||||||
# Local variables
|
# Local variables
|
||||||
#
|
#
|
||||||
|
|
||||||
DOC_FILES= AUTHORS COPYING FAQ HISTORY INSTALL README TODO
|
DOC_FILES= AUTHORS COPYING FAQ HISTORY INSTALL README TODO
|
||||||
|
DOC_FILES+= HISTORY-BETA
|
||||||
|
|
||||||
.include <bsd.port.pre.mk>
|
.include <bsd.port.pre.mk>
|
||||||
|
|
||||||
# Post-patch
|
# Post-patch
|
||||||
#
|
#
|
||||||
|
|
||||||
post-patch: patch-script patch-message
|
post-patch: patch-prefix patch-message
|
||||||
|
|
||||||
patch-script:
|
patch-prefix:
|
||||||
@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/scripts/upchk
|
@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
|
||||||
|
${WRKSRC}/scripts/upchk ${WRKSRC}/src/Makefile
|
||||||
|
|
||||||
patch-message:
|
patch-message:
|
||||||
@${SED} 's|%%PREFIX%%|${PREFIX}|g' ${MSG_FILE} > ${PKGMESSAGE}
|
@${SED} 's|%%PREFIX%%|${PREFIX}|g' ${MSG_FILE} > ${PKGMESSAGE}
|
||||||
|
@ -43,14 +48,18 @@ patch-message:
|
||||||
# Install
|
# Install
|
||||||
#
|
#
|
||||||
|
|
||||||
do-install: install-program install-sample install-script
|
do-install: install-program install-man install-sample install-script
|
||||||
|
|
||||||
install-program:
|
install-program:
|
||||||
@${INSTALL_PROGRAM} -g kmem -m 2555 ${WRKSRC}/src/upclient \
|
@${INSTALL_PROGRAM} -g kmem -m 2555 ${WRKSRC}/src/products/upclient \
|
||||||
${PREFIX}/sbin/upclient
|
${PREFIX}/sbin/upclient
|
||||||
|
|
||||||
|
install-man:
|
||||||
|
@${INSTALL_MAN} ${WRKSRC}/src/products/upclient.8 \
|
||||||
|
${MAN8PREFIX}/man/man8
|
||||||
|
|
||||||
install-sample:
|
install-sample:
|
||||||
@${INSTALL_DATA} -m 600 ${WRKSRC}/conf/upclient.conf \
|
@${INSTALL_DATA} -m 600 ${WRKSRC}/src/products/upclient.conf \
|
||||||
${PREFIX}/etc/upclient.conf.sample
|
${PREFIX}/etc/upclient.conf.sample
|
||||||
|
|
||||||
install-script:
|
install-script:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
MD5 (upclient-4.2.1.23.tar.gz) = 4c23b4623ecd490b5d3e31ac67f20feb
|
MD5 (upclient-5.0b5.tar.gz) = fa6a74f146eacf47f4b0773a835a570e
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
--- src/Makefile.orig Sun Jun 17 00:48:35 2001
|
--- src/Makefile.orig Thu Oct 10 04:36:35 2002
|
||||||
+++ src/Makefile Sun Nov 18 15:58:37 2001
|
+++ src/Makefile Sat Oct 19 23:21:49 2002
|
||||||
@@ -9,7 +9,7 @@
|
@@ -44,7 +44,7 @@
|
||||||
####
|
|
||||||
# Location of config file (for example /etc/upclient.conf)
|
|
||||||
#
|
|
||||||
-CONFIGFILE = upclient.conf
|
|
||||||
+CONFIGFILE = $(PREFIX)/etc/upclient.conf
|
|
||||||
|
|
||||||
|
|
||||||
####
|
# System directories
|
||||||
@@ -113,7 +113,7 @@
|
-prefix = /usr/local
|
||||||
CFLAGS='-DPLATFORM_WINNT -DCONFIGFILE=\"$(CONFIGFILE)\"' \
|
+prefix = %%PREFIX%%
|
||||||
upclient
|
#prefix = /sw
|
||||||
|
#prefix = /opt/${PROGRAMNAME}
|
||||||
|
|
||||||
-upclient: upclient.h
|
@@ -55,7 +55,7 @@
|
||||||
+upclient: upclient.h $(OBJECTS)
|
sbindir = ${exec_prefix}/sbin
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) upclient.c -o $(BINNAME)
|
datadir = ${prefix}/share
|
||||||
|
sysconfdir = ${prefix}/etc
|
||||||
|
-localstatedir = ${prefix}/var
|
||||||
|
+localstatedir = /var
|
||||||
|
|
||||||
clean:
|
# Further Reading
|
||||||
|
# Filesystem Hierarchy Standard 2.2 May 24, 2001
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
--- conf/upclient.conf.orig Sat Jun 16 18:33:54 2001
|
--- src/conf/upclient.conf.orig Thu Oct 10 04:36:24 2002
|
||||||
+++ conf/upclient.conf Sun Nov 18 17:33:13 2001
|
+++ src/conf/upclient.conf Sat Oct 19 19:41:36 2002
|
||||||
@@ -8,8 +8,8 @@
|
@@ -9,7 +9,7 @@
|
||||||
|
|
||||||
AuthKey = <your_authkey> # Your Authorization key
|
AuthKey = <your_authkey> # Your Authorization key
|
||||||
|
|
||||||
-Interval = 120 # Transmit interval
|
-Interval = 300 # Transmit interval
|
||||||
-UptimeServer = data.uptimes.net # Uptimes Project's data server
|
+Interval = 550 # Transmit interval
|
||||||
+Interval = 550 # Transmit interval
|
UptimeServer = @UPTIMES_SERVER@ # Uptimes Project's data server
|
||||||
+UptimeServer = uptimes.wonko.com # Uptimes Project's data server
|
|
||||||
|
|
||||||
SendIdleTime = 1 # Send your idle time
|
SendIdleTime = 1 # Send your idle time
|
||||||
SendLoadAvg = 1 # Send load average
|
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
--- src/options.c.orig Sat Jun 16 21:15:04 2001
|
--- src/options.c.orig Wed Oct 2 06:50:49 2002
|
||||||
+++ src/options.c Sun Nov 18 17:40:06 2001
|
+++ src/options.c Sat Oct 19 22:54:06 2002
|
||||||
@@ -16,9 +16,9 @@
|
@@ -55,7 +55,7 @@
|
||||||
* These are the configuration options available.
|
|
||||||
*/
|
*/
|
||||||
char cfg_authkey[AUTHKEY_REQUIRED_LEN+1] = "";
|
char cfg_authkey[AUTHKEY_REQUIRED_LEN+1] = "";
|
||||||
-char cfg_upserver[UPSERVER_MAXLEN+1] = "data.uptimes.net";
|
char cfg_upserver[UPSERVER_MAXLEN+1] = "uptimes.wonko.com";
|
||||||
-int cfg_interval = 120;
|
-int cfg_interval = 300;
|
||||||
-char cfg_pidfile[PIDFILE_MAXLEN+1] = ".upclient.pid";
|
|
||||||
+char cfg_upserver[UPSERVER_MAXLEN+1] = "uptimes.wonko.com";
|
|
||||||
+int cfg_interval = 550;
|
+int cfg_interval = 550;
|
||||||
+char cfg_pidfile[PIDFILE_MAXLEN+1] = "/var/run/upclient.pid";
|
char cfg_pidfile[PIDFILE_MAXLEN+1] = PIDFILE;
|
||||||
char cfg_proxyserver[PROXYSERVER_MAXLEN+1] = "";
|
char cfg_proxyserver[PROXYSERVER_MAXLEN+1] = "";
|
||||||
int cfg_proxyport = 8080;
|
int cfg_udpport = 49153;
|
||||||
char cfg_proxyuser[PROXYUSER_MAXLEN+1] = "";
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- src/options.h.orig Sat Jun 16 17:45:50 2001
|
--- src/options.h.orig Mon Sep 30 02:58:36 2002
|
||||||
+++ src/options.h Sun Nov 18 16:08:56 2001
|
+++ src/options.h Sat Oct 19 22:55:19 2002
|
||||||
@@ -34,11 +34,7 @@
|
@@ -60,11 +60,7 @@
|
||||||
extern char cfg_proxyuser[PROXYUSER_MAXLEN+1];
|
extern char cfg_proxyuser[PROXYUSER_MAXLEN+1];
|
||||||
extern char cfg_proxypass[PROXYPASS_MAXLEN+1];
|
extern char cfg_proxypass[PROXYPASS_MAXLEN+1];
|
||||||
extern int cfg_sendidle;
|
extern int cfg_sendidle;
|
||||||
|
|
|
@ -1,33 +1,108 @@
|
||||||
--- src/stats-bsd.c.orig Sat Jun 16 21:12:53 2001
|
--- src/stats-bsd.c.orig Mon Sep 30 02:58:36 2002
|
||||||
+++ src/stats-bsd.c Sun Nov 18 17:33:52 2001
|
+++ src/stats-bsd.c Sat Oct 19 22:50:30 2002
|
||||||
@@ -26,37 +26,50 @@
|
@@ -41,139 +41,171 @@
|
||||||
|
#include "upclient.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "stats.h"
|
||||||
|
-#include "uplog.h" /* wrapper for <syslog.h> */
|
||||||
|
|
||||||
|
/* System includes */
|
||||||
|
-#include <kvm.h>
|
||||||
|
-#include <stdio.h>
|
||||||
|
+#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
+#include <kvm.h>
|
||||||
|
#include <limits.h>
|
||||||
|
-#include <sys/time.h>
|
||||||
|
-#include <sys/param.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <syslog.h>
|
||||||
|
#include <sys/dkstat.h>
|
||||||
|
+#include <sys/param.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
+#include <sys/time.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
|
/**
|
||||||
* @desc Get statistics
|
* @desc Get statistics
|
||||||
*/
|
*/
|
||||||
void getstats(unsigned long *puptime, double *pload, int *pidle, char *os, char *oslevel, char *cpu) {
|
-void getstats(unsigned long *puptime, double *pload, int *pidle, char *os, char *oslevel, char *cpu) {
|
||||||
- struct utsname uts;
|
- struct utsname uts;
|
||||||
- struct timeval boottime;
|
- struct timeval boottime;
|
||||||
- time_t now;
|
+void
|
||||||
size_t size;
|
+getstats(unsigned long *puptime, double *pload, int *pidle,
|
||||||
- double loadavgs[2];
|
+ char *os, char *oslevel, char *cpu)
|
||||||
int mib[2];
|
+{
|
||||||
|
+ size_t size;
|
||||||
- /* Get uptime */
|
+ int mib[2];
|
||||||
- time(&now);
|
+
|
||||||
+ { /* ========== uptime ========== */
|
+ { /* ========== uptime ========== */
|
||||||
+ static struct timeval boottime;
|
+ static struct timeval boottime;
|
||||||
+ static int initialized = 0;
|
+ static int initialized = 0;
|
||||||
+ time_t now;
|
time_t now;
|
||||||
|
- size_t size;
|
||||||
|
- double loadavgs[2];
|
||||||
|
- int mib[2];
|
||||||
|
-
|
||||||
|
- /* Get uptime */
|
||||||
|
- time(&now);
|
||||||
|
- mib[0] = CTL_KERN;
|
||||||
|
- mib[1] = KERN_BOOTTIME;
|
||||||
|
- size = sizeof(boottime);
|
||||||
|
- if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && (boottime.tv_sec != 0)) {
|
||||||
|
- *puptime = now - boottime.tv_sec;
|
||||||
|
- *puptime /= 60;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (cfg_sendload) {
|
||||||
|
- /* Get load average */
|
||||||
|
- getloadavg(loadavgs, 3);
|
||||||
|
- /* Use the 3rd element (15 minute load average) */
|
||||||
|
- *pload = loadavgs[2];
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (cfg_sendos) {
|
||||||
|
- /* Get os info */
|
||||||
|
- uname(&uts);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (cfg_sendcpu) {
|
||||||
|
- /* Get CPU info */
|
||||||
|
- mib[0] = CTL_HW;
|
||||||
|
- if (cfg_sendcpulevel == 1) {
|
||||||
|
- mib[1] = HW_MACHINE; /* Send architecture */
|
||||||
|
- }
|
||||||
|
- else {
|
||||||
|
- mib[1] = HW_MODEL; /* Send architecture's specific model */
|
||||||
|
- }
|
||||||
|
- size = CPU_SIZE;
|
||||||
|
- sysctl(mib, 2, cpu, &size, NULL, 0);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (cfg_sendos) {
|
||||||
|
- strncpy(os, uts.sysname, OS_SIZE - 1);
|
||||||
|
- if (cfg_sendoslevel) {
|
||||||
|
- strncpy(oslevel, uts.release, OSLEVEL_SIZE - 1);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (cfg_sendidle) {
|
||||||
|
- static kvm_t *kp;
|
||||||
|
- static int initialized = 0;
|
||||||
|
- static struct nlist namelist [] = {
|
||||||
+
|
+
|
||||||
+ if (!initialized) {
|
+ if (!initialized) {
|
||||||
+ initialized = 1;
|
+ initialized = 1;
|
||||||
+
|
+
|
||||||
mib[0] = CTL_KERN;
|
+ mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_BOOTTIME;
|
+ mib[1] = KERN_BOOTTIME;
|
||||||
size = sizeof(boottime);
|
+ size = sizeof(boottime);
|
||||||
- if(sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && (boottime.tv_sec != 0)) {
|
|
||||||
+
|
+
|
||||||
+ if (sysctl (mib, 2, &boottime, &size, NULL, 0) == -1)
|
+ if (sysctl(mib, 2, &boottime, &size, NULL, 0) == -1) {
|
||||||
+ err (1, "sysctl: kern.boottime");
|
+ uplog(LOG_ERR, "sysctl: kern.boottime");
|
||||||
|
+ err(1, "sysctl: kern.boottime");
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (boottime.tv_sec) {
|
+ if (boottime.tv_sec) {
|
||||||
|
@ -35,52 +110,43 @@
|
||||||
+
|
+
|
||||||
+ time (&now);
|
+ time (&now);
|
||||||
+
|
+
|
||||||
*puptime = now - boottime.tv_sec;
|
+ *puptime = now - boottime.tv_sec;
|
||||||
*puptime /= 60;
|
+ *puptime /= 60;
|
||||||
}
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if(cfg_sendload) { /* ========== loadavg ========== */
|
+ if (cfg_sendload) { /* ========== loadavg ========== */
|
||||||
+ double loadavgs[3] = { 0. };
|
+ double loadavgs[3] = { 0. };
|
||||||
|
+
|
||||||
- if(cfg_sendload) {
|
+ getloadavg(loadavgs, 3);
|
||||||
- /* Get load average */
|
+ /* Use the 3rd element (15 minute load average) */
|
||||||
getloadavg(loadavgs, 3);
|
+ *pload = loadavgs[2];
|
||||||
/* Use the 3rd element (15 minute load average) */
|
+ }
|
||||||
*pload = loadavgs[2];
|
+
|
||||||
}
|
+ if (cfg_sendcpu) { /* ========== cpu ========== */
|
||||||
|
+ static char buf[CPU_SIZE] = "";
|
||||||
- if(cfg_sendos) {
|
|
||||||
- /* Get os info */
|
|
||||||
- uname(&uts);
|
|
||||||
- }
|
|
||||||
+ if(cfg_sendcpu) { /* ========== cpu ========== */
|
|
||||||
+ static char buf [CPU_SIZE] = "";
|
|
||||||
+ static int initialized = 0;
|
+ static int initialized = 0;
|
||||||
+
|
+
|
||||||
+ if (!initialized) {
|
+ if (!initialized) {
|
||||||
+ initialized = 1;
|
+ initialized = 1;
|
||||||
|
|
||||||
- if(cfg_sendcpu) {
|
|
||||||
- /* Get CPU info */
|
|
||||||
mib[0] = CTL_HW;
|
|
||||||
if(cfg_sendcpulevel == 1) {
|
|
||||||
mib[1] = HW_MACHINE; /* Send architecture */
|
|
||||||
@@ -64,17 +77,35 @@
|
|
||||||
mib[1] = HW_MODEL; /* Send architecture's specific model */
|
|
||||||
}
|
|
||||||
size = CPU_SIZE;
|
|
||||||
- sysctl(mib, 2, cpu, &size, NULL, 0);
|
|
||||||
+
|
+
|
||||||
+ if (sysctl (mib, 2, buf, &size, NULL, 0) == -1)
|
+ mib[0] = CTL_HW;
|
||||||
+ warn ("sysctl: hw.model");
|
+ if (cfg_sendcpulevel == 1)
|
||||||
|
+ mib[1] = HW_MACHINE; /* Send architecture */
|
||||||
|
+ else
|
||||||
|
+ mib[1] = HW_MODEL; /* Send architecture's specific model */
|
||||||
|
+ size = CPU_SIZE;
|
||||||
|
+
|
||||||
|
+ if (sysctl(mib, 2, buf, &size, NULL, 0) == -1) {
|
||||||
|
+ uplog(LOG_WARNING, "sysctl: hw.model");
|
||||||
|
+ /* warn("sysctl: hw.model"); */
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ strncpy (cpu, buf, CPU_SIZE);
|
+ strlcpy(cpu, buf, CPU_SIZE);
|
||||||
+ cpu [CPU_SIZE - 1] = 0;
|
+ }
|
||||||
}
|
+
|
||||||
|
+ if (cfg_sendos) {
|
||||||
if(cfg_sendos) {
|
|
||||||
+ static struct utsname uts;
|
+ static struct utsname uts;
|
||||||
+ static int initialized = 0;
|
+ static int initialized = 0;
|
||||||
+
|
+
|
||||||
|
@ -90,17 +156,139 @@
|
||||||
+ uname(&uts);
|
+ uname(&uts);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
strncpy(os, uts.sysname, OS_SIZE - 1);
|
+ strlcpy(os, uts.sysname, OS_SIZE);
|
||||||
+ os [OS_SIZE - 1] = 0;
|
|
||||||
+
|
+
|
||||||
if(cfg_sendoslevel) {
|
+ if (cfg_sendoslevel)
|
||||||
strncpy(oslevel, uts.release, OSLEVEL_SIZE - 1);
|
+ strlcpy(oslevel, uts.release, OSLEVEL_SIZE);
|
||||||
+ oslevel [OSLEVEL_SIZE - 1] = 0;
|
+ }
|
||||||
|
+
|
||||||
|
+ if (cfg_sendidle) { /* ========== idle_time ========== */
|
||||||
|
+ static kvm_t *kp;
|
||||||
|
+ static int initialized = 0;
|
||||||
|
+ static struct nlist namelist[] = {
|
||||||
|
#define X_CP_TIME 0
|
||||||
|
- { "_cp_time" },
|
||||||
|
- { NULL },
|
||||||
|
- };
|
||||||
|
-
|
||||||
|
- if (!initialized) {
|
||||||
|
- char errbuf[_POSIX2_LINE_MAX];
|
||||||
|
- initialized = 1;
|
||||||
|
-
|
||||||
|
- setgid(getgid());
|
||||||
|
-
|
||||||
|
- kp = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
|
||||||
|
-
|
||||||
|
- if (!kp) {
|
||||||
|
- uplog(LOG_WARNING, "kvm_openfiles: %s. (Did you forget to start upclient as root?)", errbuf);
|
||||||
|
-// warn("kvm_openfiles: %s", errbuf);
|
||||||
|
- }
|
||||||
|
- else if (kvm_nlist(kp,namelist) == -1) {
|
||||||
|
- uplog(LOG_WARNING, "kvm_nlist: %s", kvm_geterr(kp));
|
||||||
|
-// warn("kvm_nlist: %s", kvm_geterr(kp));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (kp) {
|
||||||
|
- long ctime[CPUSTATES];
|
||||||
|
- static long stime[CPUSTATES];
|
||||||
|
- static int first_time = 1;
|
||||||
|
-
|
||||||
|
- if (first_time) {
|
||||||
|
- first_time = 0;
|
||||||
|
-
|
||||||
|
- if (kvm_read(kp, namelist[X_CP_TIME].n_value, stime, sizeof(stime)) == -1) {
|
||||||
|
- uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
|
||||||
|
-// warn("kvm_read: %s", kvm_geterr(kp));
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- sleep(1); /* to avoid the initial 0 idle value */
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (kvm_read(kp, namelist[X_CP_TIME].n_value, ctime, sizeof(ctime)) == -1) {
|
||||||
|
- uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
|
||||||
|
-// warn("kvm_read: %s", kvm_geterr(kp));
|
||||||
|
- }
|
||||||
|
- else {
|
||||||
|
- int state;
|
||||||
|
- double time = 0.;
|
||||||
|
-
|
||||||
|
- for(state = 0; state < CPUSTATES; state++)
|
||||||
|
- time += ctime[state] - stime[state];
|
||||||
|
-
|
||||||
|
- if (time == 0.)
|
||||||
|
- time = 1.;
|
||||||
|
-
|
||||||
|
- *pidle = (ctime[CP_IDLE] - stime[CP_IDLE]) * 100. / time;
|
||||||
|
-
|
||||||
|
- for(state = 0; state < CPUSTATES; state++)
|
||||||
|
- stime[state] = ctime[state];
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- else {
|
||||||
|
- cfg_sendidle = 0;
|
||||||
|
- }
|
||||||
|
+ { "_cp_time" },
|
||||||
|
+ { NULL },
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ if (!initialized) {
|
||||||
|
+ char errbuf[_POSIX2_LINE_MAX];
|
||||||
|
+ initialized = 1;
|
||||||
|
+
|
||||||
|
+ setgid(getgid());
|
||||||
|
+
|
||||||
|
+ kp = kvm_openfiles(NULL,NULL,NULL,O_RDONLY,errbuf);
|
||||||
|
+
|
||||||
|
+ if (!kp) {
|
||||||
|
+ uplog(LOG_WARNING, "kvm_openfiles: %s",errbuf);
|
||||||
|
+ /* warn("kvm_openfiles: %s",errbuf); */
|
||||||
|
+ } else if (kvm_nlist(kp,namelist) == -1) {
|
||||||
|
+ uplog(LOG_WARNING, "kvm_nlist: %s",kvm_geterr(kp));
|
||||||
|
+ /* warn("kvm_nlist: %s",kvm_geterr(kp)); */
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (kp) {
|
||||||
|
+ long ctime[CPUSTATES];
|
||||||
|
+ static long stime[CPUSTATES];
|
||||||
|
+ static int first_time = 1;
|
||||||
|
+
|
||||||
|
+ if (first_time) {
|
||||||
|
+ first_time = 0;
|
||||||
|
+
|
||||||
|
+ if (kvm_read(kp, namelist[X_CP_TIME].n_value,
|
||||||
|
+ stime, sizeof(stime)) == -1) {
|
||||||
|
+ uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
|
||||||
|
+ /* warn("kvm_read: %s", kvm_geterr(kp)); */
|
||||||
|
+ } else
|
||||||
|
+ sleep(1); /* to avoid the initial 0 idle value */
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (kvm_read(kp, namelist[X_CP_TIME].n_value,
|
||||||
|
+ ctime, sizeof(ctime)) == -1) {
|
||||||
|
+ uplog(LOG_WARNING, "kvm_read: %s", kvm_geterr(kp));
|
||||||
|
+ /* warn("kvm_read: %s", kvm_geterr(kp)); */
|
||||||
|
+ } else {
|
||||||
|
+ int state;
|
||||||
|
+ double time = 0.;
|
||||||
|
+
|
||||||
|
+ for (state = 0; state < CPUSTATES; state++)
|
||||||
|
+ time += ctime[state] - stime[state];
|
||||||
|
+
|
||||||
|
+ if (time == 0.)
|
||||||
|
+ time = 1.;
|
||||||
|
+
|
||||||
|
+ *pidle = (ctime[CP_IDLE] - stime[CP_IDLE]) * 100. / time;
|
||||||
|
+
|
||||||
|
+ for (state = 0; state < CPUSTATES; state++)
|
||||||
|
+ stime[state] = ctime[state];
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ cfg_sendidle = 0;
|
||||||
}
|
}
|
||||||
}
|
+ }
|
||||||
|
}
|
||||||
- if(cfg_sendidle) {
|
-#endif /* PLATFORM_BSD */
|
||||||
+ if(cfg_sendidle) { /* ========== idle_time ========== */
|
+
|
||||||
static kvm_t *kp;
|
+#endif /* PLATFORM_BSD */
|
||||||
static int initialized = 0;
|
|
||||||
static struct nlist namelist [] = {
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- scripts/upchk.orig Fri Jun 1 01:30:24 2001
|
--- scripts/upchk.orig Mon Sep 23 19:28:31 2002
|
||||||
+++ scripts/upchk Sun Nov 18 16:45:59 2001
|
+++ scripts/upchk Sat Oct 19 22:52:27 2002
|
||||||
@@ -24,7 +24,7 @@
|
@@ -24,7 +24,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ sbin/upclient
|
||||||
%%PORTDOCS%%share/doc/upclient/COPYING
|
%%PORTDOCS%%share/doc/upclient/COPYING
|
||||||
%%PORTDOCS%%share/doc/upclient/FAQ
|
%%PORTDOCS%%share/doc/upclient/FAQ
|
||||||
%%PORTDOCS%%share/doc/upclient/HISTORY
|
%%PORTDOCS%%share/doc/upclient/HISTORY
|
||||||
|
%%PORTDOCS%%share/doc/upclient/HISTORY-BETA
|
||||||
%%PORTDOCS%%share/doc/upclient/INSTALL
|
%%PORTDOCS%%share/doc/upclient/INSTALL
|
||||||
%%PORTDOCS%%share/doc/upclient/README
|
%%PORTDOCS%%share/doc/upclient/README
|
||||||
%%PORTDOCS%%share/doc/upclient/TODO
|
%%PORTDOCS%%share/doc/upclient/TODO
|
||||||
|
|
Loading…
Add table
Reference in a new issue