wmifs: Make sampling and scrolling intervals customizable.
Patch by Peter Samuelson <peter@samba-tng.org>. First appeared in Debian package version 1.3b1-14. For more information, see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226689
This commit is contained in:
parent
49ecb83c8d
commit
279d4dee91
1 changed files with 32 additions and 11 deletions
|
@ -74,6 +74,9 @@
|
|||
----
|
||||
Changes:
|
||||
---
|
||||
01/08/2004 (Peter Samuelson, peter@samba-tng.org)
|
||||
* Patch to make make sampling and scrolling intervals
|
||||
customizable, adds new options -I and -s.
|
||||
01/15/2002 (Matyas Koszik, koszik@debijan.lonyay.edu.hu)
|
||||
* Patch that fixes segfaults on long interface names.
|
||||
08/31/2001 (Davi Leal, davileal@terra.es)
|
||||
|
@ -183,6 +186,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/xpm.h>
|
||||
|
@ -197,8 +201,11 @@
|
|||
#include "wmifs-master.xpm"
|
||||
#include "wmifs-mask.xbm"
|
||||
|
||||
/* How often to check for new network interface, in seconds */
|
||||
#define CHECK_INTERFACE_INTERVAL 5
|
||||
/* How often to check for new network interface, in ms */
|
||||
#define CHECK_INTERFACE_INTERVAL 5000
|
||||
|
||||
/* How often to query the interfaces, in ms */
|
||||
#define DEFAULT_SAMPLE_INTERVAL 50
|
||||
|
||||
/***********/
|
||||
/* Defines */
|
||||
|
@ -234,6 +241,8 @@ char *active_interface = NULL;
|
|||
int TimerDivisor=60;
|
||||
int WaveForm=0;
|
||||
int LockMode=0;
|
||||
int SampleInt = DEFAULT_SAMPLE_INTERVAL;
|
||||
int ScrollSpeed = CHECK_INTERFACE_INTERVAL;
|
||||
|
||||
/*****************/
|
||||
/* PPP variables */
|
||||
|
@ -296,9 +305,17 @@ int main(int argc, char *argv[]) {
|
|||
active_interface = argv[i+1];
|
||||
i++;
|
||||
break;
|
||||
case 'I' :
|
||||
SampleInt = atof(argv[i+1]) * 1000;
|
||||
i++;
|
||||
break;
|
||||
case 'l' :
|
||||
LockMode = 1;
|
||||
break;
|
||||
case 's' :
|
||||
ScrollSpeed = atof(argv[i+1]) * 1000;
|
||||
i++;
|
||||
break;
|
||||
case 'v' :
|
||||
printversion();
|
||||
exit(0);
|
||||
|
@ -361,9 +378,9 @@ void wmifs_routine(int argc, char **argv) {
|
|||
int stat_online;
|
||||
int stat_current;
|
||||
|
||||
time_t starttime;
|
||||
time_t curtime;
|
||||
time_t nexttime;
|
||||
unsigned int curtime;
|
||||
unsigned int nexttime;
|
||||
struct timeval tv, tv2;
|
||||
|
||||
long ipacket, opacket, istat, ostat;
|
||||
|
||||
|
@ -410,8 +427,8 @@ void wmifs_routine(int argc, char **argv) {
|
|||
AddMouseRegion(0, 5, 5, 35, 15);
|
||||
AddMouseRegion(1, 5, 20, 58, 58);
|
||||
|
||||
starttime = time(0);
|
||||
nexttime = starttime + CHECK_INTERFACE_INTERVAL;
|
||||
gettimeofday(&tv2, NULL);
|
||||
nexttime = ScrollSpeed;
|
||||
|
||||
for (i=0; i<stat_online; i++) {
|
||||
get_statistics(stat_devices[i].name, &ipacket, &opacket, &istat, &ostat);
|
||||
|
@ -422,7 +439,10 @@ void wmifs_routine(int argc, char **argv) {
|
|||
DrawActiveIFS(stat_devices[stat_current].name);
|
||||
|
||||
while (1) {
|
||||
curtime = time(0);
|
||||
gettimeofday(&tv, NULL);
|
||||
curtime = (tv.tv_sec - tv2.tv_sec) * 1000
|
||||
+ (tv.tv_usec - tv2.tv_usec) / 1000;
|
||||
|
||||
waitpid(0, NULL, WNOHANG);
|
||||
|
||||
for (i=0; i<stat_online; i++) {
|
||||
|
@ -455,8 +475,7 @@ void wmifs_routine(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (curtime >= nexttime) {
|
||||
|
||||
nexttime=curtime+CHECK_INTERFACE_INTERVAL;
|
||||
nexttime=curtime+ScrollSpeed;
|
||||
|
||||
for (i=0; i<stat_online; i++) {
|
||||
if (i == stat_current) {
|
||||
|
@ -538,7 +557,7 @@ void wmifs_routine(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
usleep(50000L); /* 50 milliseconds */
|
||||
usleep(SampleInt * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -880,7 +899,9 @@ void usage(void) {
|
|||
fprintf(stderr, "\t-d <display name>\n");
|
||||
fprintf(stderr, "\t-h\tthis help screen\n");
|
||||
fprintf(stderr, "\t-i <interface name>\tdefault (as it appears in /proc/net/route)\n");
|
||||
fprintf(stderr, "\t-I <interval>\tsampling interval, in seconds (default: 0.05)\n");
|
||||
fprintf(stderr, "\t-l\tstarts in lock mode\n");
|
||||
fprintf(stderr, "\t-s <interval>\tscrolling interval, in seconds (default: 5)\n");
|
||||
fprintf(stderr, "\t-v\tprint the version number\n");
|
||||
fprintf(stderr, "\t-w\twaveform load\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
|
Loading…
Reference in a new issue