2011-12-16 09:59:10 +00:00
|
|
|
/*
|
|
|
|
Code based on wmppp/wmifs
|
|
|
|
|
|
|
|
[Orig WMPPP comments]
|
|
|
|
|
|
|
|
This code was mainly put together by looking at the
|
|
|
|
following programs:
|
|
|
|
|
|
|
|
asclock
|
|
|
|
A neat piece of equip, used to display the date
|
|
|
|
and time on the screen.
|
|
|
|
Comes with every AfterStep installation.
|
|
|
|
|
|
|
|
Source used:
|
|
|
|
How do I create a not so solid window?
|
|
|
|
How do I open a window?
|
|
|
|
How do I use pixmaps?
|
2014-10-05 15:29:59 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
|
|
Authors: Martijn Pieterse (pieterse@xs4all.nl)
|
|
|
|
Antoine Nulle (warp@xs4all.nl)
|
|
|
|
|
|
|
|
This program is distributed under the GPL license.
|
|
|
|
(as were asclock and pppstats)
|
|
|
|
|
|
|
|
----
|
|
|
|
Changes:
|
|
|
|
----
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
17/03/2014 (Pedro Gimeno Fortea)
|
|
|
|
* Fix jiffy counter overflowing long on 32-bit systems.
|
2012-06-17 09:59:03 +00:00
|
|
|
17/06/2012 (Rodolfo García Peñas (kix), <kix@kix.es>)
|
|
|
|
* Code style.
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
13/3/2012 (Barry Kelly (wbk), <coydog@devio.us>)
|
|
|
|
* Fixed get_statistics() I/O features to work with newer
|
|
|
|
/proc/diskstats instead of the old /proc/stat.
|
|
|
|
* Fixes to graph/meter scaling for I/O. Original code let
|
|
|
|
the scaling grow out of control due to inappropriate static
|
|
|
|
data.
|
|
|
|
* Eliminated rounding down relatively low stats in getWidth()
|
|
|
|
and DrawStats_io() by using double and float types instead
|
|
|
|
of ints. We now round up tiny values to prevent the system
|
|
|
|
appearing idle when it's not.
|
|
|
|
* Style/readbility edits.
|
|
|
|
* TODO: Merge in Gentoo and possibly BSD local patches. This
|
|
|
|
should aid in fixing I/O monitoring on non-Linux systems.
|
|
|
|
* TODO: Color swapping. User supplies color values in .rc, and
|
|
|
|
app modifies pixmap in memory on startup. Should be simple.
|
|
|
|
* TODO: address compiler warnings (GCC has gotten pickier over
|
|
|
|
the years).
|
2011-12-16 10:01:43 +00:00
|
|
|
17/10/2009 (Romuald Delavergne, romuald.delavergne@free.fr)
|
|
|
|
* Support SMP processors in realtime CPU stress meter
|
|
|
|
15/05/2004 (Simon Law, sfllaw@debian.org)
|
|
|
|
* Support disabling of mode-cycling
|
|
|
|
23/10/2003 (Simon Law, sfllaw@debian.org)
|
|
|
|
* Eliminated exploitable static buffers
|
|
|
|
* Added -geometry support.
|
|
|
|
* /proc/meminfo support for Linux 2.6
|
2011-12-16 09:59:10 +00:00
|
|
|
18/05/1998 (Antoine Nulle, warp@xs4all.nl)
|
|
|
|
* MEM/SWAP/UPTIME only updated when visible
|
|
|
|
* Using global file descriptors to reduce file
|
2014-10-05 15:29:59 +00:00
|
|
|
system overhead, both updates are based on a diff
|
|
|
|
supplied by Dave Harden (dharden@wisewire.com)
|
2011-12-16 09:59:10 +00:00
|
|
|
15/05/1998 (Antoine Nulle, warp@xs4all.nl)
|
|
|
|
* Fixed memory overflow in the MEM gaugebar
|
|
|
|
* MEM gauge displays now real used mem
|
|
|
|
(buffered + cached mem removed)
|
|
|
|
14/05/1998 (Antoine Nulle, warp@xs4all.nl)
|
|
|
|
* Added -i & -s kludge for selecting startupmode,
|
|
|
|
tijno, don't hate me for this :)
|
|
|
|
12/05/1998 (Antoine Nulle, warp@xs4all.nl)
|
2014-10-05 15:29:59 +00:00
|
|
|
* Finetuned master-xpm, tijno don't worry, no
|
2011-12-16 09:59:10 +00:00
|
|
|
reprogramming needed this time ;-)
|
|
|
|
07/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* Added disk i/o
|
|
|
|
03/05/1998 (Antoine Nulle, warp@xs4all.nl)
|
|
|
|
* Added new master-xpm which contains the gfx
|
|
|
|
for the upcoming SysInfo part :P
|
|
|
|
02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* Removed a lot of code, that was put in wmgeneral
|
|
|
|
23/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* Added zombie destroying code (aka wait :) )
|
|
|
|
18/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* Added CPU-on-screen.
|
|
|
|
* Added -display command line
|
|
|
|
15/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* Fixed a bug in the stats routine
|
|
|
|
(Top 3 bright pixels were not shown when 100% loaded)
|
|
|
|
* Changed xpm to a no-title one.
|
|
|
|
This included the reprogramming of all positions.
|
|
|
|
warpstah, i hate you! ;)
|
|
|
|
05/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
|
|
|
|
* First Working Version
|
|
|
|
*/
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
#define _GNU_SOURCE
|
2011-12-16 09:59:10 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2017-08-12 19:06:35 +00:00
|
|
|
#include <X11/X.h>
|
2011-12-16 09:59:10 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
2015-08-15 08:38:19 +00:00
|
|
|
#include <libdockapp/wmgeneral.h>
|
|
|
|
#include <libdockapp/misc.h>
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
#include "ulllib.h"
|
2011-12-16 09:59:10 +00:00
|
|
|
#include "wmmon-master.xpm"
|
|
|
|
#include "wmmon-mask.xbm"
|
|
|
|
|
|
|
|
/***********/
|
|
|
|
/* Defines */
|
|
|
|
/***********/
|
2012-04-01 23:58:33 +00:00
|
|
|
#define HISTORY_ENTRIES 55
|
2012-06-17 09:59:03 +00:00
|
|
|
#define MAX_CPU (10) /* depends on graph height */
|
|
|
|
#define MAX_STAT_DEVICES (4)
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/********************/
|
|
|
|
/* Global Variables */
|
|
|
|
/********************/
|
2012-06-17 09:59:03 +00:00
|
|
|
int stat_current = 0; /* now global */
|
|
|
|
int mode_cycling = 1; /* Allow mode-cycling */
|
|
|
|
int cpu_avg_max = 0; /* CPU stress meter with average and max for SMP */
|
2012-04-02 04:25:30 +00:00
|
|
|
int show_buffers = 0; /* wbk adding per Gentoo -b enhancement. */
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
FILE *fp_meminfo;
|
|
|
|
FILE *fp_stat;
|
|
|
|
FILE *fp_loadavg;
|
|
|
|
FILE *fp_diskstats; /* wbk new io stats API */
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
/* functions */
|
2011-12-16 10:01:43 +00:00
|
|
|
void usage(char*);
|
2011-12-16 09:59:10 +00:00
|
|
|
void printversion(void);
|
|
|
|
void DrawStats(int *, int, int, int, int);
|
|
|
|
void DrawStats_io(int *, int, int, int, int);
|
|
|
|
void wmmon_routine(int, char **);
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *name = argv[0];
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
/* Parse Command Line */
|
2012-06-17 09:59:03 +00:00
|
|
|
for (i = 1; i < argc; i++) {
|
2011-12-16 09:59:10 +00:00
|
|
|
char *arg = argv[i];
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
if (*arg=='-')
|
2011-12-16 09:59:10 +00:00
|
|
|
switch (arg[1]) {
|
|
|
|
case 'd' :
|
|
|
|
if (strcmp(arg+1, "display")) {
|
2011-12-16 10:01:43 +00:00
|
|
|
usage(name);
|
|
|
|
return 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-12-16 10:01:43 +00:00
|
|
|
case 'g' :
|
|
|
|
if (strcmp(arg+1, "geometry")) {
|
|
|
|
usage(name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case 'l' :
|
|
|
|
mode_cycling = 0;
|
|
|
|
break;
|
|
|
|
case 'c' :
|
|
|
|
cpu_avg_max = 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
break;
|
|
|
|
case 'i' :
|
|
|
|
stat_current = 1;
|
|
|
|
break;
|
2012-04-02 04:25:30 +00:00
|
|
|
case 'b' :
|
|
|
|
show_buffers = 1;
|
|
|
|
break;
|
2011-12-16 09:59:10 +00:00
|
|
|
case 's' :
|
|
|
|
stat_current = 2;
|
|
|
|
break;
|
2011-12-16 10:01:43 +00:00
|
|
|
case 'v' :
|
|
|
|
printversion();
|
|
|
|
return 0;
|
2011-12-16 09:59:10 +00:00
|
|
|
default:
|
2011-12-16 10:01:43 +00:00
|
|
|
usage(name);
|
|
|
|
return 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wmmon_routine(argc, argv);
|
2012-06-17 09:59:03 +00:00
|
|
|
exit(0);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* wmmon_routine *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
|
|
|
|
|
|
|
typedef struct {
|
2012-06-17 09:59:03 +00:00
|
|
|
char name[5]; /* "cpu0..cpuz", eventually.. :) */
|
|
|
|
int his[HISTORY_ENTRIES];
|
|
|
|
int hisaddcnt;
|
|
|
|
long rt_stat;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong statlast;
|
2012-06-17 09:59:03 +00:00
|
|
|
long rt_idle;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong idlelast;
|
2011-12-16 10:01:43 +00:00
|
|
|
/* Processors stats */
|
2012-06-17 09:59:03 +00:00
|
|
|
long *cpu_stat;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong *cpu_last;
|
2012-06-17 09:59:03 +00:00
|
|
|
long *idle_stat;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong *idle_last;
|
2011-12-16 09:59:10 +00:00
|
|
|
} stat_dev;
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
stat_dev stat_device[MAX_STAT_DEVICES];
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2014-10-05 15:29:59 +00:00
|
|
|
char *left_action, *right_action, *middle_action;
|
2012-06-17 09:59:03 +00:00
|
|
|
int nb_cpu, cpu_max;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
int getNbCPU(void);
|
|
|
|
unsigned long getWidth(long, long);
|
2011-12-16 09:59:10 +00:00
|
|
|
int checksysdevs(void);
|
2017-08-12 19:06:38 +00:00
|
|
|
void get_statistics(char *, long *, ullong *, ullong *, ullong *, ullong *);
|
2011-12-16 09:59:10 +00:00
|
|
|
void DrawActive(char *);
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
void update_stat_cpu(stat_dev *, ullong *, ullong *);
|
2011-12-16 09:59:10 +00:00
|
|
|
void update_stat_io(stat_dev *);
|
|
|
|
void update_stat_mem(stat_dev *st, stat_dev *st2);
|
|
|
|
void update_stat_swp(stat_dev *);
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
void wmmon_routine(int argc, char **argv)
|
|
|
|
{
|
|
|
|
rckeys wmmon_keys[] = {
|
2011-12-16 09:59:10 +00:00
|
|
|
{ "left", &left_action },
|
|
|
|
{ "right", &right_action },
|
|
|
|
{ "middle", &middle_action },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2017-08-12 19:06:37 +00:00
|
|
|
int i, j;
|
2012-06-17 09:59:03 +00:00
|
|
|
long k;
|
|
|
|
XEvent Event;
|
|
|
|
int but_stat = -1;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
int stat_online;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
long starttime, curtime, nexttime;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong istat, idle, *istat2, *idle2;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
FILE *fp;
|
|
|
|
char *conffile = NULL;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
int xpm_X = 0, xpm_Y = 0;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
long online_time = 0;
|
|
|
|
long ref_time = 0;
|
|
|
|
long cnt_time;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
fp = fopen("/proc/uptime", "r");
|
|
|
|
fp_meminfo = fopen("/proc/meminfo", "r");
|
|
|
|
fp_loadavg = fopen("/proc/loadavg", "r");
|
|
|
|
fp_stat = fopen("/proc/stat", "r");
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
fp_diskstats = fopen("/proc/diskstats", "r");
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
if (fp) {
|
2012-04-01 23:58:33 +00:00
|
|
|
if (fscanf(fp, "%ld", &online_time) == EOF)
|
|
|
|
perror("Error! fscanf() of /proc/uptime failed!\n");
|
2011-12-16 09:59:10 +00:00
|
|
|
ref_time = time(0);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
for (i = 0; i < MAX_STAT_DEVICES; i++) {
|
2012-06-17 09:59:03 +00:00
|
|
|
for (j = 0; j < HISTORY_ENTRIES; j++)
|
2011-12-16 09:59:10 +00:00
|
|
|
stat_device[i].his[j] = 0;
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
stat_device[i].hisaddcnt = 0;
|
|
|
|
}
|
|
|
|
|
2012-04-01 23:58:33 +00:00
|
|
|
/* wbk - I don't fully understand this. Probably just a means of providing
|
|
|
|
* test cases. ifdef'ing to clear compiler warnings. TODO: remove. */
|
|
|
|
#ifdef LEFT_ACTION
|
2014-10-05 15:29:59 +00:00
|
|
|
if (LEFT_ACTION)
|
2012-04-01 23:58:33 +00:00
|
|
|
left_action = strdup(LEFT_ACTION);
|
|
|
|
#endif
|
|
|
|
#ifdef RIGHT_ACTION
|
2014-10-05 15:29:59 +00:00
|
|
|
if (RIGHT_ACTION)
|
2012-04-01 23:58:33 +00:00
|
|
|
right_action = strdup(RIGHT_ACTION);
|
|
|
|
#endif
|
|
|
|
#ifdef MIDDLE_ACTION
|
|
|
|
if (MIDDLE_ACTION)
|
|
|
|
middle_action = strdup(MIDDLE_ACTION);
|
|
|
|
#endif
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
/* Scan through the .rc files */
|
|
|
|
if (asprintf(&conffile, "/etc/wmmonrc") >= 0) {
|
|
|
|
parse_rcfile(conffile, wmmon_keys);
|
|
|
|
free(conffile);
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
if (asprintf(&conffile, "%s/.wmmonrc", getenv("HOME")) >= 0) {
|
|
|
|
parse_rcfile(conffile, wmmon_keys);
|
|
|
|
free(conffile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asprintf(&conffile, "/etc/wmmonrc.fixed") >= 0) {
|
|
|
|
parse_rcfile(conffile, wmmon_keys);
|
|
|
|
free(conffile);
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
stat_online = checksysdevs();
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
nb_cpu = getNbCPU();
|
|
|
|
stat_device[0].cpu_stat = calloc(nb_cpu, sizeof(long));
|
2017-08-12 19:06:38 +00:00
|
|
|
stat_device[0].cpu_last = calloc(nb_cpu, sizeof(ullong));
|
2011-12-16 10:01:43 +00:00
|
|
|
stat_device[0].idle_stat = calloc(nb_cpu, sizeof(long));
|
2017-08-12 19:06:38 +00:00
|
|
|
stat_device[0].idle_last = calloc(nb_cpu, sizeof(ullong));
|
2012-06-17 09:59:03 +00:00
|
|
|
if (!stat_device[0].cpu_stat ||
|
|
|
|
!stat_device[0].cpu_last ||
|
|
|
|
!stat_device[0].idle_stat ||
|
|
|
|
!stat_device[0].idle_last) {
|
2011-12-16 10:01:43 +00:00
|
|
|
fprintf(stderr, "%s: Unable to alloc memory !\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
istat2 = calloc(nb_cpu, sizeof(ullong));
|
|
|
|
idle2 = calloc(nb_cpu, sizeof(ullong));
|
2011-12-16 10:01:43 +00:00
|
|
|
if (!istat2 || !idle2) {
|
|
|
|
fprintf(stderr, "%s: Unable to alloc memory !!\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2017-08-12 19:06:37 +00:00
|
|
|
openXwindow(argc, argv, wmmon_master_xpm, (char *)wmmon_mask_bits,
|
2012-06-17 09:59:03 +00:00
|
|
|
wmmon_mask_width, wmmon_mask_height);
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
/* add mouse region */
|
|
|
|
AddMouseRegion(0, 12, 13, 58, 57);
|
|
|
|
AddMouseRegion(1, 5, 5, 24, 14);
|
|
|
|
|
|
|
|
starttime = time(0);
|
|
|
|
nexttime = starttime + 10;
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
/* Collect information on each panel */
|
2012-06-17 09:59:03 +00:00
|
|
|
for (i = 0; i < stat_online; i++) {
|
2011-12-16 10:01:43 +00:00
|
|
|
get_statistics(stat_device[i].name, &k, &istat, &idle, istat2, idle2);
|
2011-12-16 09:59:10 +00:00
|
|
|
stat_device[i].statlast = istat;
|
|
|
|
stat_device[i].idlelast = idle;
|
2011-12-16 10:01:43 +00:00
|
|
|
if (i == 0 && nb_cpu > 1) {
|
|
|
|
int cpu;
|
|
|
|
for (cpu = 0; cpu < nb_cpu; cpu++) {
|
|
|
|
stat_device[i].cpu_last[cpu] = istat2[cpu];
|
|
|
|
stat_device[i].idle_last[cpu] = idle2[cpu];
|
|
|
|
}
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2011-12-16 10:01:43 +00:00
|
|
|
|
|
|
|
/* Set the mask for the current window */
|
|
|
|
switch (stat_current) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
xpm_X = 0;
|
|
|
|
setMaskXY(0, 0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
xpm_X = 64;
|
|
|
|
setMaskXY(-64, 0);
|
|
|
|
default:
|
|
|
|
break;
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2011-12-16 10:01:43 +00:00
|
|
|
|
|
|
|
/* Draw statistics */
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (stat_current == 0) {
|
2014-10-05 15:29:59 +00:00
|
|
|
DrawStats(stat_device[stat_current].his,
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
HISTORY_ENTRIES-1, 40, 5, 58);
|
2012-06-17 09:59:03 +00:00
|
|
|
} else if (stat_current == 1) {
|
2014-10-05 15:29:59 +00:00
|
|
|
DrawStats_io(stat_device[stat_current].his,
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
HISTORY_ENTRIES, 40, 5, 58);
|
2012-06-17 09:59:03 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
DrawActive(stat_device[stat_current].name);
|
|
|
|
|
|
|
|
while (1) {
|
2011-12-16 10:01:43 +00:00
|
|
|
curtime = time(NULL);
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
waitpid(0, NULL, WNOHANG);
|
|
|
|
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
update_stat_cpu(&stat_device[0], istat2, idle2);
|
2011-12-16 09:59:10 +00:00
|
|
|
update_stat_io(&stat_device[1]);
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
if(stat_current == 2)
|
2011-12-16 09:59:10 +00:00
|
|
|
update_stat_mem(&stat_device[2], &stat_device[3]);
|
|
|
|
|
|
|
|
if (stat_current < 2) {
|
|
|
|
i = stat_current;
|
2014-10-05 15:29:59 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/* Load ding is 45 pixels hoog */
|
|
|
|
copyXPMArea(0, 64, 32, 12, 28, 4);
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
if (i == 0 && nb_cpu > 1) {
|
|
|
|
if (nb_cpu > MAX_CPU || cpu_avg_max) {
|
|
|
|
/* show average CPU */
|
|
|
|
j = getWidth(stat_device[i].rt_stat, stat_device[i].rt_idle);
|
|
|
|
copyXPMArea(32, 64, j, 6, 28, 4);
|
|
|
|
/* Show max CPU */
|
2014-10-05 15:29:59 +00:00
|
|
|
j = getWidth(stat_device[i].cpu_stat[cpu_max],
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
stat_device[i].idle_stat[cpu_max]);
|
2011-12-16 10:01:43 +00:00
|
|
|
copyXPMArea(32, 70, j, 6, 28, 10);
|
|
|
|
} else {
|
|
|
|
int cpu;
|
|
|
|
for (cpu = 0; cpu < nb_cpu; cpu++) {
|
2014-10-05 15:29:59 +00:00
|
|
|
j = getWidth(stat_device[i].cpu_stat[cpu],
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
stat_device[i].idle_stat[cpu]);
|
2014-10-05 15:29:59 +00:00
|
|
|
copyXPMArea(32, 65, j,
|
|
|
|
MAX_CPU / nb_cpu, 28,
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
5 + (MAX_CPU / nb_cpu) * cpu);
|
2011-12-16 10:01:43 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-17 09:59:03 +00:00
|
|
|
} else {
|
2011-12-16 10:01:43 +00:00
|
|
|
j = getWidth(stat_device[i].rt_stat, stat_device[i].rt_idle);
|
|
|
|
copyXPMArea(32, 64, j, 12, 28, 4);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Nu zal ie wel 3 zijn. */
|
|
|
|
|
|
|
|
copyXPMArea(0, 64, 32, 12, 28+64, 4);
|
|
|
|
copyXPMArea(0, 64, 32, 12, 28+64, 18);
|
|
|
|
|
|
|
|
j = stat_device[2].rt_idle;
|
|
|
|
if (j != 0) {
|
|
|
|
j = (stat_device[2].rt_stat * 100) / j;
|
|
|
|
}
|
|
|
|
j = j * 0.32;
|
|
|
|
if (j > 32) j = 32;
|
|
|
|
copyXPMArea(32, 64, j, 12, 28+64, 4);
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2012-04-02 04:25:30 +00:00
|
|
|
/*--------------------- swap? ------------------*/
|
2011-12-16 09:59:10 +00:00
|
|
|
j = stat_device[3].rt_idle;
|
2012-06-17 09:59:03 +00:00
|
|
|
if (j != 0)
|
2011-12-16 09:59:10 +00:00
|
|
|
j = (stat_device[3].rt_stat * 100) / j;
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
j = j * 0.32;
|
|
|
|
if (j > 32) j = 32;
|
|
|
|
copyXPMArea(32, 64, j, 12, 28+64, 18);
|
|
|
|
|
|
|
|
/*----------- online tijd neerzetten! ----------*/
|
|
|
|
cnt_time = time(0) - ref_time + online_time;
|
|
|
|
|
|
|
|
/* cnt_time = uptime in seconden */
|
|
|
|
/*
|
|
|
|
secs = 108,47
|
|
|
|
mins = 89,47
|
|
|
|
uren = 70,47
|
|
|
|
digits = 40,78, 6breed, 9hoog
|
|
|
|
*/
|
|
|
|
i = cnt_time % 60;
|
|
|
|
cnt_time /= 60;
|
|
|
|
copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 115, 47);
|
|
|
|
copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 108, 47);
|
|
|
|
|
|
|
|
i = cnt_time % 60;
|
|
|
|
cnt_time /= 60;
|
|
|
|
copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 96, 47);
|
|
|
|
copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 89, 47);
|
|
|
|
|
|
|
|
i = cnt_time % 24;
|
|
|
|
cnt_time /= 24;
|
|
|
|
copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 77, 47);
|
|
|
|
copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 70, 47);
|
|
|
|
|
|
|
|
/* De rest is dagen! 5x7*/
|
|
|
|
i = cnt_time;
|
|
|
|
copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 88, 35);
|
|
|
|
i /= 10;
|
|
|
|
copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 82, 35);
|
|
|
|
i /= 10;
|
|
|
|
copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 76, 35);
|
|
|
|
i /= 10;
|
|
|
|
copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 70, 35);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curtime >= nexttime) {
|
|
|
|
nexttime+=10;
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
if (curtime > nexttime) /* dont let APM suspends make this crazy */
|
2012-06-17 09:59:03 +00:00
|
|
|
nexttime = curtime;
|
2011-12-16 10:01:43 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
for (i=0; i<stat_online; i++) {
|
2012-06-17 09:59:03 +00:00
|
|
|
stat_dev *sd = stat_device + i;
|
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (sd->his[HISTORY_ENTRIES-1])
|
|
|
|
sd->his[HISTORY_ENTRIES-1] /= sd->hisaddcnt;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
for (j = 1; j < HISTORY_ENTRIES; j++)
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
sd->his[j-1] = sd->his[j];
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
if (i == stat_current) {
|
2014-10-05 15:29:59 +00:00
|
|
|
if (i == 0)
|
2012-06-17 09:59:03 +00:00
|
|
|
DrawStats(sd->his, HISTORY_ENTRIES - 1, 40, 5, 58);
|
2014-10-05 15:29:59 +00:00
|
|
|
else if (i == 1)
|
2012-06-17 09:59:03 +00:00
|
|
|
DrawStats_io(sd->his, HISTORY_ENTRIES - 1, 40, 5, 58);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
sd->his[HISTORY_ENTRIES-1] = 0;
|
|
|
|
sd->hisaddcnt = 0;
|
2014-10-05 15:29:59 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RedrawWindowXY(xpm_X, xpm_Y);
|
2014-10-05 15:29:59 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
while (XPending(display)) {
|
|
|
|
XNextEvent(display, &Event);
|
|
|
|
switch (Event.type) {
|
|
|
|
case Expose:
|
|
|
|
RedrawWindowXY(xpm_X, xpm_Y);
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
XCloseDisplay(display);
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case ButtonPress:
|
|
|
|
but_stat = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
|
2013-12-05 00:11:59 +00:00
|
|
|
if (but_stat == i && but_stat >= 0) {
|
2011-12-16 09:59:10 +00:00
|
|
|
switch (but_stat) {
|
|
|
|
case 0:
|
|
|
|
switch (Event.xbutton.button) {
|
|
|
|
case 1:
|
|
|
|
if (left_action)
|
|
|
|
execCommand(left_action);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (middle_action)
|
|
|
|
execCommand(middle_action);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (right_action)
|
|
|
|
execCommand(right_action);
|
|
|
|
break;
|
|
|
|
}
|
2013-12-05 00:11:59 +00:00
|
|
|
break;
|
2011-12-16 09:59:10 +00:00
|
|
|
case 1:
|
2013-12-05 00:11:59 +00:00
|
|
|
if (mode_cycling) {
|
|
|
|
stat_current++;
|
|
|
|
if (stat_current == stat_online)
|
|
|
|
stat_current = 0;
|
|
|
|
|
|
|
|
DrawActive(stat_device[stat_current].name);
|
|
|
|
if (stat_current == 0)
|
|
|
|
DrawStats(stat_device[stat_current].his,
|
|
|
|
HISTORY_ENTRIES-1, 40, 5, 58);
|
|
|
|
|
|
|
|
if (stat_current == 1)
|
|
|
|
DrawStats_io(stat_device[stat_current].his,
|
|
|
|
HISTORY_ENTRIES-1, 40, 5, 58);
|
|
|
|
|
|
|
|
if (stat_current == 2) {
|
|
|
|
xpm_X = 64;
|
|
|
|
setMaskXY(-64, 0);
|
|
|
|
} else {
|
|
|
|
xpm_X = 0;
|
|
|
|
setMaskXY(0, 0);
|
|
|
|
}
|
|
|
|
RedrawWindowXY(xpm_X, xpm_Y);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
usleep(250000L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
void update_stat_cpu(stat_dev *st, ullong *istat2, ullong *idle2)
|
2012-06-17 09:59:03 +00:00
|
|
|
{
|
2017-08-12 19:06:38 +00:00
|
|
|
long k;
|
|
|
|
ullong istat, idle;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
get_statistics(st->name, &k, &istat, &idle, istat2, idle2);
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
st->rt_idle = ullsub(&idle, &st->idlelast);
|
2011-12-16 09:59:10 +00:00
|
|
|
st->idlelast = idle;
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
st->rt_stat = ullsub(&istat, &st->statlast);
|
2011-12-16 09:59:10 +00:00
|
|
|
st->statlast = istat;
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
if (nb_cpu > 1) {
|
|
|
|
int cpu;
|
|
|
|
unsigned long max, j;
|
|
|
|
cpu_max = 0; max = 0;
|
|
|
|
for (cpu = 0; cpu < nb_cpu; cpu++) {
|
2017-08-12 19:06:38 +00:00
|
|
|
st->idle_stat[cpu] = ullsub(&idle2[cpu], &st->idle_last[cpu]);
|
2011-12-16 10:01:43 +00:00
|
|
|
st->idle_last[cpu] = idle2[cpu];
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
st->cpu_stat[cpu] = ullsub(&istat2[cpu], &st->cpu_last[cpu]);
|
2011-12-16 10:01:43 +00:00
|
|
|
st->cpu_last[cpu] = istat2[cpu];
|
|
|
|
|
|
|
|
j = st->cpu_stat[cpu] + st->idle_stat[cpu];
|
2012-06-17 09:59:03 +00:00
|
|
|
|
|
|
|
if (j != 0)
|
|
|
|
j = (st->cpu_stat[cpu] << 7) / j;
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
if (j > max) {
|
|
|
|
max = j;
|
|
|
|
cpu_max = cpu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
st->his[HISTORY_ENTRIES-1] += k;
|
2011-12-16 09:59:10 +00:00
|
|
|
st->hisaddcnt += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
void update_stat_io(stat_dev *st)
|
|
|
|
{
|
2017-08-12 19:06:38 +00:00
|
|
|
long j, k;
|
|
|
|
ullong istat, idle;
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
|
|
|
|
/* Periodically re-sample. Sometimes we get anomalously high readings;
|
|
|
|
* this discards them. */
|
|
|
|
static int stalemax = 300;
|
2012-06-17 09:59:03 +00:00
|
|
|
static long maxdiskio = 0;
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (--stalemax <= 0) {
|
|
|
|
maxdiskio = 0;
|
|
|
|
stalemax = 300;
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
get_statistics(st->name, &k, &istat, &idle, NULL, NULL);
|
2011-12-16 09:59:10 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
st->rt_idle = ullsub(&idle, &st->idlelast);
|
2011-12-16 09:59:10 +00:00
|
|
|
st->idlelast = idle;
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
st->rt_stat = ullsub(&istat, &st->statlast);
|
2011-12-16 09:59:10 +00:00
|
|
|
st->statlast = istat;
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
/* remember peak for scaling of upper-right meter. */
|
2011-12-16 09:59:10 +00:00
|
|
|
j = st->rt_stat;
|
2012-06-17 09:59:03 +00:00
|
|
|
if (maxdiskio < j)
|
2011-12-16 09:59:10 +00:00
|
|
|
maxdiskio = j;
|
2012-06-17 09:59:03 +00:00
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
/* Calculate scaling factor for upper-right meter. "/ 5" will clip
|
|
|
|
* the highest peaks, but makes moderate values more visible. We are
|
|
|
|
* compensating for wild fluctuations which are probably caused by
|
|
|
|
* kernel I/O buffering.
|
|
|
|
*/
|
|
|
|
st->rt_idle = (maxdiskio - j) / 5;
|
|
|
|
if (j > 0 && st->rt_idle < 1)
|
|
|
|
st->rt_idle = 1; /* scale up tiny values so they are visible */
|
2011-12-16 09:59:10 +00:00
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
st->his[HISTORY_ENTRIES-1] += st->rt_stat;
|
2011-12-16 09:59:10 +00:00
|
|
|
st->hisaddcnt += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
void update_stat_mem(stat_dev *st, stat_dev *st2)
|
|
|
|
{
|
2011-12-16 10:01:43 +00:00
|
|
|
static char *line = NULL;
|
|
|
|
static size_t line_size = 0;
|
|
|
|
|
|
|
|
unsigned long swapfree;
|
2011-12-16 09:59:10 +00:00
|
|
|
unsigned long free, shared, buffers, cached;
|
|
|
|
|
2012-04-01 23:58:33 +00:00
|
|
|
if (freopen("/proc/meminfo", "r", fp_meminfo) == NULL)
|
|
|
|
perror("freopen() of /proc/meminfo failed!)\n");
|
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
while ((getline(&line, &line_size, fp_meminfo)) > 0) {
|
|
|
|
/* The original format for the first two lines of /proc/meminfo was
|
|
|
|
* Mem: total used free shared buffers cached
|
|
|
|
* Swap: total used free
|
|
|
|
*
|
|
|
|
* As of at least 2.5.47 these two lines were removed, so that the
|
|
|
|
* required information has to come from the rest of the lines.
|
|
|
|
* On top of that, used is no longer recorded - you have to work
|
|
|
|
* this out yourself, from total - free.
|
|
|
|
*
|
|
|
|
* So, these changes below should work. They should also work with
|
|
|
|
* older kernels, too, since the new format has been available for
|
|
|
|
* ages.
|
|
|
|
*/
|
2012-06-17 09:59:03 +00:00
|
|
|
if (strstr(line, "MemTotal:"))
|
2011-12-16 10:01:43 +00:00
|
|
|
sscanf(line, "MemTotal: %ld", &st->rt_idle);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "MemFree:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "MemFree: %lu", &free);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "MemShared:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "MemShared: %lu", &shared);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "Buffers:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "Buffers: %lu", &buffers);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "Cached:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "Cached: %lu", &cached);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "SwapTotal:"))
|
2011-12-16 10:01:43 +00:00
|
|
|
sscanf(line, "SwapTotal: %ld", &st2->rt_idle);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "SwapFree:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "SwapFree: %lu", &swapfree);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2011-12-16 10:01:43 +00:00
|
|
|
|
|
|
|
/* memory use - rt_stat is the amount used, it seems, and this isn't
|
|
|
|
* recorded in current version of /proc/meminfo (as of 2.5.47), so we
|
|
|
|
* calculate it from MemTotal - MemFree
|
|
|
|
*/
|
|
|
|
st->rt_stat = st->rt_idle - free;
|
2012-04-02 04:25:30 +00:00
|
|
|
|
|
|
|
/* wbk -b flag (from Gentoo patchkit) */
|
|
|
|
if (!show_buffers)
|
|
|
|
st->rt_stat -= buffers+cached;
|
2011-12-16 10:01:43 +00:00
|
|
|
/* As with the amount of memory used, it's not recorded any more, so
|
|
|
|
* we have to calculate it ourselves.
|
|
|
|
*/
|
|
|
|
st2->rt_stat = st2->rt_idle - swapfree;
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
void update_stat_swp(stat_dev *st)
|
|
|
|
{
|
2011-12-16 10:01:43 +00:00
|
|
|
static char *line = NULL;
|
|
|
|
static size_t line_size = 0;
|
|
|
|
unsigned long swapfree;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
fseek(fp_meminfo, 0, SEEK_SET);
|
2011-12-16 10:01:43 +00:00
|
|
|
while ((getline(&line, &line_size, fp_meminfo)) > 0) {
|
|
|
|
/* As with update_stat_mem(), the format change to /proc/meminfo has
|
|
|
|
* forced some changes here. */
|
2012-06-17 09:59:03 +00:00
|
|
|
if (strstr(line, "SwapTotal:"))
|
2011-12-16 10:01:43 +00:00
|
|
|
sscanf(line, "SwapTotal: %ld", &st->rt_idle);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (strstr(line, "SwapFree:"))
|
2017-08-12 19:06:37 +00:00
|
|
|
sscanf(line, "SwapFree: %lu", &swapfree);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2011-12-16 10:01:43 +00:00
|
|
|
st->rt_stat = st->rt_idle - swapfree;
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* get_statistics *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
2017-08-12 19:06:38 +00:00
|
|
|
void get_statistics(char *devname, long *is, ullong *ds, ullong *idle, ullong *ds2, ullong *idle2)
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
{
|
2012-06-17 09:59:03 +00:00
|
|
|
int i;
|
2011-12-16 10:01:43 +00:00
|
|
|
static char *line = NULL;
|
|
|
|
static size_t line_size = 0;
|
2012-06-17 09:59:03 +00:00
|
|
|
char *p;
|
|
|
|
char *tokens = " \t\n";
|
|
|
|
float f;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullong ulltmp;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
*is = 0;
|
2017-08-12 19:06:38 +00:00
|
|
|
ullreset(ds);
|
|
|
|
ullreset(idle);
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
if (!strncmp(devname, "cpu", 3)) {
|
|
|
|
fseek(fp_stat, 0, SEEK_SET);
|
2011-12-16 10:01:43 +00:00
|
|
|
while ((getline(&line, &line_size, fp_stat)) > 0) {
|
|
|
|
if (strstr(line, "cpu")) {
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
int cpu = -1; /* by default, cumul stats => average */
|
2011-12-16 10:01:43 +00:00
|
|
|
if (!strstr(line, "cpu ")) {
|
|
|
|
sscanf(line, "cpu%d", &cpu);
|
2017-08-12 19:06:38 +00:00
|
|
|
ullreset(&ds2[cpu]);
|
|
|
|
ullreset(&idle2[cpu]);
|
2011-12-16 10:01:43 +00:00
|
|
|
}
|
|
|
|
p = strtok(line, tokens);
|
2011-12-16 09:59:10 +00:00
|
|
|
/* 1..3, 4 == idle, we don't want idle! */
|
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
p = strtok(NULL, tokens);
|
2017-08-12 19:06:38 +00:00
|
|
|
ullparse(&ulltmp, p);
|
2011-12-16 10:01:43 +00:00
|
|
|
if (cpu == -1)
|
2017-08-12 19:06:38 +00:00
|
|
|
ulladd(ds, &ulltmp);
|
2011-12-16 10:01:43 +00:00
|
|
|
else
|
2017-08-12 19:06:38 +00:00
|
|
|
ulladd(&ds2[cpu], &ulltmp);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
p = strtok(NULL, tokens);
|
2011-12-16 10:01:43 +00:00
|
|
|
if (cpu == -1)
|
2017-08-12 19:06:38 +00:00
|
|
|
ullparse(idle, p);
|
2011-12-16 10:01:43 +00:00
|
|
|
else
|
2017-08-12 19:06:38 +00:00
|
|
|
ullparse(&idle2[cpu], p);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
}
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if ((fp_loadavg = freopen("/proc/loadavg", "r", fp_loadavg)) == NULL)
|
|
|
|
perror("ger_statistics(): freopen(proc/loadavg) failed!\n");
|
|
|
|
|
2012-04-01 23:58:33 +00:00
|
|
|
if (fscanf(fp_loadavg, "%f", &f) == EOF)
|
|
|
|
perror("fscanf() failed to read f\n");
|
2011-12-16 09:59:10 +00:00
|
|
|
*is = (long) (100 * f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strncmp(devname, "i/o", 3)) {
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (fseek(fp_diskstats, 0, SEEK_SET) == -1)
|
|
|
|
perror("get_statistics() seek failed\n");
|
|
|
|
|
|
|
|
/* wbk 20120308 These are no longer in /proc/stat. /proc/diskstats
|
2014-10-05 15:29:59 +00:00
|
|
|
* seems to be the closest replacement. Under modern BSD's, /proc is
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
* now deprecated, so iostat() might be the answer.
|
|
|
|
* http://www.gossamer-threads.com/lists/linux/kernel/314618
|
|
|
|
* has good info on this being removed from kernel. Also see
|
|
|
|
* kernel sources Documentation/iostats.txt
|
|
|
|
*
|
2014-10-05 15:29:59 +00:00
|
|
|
* TODO: We will end up with doubled values. We are adding the
|
|
|
|
* aggregate to the individual partition, due to device selection
|
|
|
|
* logic. Either grab devices' stats with numbers, or without (sda
|
|
|
|
* OR sda[1..10]. Could use strstr() return plus offset, but would
|
|
|
|
* have to be careful with bounds checking since we're in a
|
|
|
|
* limited buffer. Or just divide by 2 (inefficient). Shouldn't
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
* matter for graphing (we care about proportions, not numbers). */
|
|
|
|
while ((getline(&line, &line_size, fp_diskstats)) > 0) {
|
|
|
|
if (strstr(line, "sd") || strstr(line, "sr")) {
|
2011-12-16 10:01:43 +00:00
|
|
|
p = strtok(line, tokens);
|
2014-10-05 15:29:59 +00:00
|
|
|
/* skip 3 tokens, then use fields from
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
`* linux/Documentation/iostats.txt */
|
|
|
|
for (i = 1; i <= 6; i++)
|
2011-12-16 09:59:10 +00:00
|
|
|
p = strtok(NULL, tokens);
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
ullparse(&ulltmp, p);
|
|
|
|
ulladd(ds, &ulltmp);
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
for (i = 7; i <= 10; i++)
|
|
|
|
p = strtok(NULL, tokens);
|
|
|
|
|
2017-08-12 19:06:38 +00:00
|
|
|
ullparse(&ulltmp, p);
|
|
|
|
ulladd(ds, &ulltmp);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2012-06-17 09:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* getWidth *|
|
2011-12-16 10:01:43 +00:00
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
unsigned long getWidth(long actif, long idle)
|
|
|
|
{
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
/* wbk - work with a decimal value so we don't round < 1 down to zero. */
|
|
|
|
double j = 0;
|
|
|
|
unsigned long r = 0;
|
2011-12-16 10:01:43 +00:00
|
|
|
|
|
|
|
j = (actif + idle);
|
2012-06-17 09:59:03 +00:00
|
|
|
if (j != 0)
|
2011-12-16 10:01:43 +00:00
|
|
|
j = (actif * 100) / j;
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 10:01:43 +00:00
|
|
|
j = j * 0.32;
|
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
/* round up very low positive values so they are visible. */
|
|
|
|
if (actif > 0 && j < 2)
|
2012-06-17 09:59:03 +00:00
|
|
|
j = 2;
|
|
|
|
|
2014-10-05 15:29:59 +00:00
|
|
|
if (j > 32)
|
2012-06-17 09:59:03 +00:00
|
|
|
j = 32;
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
r = (unsigned long) j;
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
return r;
|
2011-12-16 10:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* getNbCPU *|
|
2011-12-16 10:01:43 +00:00
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
int getNbCPU(void)
|
|
|
|
{
|
2011-12-16 10:01:43 +00:00
|
|
|
static char *line = NULL;
|
|
|
|
static size_t line_size = 0;
|
|
|
|
int cpu = 0;
|
|
|
|
|
|
|
|
fseek(fp_stat, 0, SEEK_SET);
|
|
|
|
while ((getline(&line, &line_size, fp_stat)) > 0) {
|
|
|
|
if (strstr(line, "cpu") && !strstr(line, "cpu "))
|
|
|
|
sscanf(line, "cpu%d", &cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cpu+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* checksysdevs *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
|
|
|
int checksysdevs(void) {
|
|
|
|
strcpy(stat_device[0].name, "cpu0");
|
|
|
|
strcpy(stat_device[1].name, "i/o");
|
|
|
|
strcpy(stat_device[2].name, "sys");
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* void DrawActive(char *) *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
void DrawActive(char *name)
|
|
|
|
{
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
/* Alles op X,77
|
|
|
|
CPU: 0
|
|
|
|
I/O: 21
|
|
|
|
|
|
|
|
20 Breed, 10 hoog
|
|
|
|
Destinatie: 5,5
|
|
|
|
*/
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
if (name[0] == 'c')
|
2011-12-16 09:59:10 +00:00
|
|
|
copyXPMArea(0, 77, 19, 10, 5, 5);
|
2012-06-17 09:59:03 +00:00
|
|
|
else if (name[0] == 'i')
|
2011-12-16 09:59:10 +00:00
|
|
|
copyXPMArea(19, 77, 19, 10, 5, 5);
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/*******************************************************************************\
|
|
|
|
|* DrawStats *|
|
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
void DrawStats(int *his, int num, int size, int x_left, int y_bottom)
|
|
|
|
{
|
2018-04-10 22:05:12 +00:00
|
|
|
int pixels_per_byte, j, k, *p, d, hint_height, hint_color;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
pixels_per_byte = 100;
|
|
|
|
p = his;
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
for (j=0; j<num; j++) {
|
2018-04-10 20:14:19 +00:00
|
|
|
while (p[0] > pixels_per_byte)
|
2011-12-16 09:59:10 +00:00
|
|
|
pixels_per_byte += 100;
|
|
|
|
p += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = his;
|
|
|
|
|
|
|
|
for (k=0; k<num; k++) {
|
|
|
|
d = (1.0 * p[0] / pixels_per_byte) * size;
|
|
|
|
|
|
|
|
for (j=0; j<size; j++) {
|
|
|
|
if (j < d - 3)
|
|
|
|
copyXPMArea(2, 88, 1, 1, k+x_left, y_bottom-j);
|
|
|
|
else if (j < d)
|
|
|
|
copyXPMArea(2, 89, 1, 1, k+x_left, y_bottom-j);
|
|
|
|
else
|
|
|
|
copyXPMArea(2, 90, 1, 1, k+x_left, y_bottom-j);
|
|
|
|
}
|
|
|
|
p += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Nu horizontaal op 100/200/300 etc lijntje trekken! */
|
2018-04-10 22:05:12 +00:00
|
|
|
if (pixels_per_byte > 10000) {
|
|
|
|
hint_height = 10000;
|
|
|
|
hint_color = 93; /* red */
|
|
|
|
} else if (pixels_per_byte > 1000) {
|
|
|
|
hint_height = 1000;
|
|
|
|
hint_color = 92; /* yellow */
|
|
|
|
} else {
|
|
|
|
hint_height = 100;
|
|
|
|
hint_color = 91; /* green */
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = hint_height; j < pixels_per_byte; j += hint_height) {
|
|
|
|
d = (40.0 / pixels_per_byte) * j - 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
for (k=0; k<num; k++) {
|
2018-04-10 22:05:12 +00:00
|
|
|
copyXPMArea(2, hint_color, 1, 1, k+x_left, y_bottom-d);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/*******************************************************************************\
|
|
|
|
|* DrawStats_io *|
|
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
void DrawStats_io(int *his, int num, int size, int x_left, int y_bottom)
|
|
|
|
{
|
2011-12-16 09:59:10 +00:00
|
|
|
float pixels_per_byte;
|
2012-06-17 09:59:03 +00:00
|
|
|
int j, k, *p;
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
/* wbk - Use a double to avoid rounding values of d < 1 to zero. */
|
|
|
|
double d = 0;
|
|
|
|
int border = 3;
|
|
|
|
|
|
|
|
/* wbk - this should not be static. No need to track the scale, since
|
|
|
|
* we always calculate it on the fly anyway. This static variable did
|
2014-10-05 15:29:59 +00:00
|
|
|
* not get re-initialized when we entered this function, so the scale
|
|
|
|
* would always grow and never shrink.
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
*/
|
|
|
|
/*static int global_io_scale = 1;*/
|
|
|
|
int io_scale = 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
p = his;
|
2012-06-17 09:59:03 +00:00
|
|
|
for (j=0; j<num; j++)
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (p[j] > io_scale) io_scale = p[j];
|
2011-12-16 09:59:10 +00:00
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
pixels_per_byte = 1.0 * io_scale / size;
|
2012-06-17 09:59:03 +00:00
|
|
|
if (pixels_per_byte == 0)
|
|
|
|
pixels_per_byte = 1;
|
2011-12-16 09:59:10 +00:00
|
|
|
|
|
|
|
for (k=0; k<num; k++) {
|
|
|
|
d = (1.0 * p[0] / pixels_per_byte);
|
|
|
|
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
/* graph values too low for graph resolution */
|
|
|
|
if (d > 0 && d < 1) {
|
|
|
|
d = 3;
|
|
|
|
border = 2;
|
|
|
|
} else {
|
|
|
|
border = 3;
|
|
|
|
}
|
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
for (j=0; j<size; j++) {
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
if (j < d - border)
|
2011-12-16 09:59:10 +00:00
|
|
|
copyXPMArea(2, 88, 1, 1, k+x_left, y_bottom-j);
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
else if (j < d )
|
2011-12-16 09:59:10 +00:00
|
|
|
copyXPMArea(2, 89, 1, 1, k+x_left, y_bottom-j);
|
|
|
|
else
|
|
|
|
copyXPMArea(2, 90, 1, 1, k+x_left, y_bottom-j);
|
|
|
|
}
|
wmmon I/O monitor bug fixes:
wmmon/CHANGES:
Updated for 1.2b1.
wmmon/Makefile:
Added debug build with -g3; default build with -O3. Note:
This makefile isn't perfect. You must "make clean" when switching
between "make" and "make debug" otherwise objects won't compile.
I'm sure it's a simple dependency issue, but I am not an expert with
Makefiles. I intend to fix this, but it's a low priority.
wmmon/wmmon/wmmon.c:
Updated changelog. Added #define HISTORY_ENTRIES to replace hardcoded
values.
DrawStats_io():
Removed static variable global_io_scale. Replaced with a local
variable. This should improve graphing - scale was growing, but
never shrinking, meaning as time passed, graphed values were
downscaled and not displayed.
Fixed rounding errors caused by use of integer types which were
causing very small values not to appear on graph. Added code to
round very low values up, so they will appear on meter and graph.
We are making a reasonable compromise between readability and
accuracy. Side effect is that small peaks (greater than 0 but less
than our rounded-up tiny values) will actually appear as dips
instead of peaks. I feel this is acceptable, since it still conveys
an impression of "jitter" to the user. Fixing this would have
involved further modifying the data before we graph it, which would
defeat the purpose of improving accuracy.
Tweaked load bar scaling algorithm for reabality and sensitivity.
update_stat_io():
Added a "stale" timeout for static long maxdiskio (determines
scaling of load bar). New behaviour is that every couple of minutes
we discard our saved peak value and resample. This prevents an
anomalously huge I/O spike from making more typical values fail to
trigger the load bar for the rest of the app's lifetime. Side
effect will be that every couple of minutes, we will get an
anomalous spike in the load bar as it recalibrates. This anomaly
only affects the bar, not the graph.
getWidth():
Fixed integer rounding issue similar to that in DrawStats_io().
Added similar rounding code to round up very small values so we
don't have the illusion of an idle system following a huge spike.
2012-03-10 20:37:32 +00:00
|
|
|
p += 1; /* beware... */
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* usage *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
void usage(char *name)
|
|
|
|
{
|
2011-12-16 10:01:43 +00:00
|
|
|
printf("Usage: %s [OPTION]...\n", name);
|
|
|
|
printf("WindowMaker dockapp that displays system information.\n");
|
|
|
|
printf("\n");
|
|
|
|
printf(" -display DISPLAY contact the DISPLAY X server\n");
|
|
|
|
printf(" -geometry GEOMETRY position the clock at GEOMETRY\n");
|
|
|
|
printf(" -l locked view - cannot cycle modes\n");
|
|
|
|
printf(" -c show average and max CPU for SMP machine.\n");
|
|
|
|
printf(" default if there is more than %d processors\n", MAX_CPU);
|
|
|
|
printf(" -i start in Disk I/O mode\n");
|
|
|
|
printf(" -s start in System Info mode\n");
|
2012-04-02 04:25:30 +00:00
|
|
|
printf(" -b include buffers and cache in memory usage\n");
|
2011-12-16 10:01:43 +00:00
|
|
|
printf(" -h display this help and exit\n");
|
|
|
|
printf(" -v output version information and exit\n");
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 09:59:03 +00:00
|
|
|
|
2011-12-16 09:59:10 +00:00
|
|
|
/*******************************************************************************\
|
2012-06-17 09:59:03 +00:00
|
|
|
|* printversion *|
|
2011-12-16 09:59:10 +00:00
|
|
|
\*******************************************************************************/
|
2012-06-17 09:59:03 +00:00
|
|
|
void printversion(void)
|
|
|
|
{
|
2017-08-12 19:06:34 +00:00
|
|
|
printf("WMMon version %s\n", PACKAGE_VERSION);
|
2011-12-16 09:59:10 +00:00
|
|
|
}
|
2011-12-16 10:01:43 +00:00
|
|
|
/* vim: sw=4 ts=4 columns=82
|
|
|
|
*/
|