summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorwiz <wiz@pkgsrc.org>2002-04-16 21:49:25 +0000
committerwiz <wiz@pkgsrc.org>2002-04-16 21:49:25 +0000
commit42a3e14049158639d9fce49df95a4b3afc61e17b (patch)
tree74c01cdb5b1578d0da6b9b87f4e6aadf4b7ccc13 /sysutils
parent9771d9bf71f0fe37b739049383c7aee960674279 (diff)
downloadpkgsrc-42a3e14049158639d9fce49df95a4b3afc61e17b.tar.gz
Initial import of bbsload-0.2.5:
bbsload is one of the 'bbtools' for the BlackBox window manager. It is a small (in dimensions) tool that will visualise various system parameters, like avarage load and memory usage. Provided by Martijn van Buul in pkg/16339.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/bbsload/DESCR3
-rw-r--r--sysutils/bbsload/Makefile19
-rw-r--r--sysutils/bbsload/PLIST6
-rw-r--r--sysutils/bbsload/distinfo6
-rw-r--r--sysutils/bbsload/patches/patch-aa331
-rw-r--r--sysutils/bbsload/patches/patch-ab13
6 files changed, 378 insertions, 0 deletions
diff --git a/sysutils/bbsload/DESCR b/sysutils/bbsload/DESCR
new file mode 100644
index 00000000000..2f91fc3d714
--- /dev/null
+++ b/sysutils/bbsload/DESCR
@@ -0,0 +1,3 @@
+Small (in dimensions) tool to display various statistics like average
+load during the last minute, last 5 minutes and 15 minutes, memory
+usage, swap usage and CPU usage. Especially suited for BlackBox.
diff --git a/sysutils/bbsload/Makefile b/sysutils/bbsload/Makefile
new file mode 100644
index 00000000000..4addd80404b
--- /dev/null
+++ b/sysutils/bbsload/Makefile
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1.1.1 2002/04/16 21:49:25 wiz Exp $
+#
+
+DISTNAME= bbsload-0.2.5
+CATEGORIES= sysutils x11 wm
+MASTER_SITES= http://bbtools.thelinuxcommunity.org/sources/
+
+MAINTAINER= pino@dohd.org
+HOMEPAGE= http://bbtools.thelinuxcommunity.org/
+COMMENT= Small (in dimensions) tool to display the avarage load
+
+GNU_CONFIGURE= YES
+USE_BUILDLINK_ONLY= YES
+USE_X11BASE= YES
+
+GNU_CONFIGURE= YES
+
+.include "../../mk/x11.buildlink.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/bbsload/PLIST b/sysutils/bbsload/PLIST
new file mode 100644
index 00000000000..ec05e88263c
--- /dev/null
+++ b/sysutils/bbsload/PLIST
@@ -0,0 +1,6 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2002/04/16 21:49:27 wiz Exp $
+bin/bbsload
+share/bbtools/README.bbsload
+share/bbtools/bbsload.bb
+share/bbtools/bbsload.nobb
+@unexec ${RMDIR} %D/share/bbtools 2>/dev/null || true
diff --git a/sysutils/bbsload/distinfo b/sysutils/bbsload/distinfo
new file mode 100644
index 00000000000..b31e451d948
--- /dev/null
+++ b/sysutils/bbsload/distinfo
@@ -0,0 +1,6 @@
+$NetBSD: distinfo,v 1.1.1.1 2002/04/16 21:49:27 wiz Exp $
+
+SHA1 (bbsload-0.2.5.tar.gz) = 4c4a023dd8ded57b959167e64877cc86c2709e52
+Size (bbsload-0.2.5.tar.gz) = 79203 bytes
+SHA1 (patch-aa) = 51a725db6d11831f48bf2896304569a584ce41ef
+SHA1 (patch-ab) = 3a14f1b186939e75a74468f481583d49a2a30b4e
diff --git a/sysutils/bbsload/patches/patch-aa b/sysutils/bbsload/patches/patch-aa
new file mode 100644
index 00000000000..5c5890dc15a
--- /dev/null
+++ b/sysutils/bbsload/patches/patch-aa
@@ -0,0 +1,331 @@
+$NetBSD: patch-aa,v 1.1.1.1 2002/04/16 21:49:27 wiz Exp $
+
+--- bbsload.cc.orig Mon May 22 20:53:37 2000
++++ bbsload.cc
+@@ -21,6 +21,12 @@
+
+ #include "bbsload.hh"
+
++#ifdef __NetBSD__
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <uvm/uvm_param.h>
++#endif
++
+ CheckLoad::CheckLoad(ToolWindow *toolwindow) {
+ bbtool=toolwindow;
+ timer=new BTimer(bbtool->getCurrentScreenInfo()->getBaseDisplay(),this) ;
+@@ -40,97 +46,81 @@
+
+ void CheckLoad::timeout()
+ {
+- FILE *fp;
+-
+- char loadstr[28];
+- char buffer[128];
+- bool redraw=False;
+- struct stat file_status;
+- static time_t last_mtime;
+- static unsigned long old_user=0;
+- static unsigned long old_nice=0;
+- static unsigned long old_system=0;
+- static unsigned long old_idle=0;
+- broken=False;
++ static u_int64_t old_user=0, old_nice=0, old_system=0,
++ old_idle=0;
++ u_int64_t user,nice,system,idle,total;
++ u_int64_t cputimes[5];
++ double lavg[3];
++ struct uvmexp uvm_stat;
++ int ctl_name[3];
++ size_t ctllen;
+
+- if (!(fp = fopen("/proc/loadavg", "r")))
+- broken=True;
+- else
+- {
+- fstat(fileno(fp),&file_status);
+- if (file_status.st_mtime != last_mtime)
+- {
+- fgets(loadstr, 28, fp);
+- sscanf(loadstr,"%e %e %e %d/%d",&load.average1m,
+- &load.average5m,&load.average15m,&task.running,
+- &task.total);
+- redraw=true;
+- }
+- }
+- fclose(fp);
+- if (!(fp = fopen("/proc/meminfo", "r")))
+- broken=True;
+- else
+- {
+- fstat(fileno(fp),&file_status);
+- if (file_status.st_mtime != last_mtime)
+- {
+- /* should work for now */
+- fgets(buffer,128,fp);
+- fgets(buffer,128,fp);
+- sscanf(buffer,"Mem: %lu %lu %lu %lu %lu %lu",&mem.total,
+- &mem.used,&mem.free,&mem.shared,&mem.buffers,
+- &mem.cached);
+- fgets(buffer,128,fp);
+- sscanf(buffer,"Swap: %lu %lu %lu",
+- &swap.total,&swap.used,&swap.free);
+-
+- norm.total_used=(double)(mem.used+swap.used)/
+- (double)(mem.total+swap.total);
+- norm.mem_used=(double)mem.used/(double)mem.total;
+- if (swap.total!=0)
+- norm.swap_used=(double)swap.used/(double)swap.total;
+-
+- redraw=true;
+- }
+- }
+- fclose(fp);
++ int i;
+
+- if (!(fp = fopen("/proc/stat", "r")))
+- broken=True;
+- else
+- {
+- fstat(fileno(fp),&file_status);
+- if (file_status.st_mtime != last_mtime)
+- {
+- unsigned long user,nice,system,idle,total;
+- /* should work for now */
+- fgets(buffer,128,fp);
+- sscanf(buffer,"cpu %lu %lu %lu %lu",&user,
+- &nice,&system,&idle);
+- total=(user-old_user)+(nice-old_nice)+
+- (system-old_system)+(idle-old_idle);
++ broken=False;
+
+- if ((total!=0)&(old_user!=0))
+- {
+- cpu.user=(user-old_user)/(double)total;
+- cpu.nice=(nice-old_nice)/(double)user;
+- cpu.system=(system-old_system)/(double)total;
+- cpu.idle=(idle-old_idle)/(double)total;
+- }
+- else
+- cpu.user=cpu.nice=cpu.system=cpu.idle=0;
++ /* Get system load */
+
+- old_user=user;
+- old_nice=nice;
+- old_system=system;
+- old_idle=idle;
+- redraw=true;
+- }
+- }
+- fclose(fp);
+- if (redraw)
+- bbtool->Redraw();
++ getloadavg(lavg,3);
++ load.average1m=lavg[0];
++ load.average5m=lavg[1];
++ load.average15m=lavg[2];
++
++ /* Get total amount of processes */
++
++ ctl_name[0]=CTL_KERN;
++ ctl_name[1]=KERN_PROC;
++ ctl_name[2]=KERN_PROC_ALL;
++ sysctl(ctl_name, 3, NULL, &ctllen,NULL,0); /* get size of proc table */
++ task.total=ctllen/sizeof(struct kinfo_proc); /* Anybody have an
++ alternative ? */
++
++ /* task.running is missing */
++ /* get memory statistics */
++ ctllen=sizeof(uvm_stat);
++ ctl_name[0]=CTL_VM;
++ ctl_name[1]=VM_UVMEXP;
++ sysctl(ctl_name,2,&uvm_stat,&ctllen,NULL,0);
++
++ mem.total=uvm_stat.npages;
++ mem.used=uvm_stat.npages-uvm_stat.free;
++
++ swap.total=uvm_stat.swpages;
++ swap.used=uvm_stat.swpgonly; /* Only count pages in swap which are
++ not also present in memory */
++
++ norm.total_used=(double)(mem.used+swap.used)/
++ (double)(mem.total+swap.total);
++ norm.mem_used=(double)mem.used/(double)mem.total;
++ if (swap.total!=0)
++ norm.swap_used=(double)swap.used/(double)swap.total;
++
++ ctl_name[0]=CTL_KERN;
++ ctl_name[1]=KERN_CP_TIME;
++ ctllen=sizeof(cputimes);
++ if(sysctl(ctl_name,2,cputimes,&ctllen,NULL,0))
++ perror("sysctl");
++ user=cputimes[0];
++ nice=cputimes[1];
++ system=cputimes[2] /*sys*/
++ +cputimes[3]/*intr*/;
++ idle=cputimes[4];
++ total=(user-old_user)+(nice-old_nice)+
++ (system-old_system)+(idle-old_idle);
++ if ((total!=0)&(old_user!=0))
++ {
++ cpu.user=(double)(user-old_user)/(double)total;
++ cpu.nice=(double)(nice-old_nice)/(double)total;
++ cpu.system=(double)(system-old_system)/(double)total;
++ cpu.idle=(double)(idle-old_idle)/(double)total;
++ }
++ else
++ cpu.user=cpu.nice=cpu.system=cpu.idle=0;
++ old_user=user;
++ old_nice=nice;
++ old_system=system;
++ old_idle=idle;
++ bbtool->Redraw();
+ }
+
+
+@@ -233,15 +223,15 @@
+ label_counter++;
+ }
+ if (resource->show.label_totalused) {
+- label.width[6] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
++ label.width[8] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
+ label_counter++;
+ }
+ if (resource->show.label_memused) {
+- label.width[7] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
++ label.width[6] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
+ label_counter++;
+ }
+ if (resource->show.label_swapused) {
+- label.width[8] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
++ label.width[7] = XTextWidth(resource->label.font,"0.00",strlen("0.00"));
+ label_counter++;
+ }
+ if (resource->show.label_usercpu) {
+@@ -545,7 +535,7 @@
+ }
+ }
+
+-void ToolWindow::RedrawLabel(double level,int labelnr)
++void ToolWindow::RedrawLabel(double level,int labelnr,int idx, BColor colour)
+ {
+ char t[6];
+
+@@ -561,15 +551,14 @@
+ xposition+=label.seperator_width;
+ }
+
+- XSetForeground(getXDisplay(),frameGC,
+- resource->label.load1m_textColor.getPixel());
++ XSetForeground(getXDisplay(),frameGC, colour.getPixel());
+ labelnr++;
+ sprintf(t,"%1.2f",level);
+ XDrawString(getXDisplay(), labelwin, frameGC, xposition,
+ (label.height+resource->label.font->ascent-
+ resource->label.font->descent) / 2,
+ t, strlen(t));
+- xposition+=label.width[2];
++ xposition+=label.width[idx];
+ }
+
+ void ToolWindow::Redraw()
+@@ -577,12 +566,12 @@
+ int offset=0;
+ if (resource->show.load1m)
+ {
+- RedrawGauge(check_load->getLoad().average1m,offset);
++ RedrawGauge(check_load->getLoad().average1m,offset);
+ offset++;
+ }
+ if (resource->show.load5m)
+ {
+- RedrawGauge(check_load->getLoad().average5m,offset);
++ RedrawGauge(check_load->getLoad().average5m,offset);
+ offset++;
+ }
+ if (resource->show.load15m)
+@@ -678,53 +667,63 @@
+
+ if (resource->show.label_load1m)
+ {
+- RedrawLabel(check_load->getLoad().average1m,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getLoad().average1m,offset,2,
++ resource->label.load1m_textColor);
++ offset++;
+ }
+ if (resource->show.label_load5m)
+ {
+- RedrawLabel(check_load->getLoad().average5m,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getLoad().average5m,offset,3,
++ resource->label.load5m_textColor);
++ offset++;
+ }
+ if (resource->show.label_load15m)
+ {
+- RedrawLabel(check_load->getLoad().average15m,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getLoad().average15m,offset,4,
++ resource->label.load15m_textColor);
++ offset++;
+ }
+ if (resource->show.label_memused)
+ {
+- RedrawLabel(check_load->getNorm().mem_used,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getNorm().mem_used,offset,6,
++ resource->label.memUsed_textColor);
++ offset++;
+ }
+ if (resource->show.label_swapused)
+ {
+- RedrawLabel(check_load->getNorm().swap_used,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getNorm().swap_used,offset,7,
++ resource->label.swapUsed_textColor);
++ offset++;
+ }
+ if (resource->show.label_totalused)
+ {
+- RedrawLabel(check_load->getNorm().total_used,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getNorm().total_used,offset,8,
++ resource->label.totalUsed_textColor);
++ offset++;
+ }
+ if (resource->show.label_usercpu)
+ {
+- RedrawLabel(check_load->getCpu().user,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getCpu().user,offset,9,
++ resource->label.seperator_textColor);
++ offset++;
+ }
+ if (resource->show.label_nicecpu)
+ {
+- RedrawLabel(check_load->getCpu().nice,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getCpu().nice,offset,10,
++ resource->label.seperator_textColor);
++ offset++;
+ }
+ if (resource->show.label_systemcpu)
+ {
+- RedrawLabel(check_load->getCpu().system,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getCpu().system,offset,11,
++ resource->label.seperator_textColor);
++ offset++;
+ }
+ if (resource->show.label_idlecpu)
+ {
+- RedrawLabel(check_load->getCpu().idle,labelnr);
+- labelnr++;
++ RedrawLabel(check_load->getCpu().idle,offset,12,
++ resource->label.seperator_textColor);
++ offset++;
+ }
+ }
+
diff --git a/sysutils/bbsload/patches/patch-ab b/sysutils/bbsload/patches/patch-ab
new file mode 100644
index 00000000000..5ac16a450cb
--- /dev/null
+++ b/sysutils/bbsload/patches/patch-ab
@@ -0,0 +1,13 @@
+$NetBSD: patch-ab,v 1.1.1.1 2002/04/16 21:49:27 wiz Exp $
+
+--- bbsload.hh.orig Sun Apr 9 12:27:34 2000
++++ bbsload.hh
+@@ -150,7 +150,7 @@
+ void reconfigure(void);
+ void CheckConfig(void);
+ void RedrawGauge(double,int);
+- void RedrawLabel(double,int);
++ void RedrawLabel(double,int,int,BColor);
+ bool raised;
+ Resource *getResource(void) { return(resource); }
+ protected: