summaryrefslogtreecommitdiff
path: root/misc/upclient/files
diff options
context:
space:
mode:
Diffstat (limited to 'misc/upclient/files')
-rw-r--r--misc/upclient/files/patch-aa17
-rw-r--r--misc/upclient/files/patch-ab15
-rw-r--r--misc/upclient/files/patch-options.c37
-rw-r--r--misc/upclient/files/patch-options.h28
-rw-r--r--misc/upclient/files/patch-stats-bsd.c184
-rw-r--r--misc/upclient/files/patch-upchk15
-rw-r--r--misc/upclient/files/upclient.sh93
7 files changed, 156 insertions, 233 deletions
diff --git a/misc/upclient/files/patch-aa b/misc/upclient/files/patch-aa
index b743569e83f8..7a5c4bb709f5 100644
--- a/misc/upclient/files/patch-aa
+++ b/misc/upclient/files/patch-aa
@@ -1,6 +1,6 @@
---- src/Makefile.orig Mon Dec 18 14:44:48 2000
-+++ src/Makefile Sat Dec 30 02:44:49 2000
-@@ -8,7 +8,7 @@
+--- src/Makefile.orig Sun Jun 17 00:48:35 2001
++++ src/Makefile Sun Nov 18 15:58:37 2001
+@@ -9,7 +9,7 @@
####
# Location of config file (for example /etc/upclient.conf)
#
@@ -9,16 +9,7 @@
####
-@@ -41,7 +41,7 @@
-
- bsd:
- $(MAKE) CC=gcc \
-- LDFLAGS= \
-+ LDFLAGS="-lkvm" \
- OBJECTS='stats-bsd.c $(STDOPTS)' \
- CFLAGS='-DPLATFORM_BSD -DCONFIGFILE=\"$(CONFIGFILE)\"' \
- upclient
-@@ -88,7 +88,7 @@
+@@ -113,7 +113,7 @@
CFLAGS='-DPLATFORM_WINNT -DCONFIGFILE=\"$(CONFIGFILE)\"' \
upclient
diff --git a/misc/upclient/files/patch-ab b/misc/upclient/files/patch-ab
index 1f1af4045616..df189f5b908a 100644
--- a/misc/upclient/files/patch-ab
+++ b/misc/upclient/files/patch-ab
@@ -1,16 +1,13 @@
---- upclient.conf.orig Wed Dec 27 00:48:16 2000
-+++ upclient.conf Sat Dec 30 06:11:27 2000
-@@ -4,11 +4,11 @@
- # upclient.conf
- #
-
--PidFile = /home/alex/.upclient.pid # Location of pid file
-+PidFile = /var/run/upclient.pid # Location of pid file
+--- conf/upclient.conf.orig Sat Jun 16 18:33:54 2001
++++ conf/upclient.conf Sun Nov 18 17:33:13 2001
+@@ -8,8 +8,8 @@
AuthKey = <your_authkey> # Your Authorization key
-Interval = 120 # Transmit interval
+-UptimeServer = data.uptimes.net # Uptimes Project's data server
+Interval = 550 # Transmit interval
- UptimeServer = data.uptimes.net # Uptimes Project's data server
++UptimeServer = uptimes.wonko.com # Uptimes Project's data server
SendIdleTime = 1 # Send your idle time
+ SendLoadAvg = 1 # Send load average
diff --git a/misc/upclient/files/patch-options.c b/misc/upclient/files/patch-options.c
index c6773e9241af..5f768b4132d8 100644
--- a/misc/upclient/files/patch-options.c
+++ b/misc/upclient/files/patch-options.c
@@ -1,26 +1,15 @@
---- src/options.c.orig Wed Dec 27 00:41:53 2000
-+++ src/options.c Sat Dec 30 06:09:57 2000
-@@ -23,11 +23,7 @@
+--- src/options.c.orig Sat Jun 16 21:15:04 2001
++++ src/options.c Sun Nov 18 17:40:06 2001
+@@ -16,9 +16,9 @@
+ * These are the configuration options available.
+ */
+ char cfg_authkey[AUTHKEY_REQUIRED_LEN+1] = "";
+-char cfg_upserver[UPSERVER_MAXLEN+1] = "data.uptimes.net";
+-int cfg_interval = 120;
+-char cfg_pidfile[PIDFILE_MAXLEN+1] = ".upclient.pid";
++char cfg_upserver[UPSERVER_MAXLEN+1] = "uptimes.wonko.com";
++int cfg_interval = 550;
++char cfg_pidfile[PIDFILE_MAXLEN+1] = "/var/run/upclient.pid";
+ char cfg_proxyserver[PROXYSERVER_MAXLEN+1] = "";
int cfg_proxyport = 8080;
char cfg_proxyuser[PROXYUSER_MAXLEN+1] = "";
- char cfg_proxypass[PROXYPASS_MAXLEN+1] = "";
--#if defined(PLATFORM_BSD)
--int cfg_sendidle = 0;
--#else
- int cfg_sendidle = 1;
--#endif
- #if defined(PLATFORM_UNIXWARE)
- int cfg_sendload = 0;
- #else
-@@ -124,11 +120,7 @@
- strcpy(cfg_pidfile, value);
- }
- else if(strcmp(key, "SendIdleTime") == 0) {
--#if defined(PLATFORM_BSD)
-- ;
--#else
- cfg_sendidle = atol(value);
--#endif
- }
- else if(strcmp(key, "SendLoadAvg") == 0) {
- #if defined(PLATFORM_UNIXWARE)
diff --git a/misc/upclient/files/patch-options.h b/misc/upclient/files/patch-options.h
index ae8744b4a5b3..d3b6d58c09c8 100644
--- a/misc/upclient/files/patch-options.h
+++ b/misc/upclient/files/patch-options.h
@@ -1,26 +1,14 @@
---- src/options.h.orig Mon Dec 18 01:22:43 2000
-+++ src/options.h Sat Dec 30 02:49:11 2000
-@@ -33,19 +33,11 @@
- extern int cfg_proxyport;
+--- src/options.h.orig Sat Jun 16 17:45:50 2001
++++ src/options.h Sun Nov 18 16:08:56 2001
+@@ -34,11 +34,7 @@
extern char cfg_proxyuser[PROXYUSER_MAXLEN+1];
extern char cfg_proxypass[PROXYPASS_MAXLEN+1];
--#if defined(PLATFORM_BSD)
extern int cfg_sendidle;
--#else
--extern int cfg_sendidle;
--#endif
-#if defined(PLATFORM_UNIXWARE)
--extern cfg_sendload;
+ extern int cfg_sendload;
-#else
--extern cfg_sendload;
+-extern int cfg_sendload;
-#endif
--extern cfg_sendos;
--extern cfg_sendoslevel;
--extern cfg_sendcpu;
-+extern int cfg_sendload;
-+extern int cfg_sendos;
-+extern int cfg_sendoslevel;
-+extern int cfg_sendcpu;
-
- /* External global variables: set to reflect config options */
- extern int have_proxyserver;
+ extern int cfg_sendos;
+ extern int cfg_sendoslevel;
+ extern int cfg_sendcpu;
diff --git a/misc/upclient/files/patch-stats-bsd.c b/misc/upclient/files/patch-stats-bsd.c
index d53fa937e08c..b5aea3fa6c2c 100644
--- a/misc/upclient/files/patch-stats-bsd.c
+++ b/misc/upclient/files/patch-stats-bsd.c
@@ -1,21 +1,6 @@
---- src/stats-bsd.c.orig Mon Dec 18 14:32:19 2000
-+++ src/stats-bsd.c Sat Dec 30 03:26:15 2000
-@@ -12,57 +12,153 @@
- /* System includes */
- #include <stdio.h>
- #include <errno.h>
-+#include <fcntl.h>
-+#include <limits.h>
-+#include <kvm.h>
- #include <syslog.h>
- #include <sys/time.h>
- #include <sys/param.h>
- #include <sys/sysctl.h>
-+#include <sys/dkstat.h>
-+#include <devstat.h>
- #include <sys/utsname.h>
-
- /**
+--- src/stats-bsd.c.orig Sat Jun 16 21:12:53 2001
++++ src/stats-bsd.c Sun Nov 18 17:33:52 2001
+@@ -26,37 +26,50 @@
* @desc Get statistics
*/
void getstats(unsigned long *puptime, double *pload, int *pidle, char *os, char *oslevel, char *cpu) {
@@ -24,137 +9,68 @@
- time_t now;
size_t size;
- double loadavgs[2];
-- int mib[2];
-+ int mib [2];
-+
-+ { /* ========== uptime ========== */
+ int mib[2];
+
+- /* Get uptime */
+- time(&now);
++ { /* ========== uptime ========== */
+ static struct timeval boottime;
+ static int initialized = 0;
++ time_t now;
+
+ if (!initialized) {
+ initialized = 1;
+
-+ mib [0] = CTL_KERN;
-+ mib [1] = KERN_BOOTTIME;
-+
-+ size = sizeof (boottime);
-
-- /* Get uptime */
-- time(&now);
-- mib[0] = CTL_KERN;
-- mib[1] = KERN_BOOTTIME;
-- size = sizeof(boottime);
+ 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 (sysctl (mib, 2, &boottime, &size, NULL, 0) == -1)
+ err (1, "sysctl: kern.boottime");
- }
-
-- if(cfg_sendos) {
-- /* Get os info */
-- uname(&uts);
++ }
++
+ if (boottime.tv_sec) {
+ time_t now;
+
+ time (&now);
+
-+ *puptime = (now - boottime.tv_sec) / 60;
-+ }
+ *puptime = now - boottime.tv_sec;
+ *puptime /= 60;
+ }
+ }
+
-+ if (cfg_sendidle) { /* ========== idle_time ========== */
-+ static kvm_t *kp;
-+ static struct nlist namelist [] = {
-+#define X_CP_TIME 0
-+ { "_cp_time" },
-+ { NULL },
-+ };
++ if(cfg_sendload) { /* ========== loadavg ========== */
++ double loadavgs[3] = { 0. };
+
+- 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) { /* ========== cpu ========== */
++ static char buf [CPU_SIZE] = "";
+ static int initialized = 0;
+
+ if (!initialized) {
-+ char errbuf [_POSIX2_LINE_MAX];
+ initialized = 1;
-+
-+ setgid (getgid ());
-+
-+ kp = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
-+
-+ if (!kp)
-+ warn ("kvm_openfiles: %s", errbuf);
-+ else if (kvm_nlist (kp, namelist) == -1)
-+ 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)
-+ warn ("kvm_read: %s", kvm_geterr (kp));
-+ else
-+ sleep (1); /* to avoid the initial 0 idle value */
- }
- if(cfg_sendcpu) {
- /* Get CPU info */
-- mib[0] = CTL_HW;
-- mib[1] = HW_MODEL;
-- size = CPU_SIZE;
+ 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 (kvm_read(kp, namelist [X_CP_TIME].n_value,
-+ ctime, sizeof (ctime)) == -1)
-+ 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_sendload) { /* ========== loadavg ========== */
-+ double loadavgs [3] = { 0. };
-+
-+ getloadavg (loadavgs, 3);
-+
-+ *pload = loadavgs [2];
-+ }
-+
-+ if (cfg_sendcpu) { /* ========== cpu ========== */
-+ static char buf [CPU_SIZE] = "";
-+ static int initialized = 0;
-+
-+ if (!initialized) {
-+ initialized = 1;
-+
-+ mib [0] = CTL_HW;
-+ mib [1] = HW_MODEL;
-+
-+ size = sizeof (buf);
+
+ if (sysctl (mib, 2, buf, &size, NULL, 0) == -1)
+ warn ("sysctl: hw.model");
@@ -165,24 +81,26 @@
}
if(cfg_sendos) {
-- strncpy(os, uts.sysname, OS_SIZE - 1);
-- if(cfg_sendoslevel) {
-- strncpy(oslevel, uts.release, OSLEVEL_SIZE - 1);
+ static struct utsname uts;
+ static int initialized = 0;
+
+ if (!initialized) {
+ initialized = 1;
-+
++
+ uname(&uts);
+ }
+
-+ strncpy (os, uts.sysname, OS_SIZE - 1);
+ strncpy(os, uts.sysname, OS_SIZE - 1);
+ os [OS_SIZE - 1] = 0;
+
-+ if (cfg_sendoslevel) {
-+ strncpy (oslevel, uts.release, OSLEVEL_SIZE - 1);
+ if(cfg_sendoslevel) {
+ strncpy(oslevel, uts.release, OSLEVEL_SIZE - 1);
+ oslevel [OSLEVEL_SIZE - 1] = 0;
}
}
- }
+
+- if(cfg_sendidle) {
++ if(cfg_sendidle) { /* ========== idle_time ========== */
+ static kvm_t *kp;
+ static int initialized = 0;
+ static struct nlist namelist [] = {
diff --git a/misc/upclient/files/patch-upchk b/misc/upclient/files/patch-upchk
index 434f5dc23e77..dc4871db64e5 100644
--- a/misc/upclient/files/patch-upchk
+++ b/misc/upclient/files/patch-upchk
@@ -1,16 +1,11 @@
---- scripts/upchk.orig Wed Nov 29 01:19:14 2000
-+++ scripts/upchk Sat Dec 30 00:19:54 2000
-@@ -24,11 +24,11 @@
+--- scripts/upchk.orig Fri Jun 1 01:30:24 2001
++++ scripts/upchk Sun Nov 18 16:45:59 2001
+@@ -24,7 +24,7 @@
#
# change this to the full path AND name of your upclient executable:
--upclient="/home/mydir/upclient"
-+upclient="!!PREFIX!!/sbin/upclient"
+-upclient="/usr/local/sbin/upclient"
++upclient="%%PREFIX%%/sbin/upclient"
# change this to the name of your upclient's pidfile (as defined in
# config.h of the upclient distribution)
--pidfile="/home/mydir/upclient.pid"
-+pidfile="/var/run/upclient.pid"
-
- ########## you probably don't need to change anything below here ##########
-
diff --git a/misc/upclient/files/upclient.sh b/misc/upclient/files/upclient.sh
index 70470e68b6fa..f124a7f31218 100644
--- a/misc/upclient/files/upclient.sh
+++ b/misc/upclient/files/upclient.sh
@@ -1,35 +1,80 @@
#!/bin/sh
+#
+# $FreeBSD$
+#
+# Start or stop upclient.
+#
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
- echo "$0: Cannot determine the PREFIX" >&2
- exit 1
-fi
+rc_file=${0##*/}
+rc_arg=$1
-if [ -f ${PREFIX}/etc/upclient.conf ]; then
- if grep -qs '^[ ]*AuthKey[ ]*=' ${PREFIX}/etc/upclient.conf; then
- if grep -qs '^[ ]*AuthKey[ ]*=[ ]*<your_authkey>' ${PREFIX}/etc/upclient.conf; then
- echo "upclient: AuthKey not configured in ${PREFIX}/etc/upclient.conf -- aborted." >&2
- exit 1
- fi
- else
- echo "upclient: ${PREFIX}/etc/upclient.conf is out of date -- aborted." >&2
- exit 1
- fi
-else
- echo "upclient: ${PREFIX}/etc/upclient.conf doesn't exist -- aborted." >&2
- exit 1
+if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${rc_file}\$"); then
+ echo "${rc_file}: Cannot determine PREFIX." >&2
+ echo "Please use the complete pathname." >&2
+ exit 64
fi
-case "$1" in
+program_dir=${PREFIX}/sbin
+program_file=upclient
+program_path=${program_dir}/${program_file}
+
+config_dir=${PREFIX}/etc
+config_file=${program_file}.conf
+config_path=${config_dir}/${config_file}
+
+pid_dir=/var/run
+pid_file=${program_file}.pid
+pid_path=${pid_dir}/${pid_file}
+
+syslog_facility=daemon.err
+
+case "$rc_arg" in
start)
- [ -x ${PREFIX}/sbin/upclient ] && ${PREFIX}/sbin/upclient > /dev/null && echo -n ' upclient'
- ;;
+ if [ ! -x ${program_path} ]; then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: ${program_path} is missing."
+ exit 72
+ fi
+ if [ ! -f ${config_path} ]; then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: ${config_path} is missing."
+ exit 72
+ fi
+ ws=" "
+ if ! grep -qs "^[$ws]*AuthKey[$ws]*=" ${config_path}; then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: AuthKey is missing from" \
+ "${config_path}."
+ exit 72
+ fi
+ if grep -qs "^[$ws]*AuthKey[$ws]*=[$ws]*<your_authkey>" ${config_path}
+ then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: AuthKey isn't configured in" \
+ "${config_path}."
+ exit 72
+ fi
+ ${program_path} &&
+ echo -n " ${program_file}"
+ ;;
stop)
- [ -r /var/run/upclient.pid ] && kill `cat /var/run/upclient.pid` > /dev/null && echo -n ' upclient'
- ;;
+ if [ -r ${pid_path} ]; then
+ kill $(cat ${pid_path}) 2> /dev/null
+ else
+ killall ${program_file} 2> /dev/null
+ fi
+ ;;
+restart)
+ $0 stop
+ $0 start
+ ;;
+status)
+ ps -auxww | egrep ${program_file} | egrep -v "($0|egrep)"
+ ;;
*)
- echo "Usage: `basename $0` {start|stop}" >&2
- ;;
+ echo "usage: ${rc_file} {start|stop|restart|status}" >&2
+ exit 64
+ ;;
esac
exit 0