asmon: re-indent code
indent -linux asmon.c
This commit is contained in:
parent
deb3acc132
commit
e239e4a58d
|
@ -38,15 +38,14 @@
|
||||||
#define B_RED (1)
|
#define B_RED (1)
|
||||||
#define B_GREEN (2)
|
#define B_GREEN (2)
|
||||||
|
|
||||||
|
|
||||||
/* Evil globals I haven't removed yet */
|
/* Evil globals I haven't removed yet */
|
||||||
long last_pageins=0, last_pageouts=0;
|
long last_pageins = 0, last_pageouts = 0;
|
||||||
long last_swapins=0, last_swapouts=0;
|
long last_swapins = 0, last_swapouts = 0;
|
||||||
//double old;
|
//double old;
|
||||||
static int has_kern26 = 0;
|
static int has_kern26 = 0;
|
||||||
|
|
||||||
#ifdef EXEC_ON_CLICK
|
#ifdef EXEC_ON_CLICK
|
||||||
char Command[256]="";
|
char Command[256] = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
@ -75,8 +74,8 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
int allmem=1;
|
int allmem = 1;
|
||||||
int Xpid=1;
|
int Xpid = 1;
|
||||||
char *ProgName;
|
char *ProgName;
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
int kernMajor, kernMinor, kernRev;
|
int kernMajor, kernMinor, kernRev;
|
||||||
|
@ -86,37 +85,38 @@ int main(int argc, char *argv[])
|
||||||
if (strlen(ProgName) >= 5)
|
if (strlen(ProgName) >= 5)
|
||||||
ProgName += (strlen(ProgName) - 5);
|
ProgName += (strlen(ProgName) - 5);
|
||||||
|
|
||||||
for (i=1; i<argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
if (*arg=='-') {
|
if (*arg == '-') {
|
||||||
switch (arg[1]) {
|
switch (arg[1]) {
|
||||||
case 'd' :
|
case 'd':
|
||||||
if (strcmp(arg+1, "display")) {
|
if (strcmp(arg + 1, "display")) {
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef EXEC_ON_CLICK
|
#ifdef EXEC_ON_CLICK
|
||||||
case 'e' :
|
case 'e':
|
||||||
if ( argv[++i] ) {
|
if (argv[++i]) {
|
||||||
strncpy( Command, argv[i], 253);
|
strncpy(Command, argv[i], 253);
|
||||||
strcat( Command, " &");
|
strcat(Command, " &");
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'v' :
|
case 'v':
|
||||||
printversion();
|
printversion();
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case 'u' :
|
case 'u':
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
fprintf(stderr, "X Server memory stats unavailable for Solaris.\n");
|
fprintf(stderr,
|
||||||
exit(0);
|
"X Server memory stats unavailable for Solaris.\n");
|
||||||
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
Xpid=0;
|
Xpid = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -126,58 +126,61 @@ exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef __solaris__
|
#ifndef __solaris__
|
||||||
if ( Xpid != 0) {
|
if (Xpid != 0) {
|
||||||
if ( (fp = fopen("/var/run/server.0.pid", "r")) != NULL)
|
if ((fp = fopen("/var/run/server.0.pid", "r")) != NULL) {
|
||||||
{
|
|
||||||
fscanf(fp, " %d", &Xpid);
|
fscanf(fp, " %d", &Xpid);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
if ( (fp = fopen("/tmp/.X0-lock", "r")) != NULL)
|
if ((fp = fopen("/tmp/.X0-lock", "r")) != NULL) {
|
||||||
{
|
|
||||||
fscanf(fp, " %d", &Xpid);
|
fscanf(fp, " %d", &Xpid);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
Xpid=0;
|
Xpid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Open 64x64 window */
|
/* Open 64x64 window */
|
||||||
openXwindow(argc, argv, asmon_master_xpm, asmon_mask_bits, asmon_mask_width, asmon_mask_height);
|
openXwindow(argc, argv, asmon_master_xpm, asmon_mask_bits,
|
||||||
|
asmon_mask_width, asmon_mask_height);
|
||||||
|
|
||||||
if( uname( &name ) != -1 )
|
if (uname(&name) != -1) {
|
||||||
{
|
if (strcmp(name.sysname, "Linux") == 0) {
|
||||||
if( strcmp( name.sysname, "Linux" ) == 0 )
|
|
||||||
{
|
|
||||||
sscanf(name.release, "%d.%d.%d", &kernMajor, &kernMinor,
|
sscanf(name.release, "%d.%d.%d", &kernMajor, &kernMinor,
|
||||||
&kernRev);
|
&kernRev);
|
||||||
if(( kernMajor == 2 ) && ( kernMinor == 6 ))
|
if ((kernMajor == 2) && (kernMinor == 6))
|
||||||
has_kern26 = 1;
|
has_kern26 = 1;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't find system name\n");
|
fprintf(stderr, "Can't find system name\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
asmon_routine(Xpid, allmem);
|
asmon_routine(Xpid, allmem);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
void usage(void) {
|
void usage(void)
|
||||||
fprintf(stderr, "\nasmon %s - by Brad Hall (bkh@rio.vg)\n\t\toriginally based on Timecop's wmcpu\n\n", ASMON_VERSION);
|
{
|
||||||
fprintf(stderr, "The top bar: left is the CPU usage, right is the load average\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr, "The middle bar: left memory usage devided by ticks into shared, buffers, and\n\t\t cached, respectively, and the number of megs used\n");
|
"\nasmon %s - by Brad Hall (bkh@rio.vg)\n\t\toriginally based on Timecop's wmcpu\n\n",
|
||||||
fprintf(stderr, "The lower bar: the left swap usage and the number of megs swappedd avg\n");
|
ASMON_VERSION);
|
||||||
fprintf(stderr, "The bottom: the left is a set of LED's marking page's and swap's, the right is\n\t\t a bar representing the amount of memory that the X server \n\t\t is taking up, and the exact megs\n\n usage:\n");
|
fprintf(stderr,
|
||||||
|
"The top bar: left is the CPU usage, right is the load average\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"The middle bar: left memory usage devided by ticks into shared, buffers, and\n\t\t cached, respectively, and the number of megs used\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"The lower bar: the left swap usage and the number of megs swappedd avg\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"The bottom: the left is a set of LED's marking page's and swap's, the right is\n\t\t a bar representing the amount of memory that the X server \n\t\t is taking up, and the exact megs\n\n usage:\n");
|
||||||
fprintf(stderr, "\t-display <display name>\n");
|
fprintf(stderr, "\t-display <display name>\n");
|
||||||
fprintf(stderr, "\t-h\tthis screen\n");
|
fprintf(stderr, "\t-h\tthis screen\n");
|
||||||
fprintf(stderr, "\t-v\tprint the version number\n");
|
fprintf(stderr, "\t-v\tprint the version number\n");
|
||||||
#ifndef __solaris__
|
#ifndef __solaris__
|
||||||
fprintf(stderr, "\t-u\tforce asmon to show uptime, rather than X mem use\n");
|
fprintf(stderr,
|
||||||
|
"\t-u\tforce asmon to show uptime, rather than X mem use\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXEC_ON_CLICK
|
#ifdef EXEC_ON_CLICK
|
||||||
fprintf(stderr, "\t-e cmd\texecute 'cmd' on mouse click\n");
|
fprintf(stderr, "\t-e cmd\texecute 'cmd' on mouse click\n");
|
||||||
|
@ -196,29 +199,27 @@ void printversion(void)
|
||||||
|
|
||||||
void asmon_routine(int Xpid, int allmem)
|
void asmon_routine(int Xpid, int allmem)
|
||||||
{
|
{
|
||||||
int xpm_X=0, xpm_Y=0, count=0;
|
int xpm_X = 0, xpm_Y = 0, count = 0;
|
||||||
XEvent Event;
|
XEvent Event;
|
||||||
float total=0.0;
|
float total = 0.0;
|
||||||
|
|
||||||
while(1)
|
while (1) {
|
||||||
{
|
|
||||||
DrawCPU();
|
DrawCPU();
|
||||||
DrawLoad();
|
DrawLoad();
|
||||||
|
|
||||||
/* Only run every 15 iterations */
|
/* Only run every 15 iterations */
|
||||||
if ( count == 0 || count == 15)
|
if (count == 0 || count == 15)
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
total=DrawMemSwap();
|
total = DrawMemSwap();
|
||||||
#else
|
#else
|
||||||
total=DrawMemSwap(total, allmem);
|
total = DrawMemSwap(total, allmem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
DrawUptime();
|
DrawUptime();
|
||||||
#else
|
#else
|
||||||
/* X mem or Uptime? */
|
/* X mem or Uptime? */
|
||||||
if (Xpid == 0)
|
if (Xpid == 0) {
|
||||||
{
|
|
||||||
DrawUptime();
|
DrawUptime();
|
||||||
} else {
|
} else {
|
||||||
if (count == 5)
|
if (count == 5)
|
||||||
|
@ -228,17 +229,16 @@ void asmon_routine(int Xpid, int allmem)
|
||||||
|
|
||||||
/* Redraw Windows */
|
/* Redraw Windows */
|
||||||
RedrawWindowXY(xpm_X, xpm_Y);
|
RedrawWindowXY(xpm_X, xpm_Y);
|
||||||
while (XPending(display))
|
while (XPending(display)) {
|
||||||
{
|
|
||||||
XNextEvent(display, &Event);
|
XNextEvent(display, &Event);
|
||||||
switch (Event.type)
|
switch (Event.type) {
|
||||||
{
|
|
||||||
#ifdef EXEC_ON_CLICK
|
#ifdef EXEC_ON_CLICK
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr,"system(%s)\n",Command);
|
fprintf(stderr, "system(%s)\n", Command);
|
||||||
#endif
|
#endif
|
||||||
if (Command[ 0 ]) system(Command);
|
if (Command[0])
|
||||||
|
system(Command);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case Expose:
|
case Expose:
|
||||||
|
@ -257,23 +257,19 @@ void asmon_routine(int Xpid, int allmem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
|
|
||||||
/* CPU Usage Meter */
|
/* CPU Usage Meter */
|
||||||
void DrawCPU
|
void DrawCPU(void
|
||||||
(
|
) {
|
||||||
void
|
|
||||||
)
|
|
||||||
{
|
|
||||||
unsigned long cpuIdle, cpuUser, cpuKern, cpuWait;
|
unsigned long cpuIdle, cpuUser, cpuKern, cpuWait;
|
||||||
unsigned long pageIn, pageOut, swapIn, swapOut;
|
unsigned long pageIn, pageOut, swapIn, swapOut;
|
||||||
|
|
||||||
/* remember the statistics read last time */
|
/* remember the statistics read last time */
|
||||||
static float cpustat[4] = {0.0, 0.0, 0.0, 0.0};
|
static float cpustat[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||||
float fields[4] = {0.0, 0.0, 0.0, 0.0};
|
float fields[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||||
float cputotal = 0.0;
|
float cputotal = 0.0;
|
||||||
|
|
||||||
getCPU(&cpuIdle, &cpuUser, &cpuKern, &cpuWait,
|
getCPU(&cpuIdle, &cpuUser, &cpuKern, &cpuWait,
|
||||||
|
@ -297,35 +293,42 @@ void DrawCPU
|
||||||
cputotal += fields[3];
|
cputotal += fields[3];
|
||||||
|
|
||||||
// CPU Bar
|
// CPU Bar
|
||||||
if(cputotal > 0)
|
if (cputotal > 0) {
|
||||||
{
|
|
||||||
cputotal = ((cputotal - (fields[0] + fields[2])) * 1.55);
|
cputotal = ((cputotal - (fields[0] + fields[2])) * 1.55);
|
||||||
if (cputotal > 26) cputotal = 26;
|
if (cputotal > 26)
|
||||||
|
cputotal = 26;
|
||||||
copyXPMArea(3, 84, cputotal, 9, 5, 5);
|
copyXPMArea(3, 84, cputotal, 9, 5, 5);
|
||||||
copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal), 5);
|
copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal), 5);
|
||||||
copyXPMArea(16, 46, 2, 14, 32, 2);
|
copyXPMArea(16, 46, 2, 14, 32, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page In/Out
|
// Page In/Out
|
||||||
if (pageIn > last_pageins) DrawLite(B_RED, 5, 48);
|
if (pageIn > last_pageins)
|
||||||
else DrawLite(B_OFF, 5, 48);
|
DrawLite(B_RED, 5, 48);
|
||||||
|
else
|
||||||
|
DrawLite(B_OFF, 5, 48);
|
||||||
|
|
||||||
if (pageOut > last_pageouts) DrawLite(B_RED, 10, 48);
|
if (pageOut > last_pageouts)
|
||||||
else DrawLite(B_OFF, 10, 48);
|
DrawLite(B_RED, 10, 48);
|
||||||
|
else
|
||||||
|
DrawLite(B_OFF, 10, 48);
|
||||||
|
|
||||||
last_pageins = pageIn;
|
last_pageins = pageIn;
|
||||||
last_pageouts = pageOut;
|
last_pageouts = pageOut;
|
||||||
|
|
||||||
// Swap In/Out
|
// Swap In/Out
|
||||||
if (swapIn > last_swapins) DrawLite(B_RED, 5, 53);
|
if (swapIn > last_swapins)
|
||||||
else DrawLite(B_OFF, 5, 53);
|
DrawLite(B_RED, 5, 53);
|
||||||
|
else
|
||||||
|
DrawLite(B_OFF, 5, 53);
|
||||||
|
|
||||||
if (swapOut > last_swapouts) DrawLite(B_RED, 10, 53);
|
if (swapOut > last_swapouts)
|
||||||
else DrawLite(B_OFF, 10, 53);
|
DrawLite(B_RED, 10, 53);
|
||||||
|
else
|
||||||
|
DrawLite(B_OFF, 10, 53);
|
||||||
|
|
||||||
last_swapins = swapIn;
|
last_swapins = swapIn;
|
||||||
last_swapouts = swapOut;
|
last_swapouts = swapOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -335,69 +338,68 @@ void DrawCPU(void)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
static double cpustat[7]; /* remember the statistics read last time */
|
static double cpustat[7]; /* remember the statistics read last time */
|
||||||
//double fields[7], info[7], cputotal=0.0,idlee=0.0;
|
//double fields[7], info[7], cputotal=0.0,idlee=0.0;
|
||||||
double fields[7], info[7], cputotal=0.0;
|
double fields[7], info[7], cputotal = 0.0;
|
||||||
long pageins=0, pageouts=0, swapins=0, swapouts=0 ;
|
long pageins = 0, pageouts = 0, swapins = 0, swapouts = 0;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( (fp = fopen("/proc/stat", "r")) != NULL)
|
if ((fp = fopen("/proc/stat", "r")) != NULL) {
|
||||||
{
|
if (has_kern26 > 0) {
|
||||||
if( has_kern26 > 0 )
|
|
||||||
{
|
|
||||||
// CPU data
|
// CPU data
|
||||||
fscanf(fp, "cpu %lf %lf %lf %lf %lf %lf %lf", info, info+1,
|
fscanf(fp, "cpu %lf %lf %lf %lf %lf %lf %lf", info,
|
||||||
info+2, info+3, info+4, info+5, info+6);
|
info + 1, info + 2, info + 3, info + 4, info + 5,
|
||||||
|
info + 6);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if( (fp = fopen("/proc/vmstat", "r")) != NULL)
|
if ((fp = fopen("/proc/vmstat", "r")) != NULL) {
|
||||||
{
|
|
||||||
// gather data for LED's
|
// gather data for LED's
|
||||||
while( fgets(buf, 127, fp) )
|
while (fgets(buf, 127, fp)) {
|
||||||
{
|
|
||||||
if (strstr(buf, "pgpgin"))
|
if (strstr(buf, "pgpgin"))
|
||||||
sscanf(buf, "pgpgin %ld", &pageins);
|
sscanf(buf, "pgpgin %ld",
|
||||||
|
&pageins);
|
||||||
|
|
||||||
if (strstr(buf, "pgpgout"))
|
if (strstr(buf, "pgpgout"))
|
||||||
sscanf(buf, "pgpgout %ld", &pageouts);
|
sscanf(buf, "pgpgout %ld",
|
||||||
|
&pageouts);
|
||||||
|
|
||||||
if (strstr(buf, "pswpin"))
|
if (strstr(buf, "pswpin"))
|
||||||
sscanf(buf, "pswpin %ld", &swapins);
|
sscanf(buf, "pswpin %ld",
|
||||||
|
&swapins);
|
||||||
|
|
||||||
if (strstr(buf, "pswpout"))
|
if (strstr(buf, "pswpout"))
|
||||||
sscanf(buf, "pswpout %ld", &swapouts);
|
sscanf(buf, "pswpout %ld",
|
||||||
|
&swapouts);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// CPU data
|
// CPU data
|
||||||
fscanf(fp, "cpu %lf %lf %lf %lf", info, info+1, info+2,
|
fscanf(fp, "cpu %lf %lf %lf %lf", info, info + 1,
|
||||||
info+3);
|
info + 2, info + 3);
|
||||||
|
|
||||||
// gather data for LED's
|
// gather data for LED's
|
||||||
while( fgets(buf, 127, fp) )
|
while (fgets(buf, 127, fp)) {
|
||||||
{
|
|
||||||
if (strstr(buf, "page"))
|
if (strstr(buf, "page"))
|
||||||
sscanf(buf, "page %ld %ld", &pageins, &pageouts);
|
sscanf(buf, "page %ld %ld", &pageins,
|
||||||
|
&pageouts);
|
||||||
|
|
||||||
if (strstr(buf, "swap"))
|
if (strstr(buf, "swap"))
|
||||||
sscanf(buf, "swap %ld %ld", &swapins, &swapouts);
|
sscanf(buf, "swap %ld %ld", &swapins,
|
||||||
|
&swapouts);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate CPU stuff
|
// Calculate CPU stuff
|
||||||
if( has_kern26 > 0 )
|
if (has_kern26 > 0) {
|
||||||
{
|
for (i = 0; i < 7; i++) {
|
||||||
for(i = 0; i < 7; i++)
|
|
||||||
{
|
|
||||||
fields[i] = info[i] - cpustat[i];
|
fields[i] = info[i] - cpustat[i];
|
||||||
cputotal += fields[i];
|
cputotal += fields[i];
|
||||||
cpustat[i] = info[i];
|
cpustat[i] = info[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++) {
|
||||||
{
|
|
||||||
fields[i] = info[i] - cpustat[i];
|
fields[i] = info[i] - cpustat[i];
|
||||||
cputotal += fields[i];
|
cputotal += fields[i];
|
||||||
cpustat[i] = info[i];
|
cpustat[i] = info[i];
|
||||||
|
@ -411,25 +413,23 @@ void DrawCPU(void)
|
||||||
|
|
||||||
//cputotal = 100 * l1 ;
|
//cputotal = 100 * l1 ;
|
||||||
//cputotal=(100-(idlee*100/16))*26/100;
|
//cputotal=(100-(idlee*100/16))*26/100;
|
||||||
if(cputotal > 0)
|
if (cputotal > 0) {
|
||||||
{
|
cputotal = (cputotal - (fields[3] + fields[4])) * 1.55;
|
||||||
cputotal = (cputotal-(fields[3]+fields[4]))*1.55;
|
if (cputotal > 26)
|
||||||
if ( cputotal > 26 ) cputotal = 26;
|
cputotal = 26;
|
||||||
copyXPMArea(3,84,cputotal,9,5,5);
|
copyXPMArea(3, 84, cputotal, 9, 5, 5);
|
||||||
copyXPMArea(15,105,(27-cputotal),9,(5+cputotal),5);
|
copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal),
|
||||||
copyXPMArea(16,46,2,14,32,2);
|
5);
|
||||||
|
copyXPMArea(16, 46, 2, 14, 32, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page In/Out
|
// Page In/Out
|
||||||
if (pageins > last_pageins)
|
if (pageins > last_pageins) {
|
||||||
{
|
|
||||||
DrawLite(B_RED, 5, 48);
|
DrawLite(B_RED, 5, 48);
|
||||||
} else {
|
} else {
|
||||||
DrawLite(B_OFF, 5, 48);
|
DrawLite(B_OFF, 5, 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageouts > last_pageouts)
|
if (pageouts > last_pageouts) {
|
||||||
{
|
|
||||||
DrawLite(B_RED, 10, 48);
|
DrawLite(B_RED, 10, 48);
|
||||||
} else {
|
} else {
|
||||||
DrawLite(B_OFF, 10, 48);
|
DrawLite(B_OFF, 10, 48);
|
||||||
|
@ -438,15 +438,13 @@ void DrawCPU(void)
|
||||||
last_pageouts = pageouts;
|
last_pageouts = pageouts;
|
||||||
|
|
||||||
// Swap In/Out
|
// Swap In/Out
|
||||||
if (swapins > last_swapins)
|
if (swapins > last_swapins) {
|
||||||
{
|
|
||||||
DrawLite(B_RED, 5, 53);
|
DrawLite(B_RED, 5, 53);
|
||||||
} else {
|
} else {
|
||||||
DrawLite(B_OFF, 5, 53);
|
DrawLite(B_OFF, 5, 53);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swapouts > last_swapouts)
|
if (swapouts > last_swapouts) {
|
||||||
{
|
|
||||||
DrawLite(B_RED, 10, 53);
|
DrawLite(B_RED, 10, 53);
|
||||||
} else {
|
} else {
|
||||||
DrawLite(B_OFF, 10, 53);
|
DrawLite(B_OFF, 10, 53);
|
||||||
|
@ -468,32 +466,28 @@ void DrawLoad(void)
|
||||||
float ftmp;
|
float ftmp;
|
||||||
|
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
if (getLoad(&ftmp) != -1)
|
if (getLoad(&ftmp) != -1) {
|
||||||
{
|
|
||||||
#else
|
#else
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if( (fp = fopen("/proc/loadavg", "r")) != NULL)
|
if ((fp = fopen("/proc/loadavg", "r")) != NULL) {
|
||||||
{
|
|
||||||
fscanf(fp, "%f", &ftmp);
|
fscanf(fp, "%f", &ftmp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#endif
|
#endif
|
||||||
if(oldv != ftmp)
|
if (oldv != ftmp) {
|
||||||
{
|
|
||||||
oldv = ftmp;
|
oldv = ftmp;
|
||||||
tempa=(ftmp+0.005)*100;
|
tempa = (ftmp + 0.005) * 100;
|
||||||
tempy=tempa%10;
|
tempy = tempa % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,5);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 5);
|
||||||
tempy=tempa/10;
|
tempy = tempa / 10;
|
||||||
tempy=tempy%10;
|
tempy = tempy % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,5);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 5);
|
||||||
copyXPMArea(65,66,3,9,41,5);
|
copyXPMArea(65, 66, 3, 9, 41, 5);
|
||||||
tempy=tempa/100;
|
tempy = tempa / 100;
|
||||||
if ( tempy > 9 )
|
if (tempy > 9) {
|
||||||
{
|
tempy = (tempy - 10);
|
||||||
tempy=(tempy-10);
|
copyXPMArea(3 + (tempy * 6), 95, 6, 9, 34, 5);
|
||||||
copyXPMArea(3+(tempy*6),95,6,9,34,5);
|
|
||||||
} else {
|
} else {
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,34,5);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,11 +498,8 @@ void DrawLoad(void)
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
|
|
||||||
/* Mem/Swap Meter */
|
/* Mem/Swap Meter */
|
||||||
float DrawMemSwap
|
float DrawMemSwap(void
|
||||||
(
|
) {
|
||||||
void
|
|
||||||
)
|
|
||||||
{
|
|
||||||
unsigned long memMax, memFree, swapMax, swapFree;
|
unsigned long memMax, memFree, swapMax, swapFree;
|
||||||
unsigned long MEMmem, MEMswap;
|
unsigned long MEMmem, MEMswap;
|
||||||
float memUsed, swapUsed;
|
float memUsed, swapUsed;
|
||||||
|
@ -523,8 +514,7 @@ float DrawMemSwap
|
||||||
/* MEM Meter */
|
/* MEM Meter */
|
||||||
if (memMax == 0)
|
if (memMax == 0)
|
||||||
MEMmem = 0;
|
MEMmem = 0;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (((float)memMax / 1048576) >= 1)
|
if (((float)memMax / 1048576) >= 1)
|
||||||
MEMmem = ((memUsed * 31) / (float)memMax);
|
MEMmem = ((memUsed * 31) / (float)memMax);
|
||||||
else
|
else
|
||||||
|
@ -544,13 +534,10 @@ float DrawMemSwap
|
||||||
tempy = ((tempa / 10) % 10);
|
tempy = ((tempa / 10) % 10);
|
||||||
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 19);
|
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 19);
|
||||||
tempy = ((tempa / 100) % 10);
|
tempy = ((tempa / 100) % 10);
|
||||||
if (tempy != 0)
|
if (tempy != 0) {
|
||||||
{
|
|
||||||
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 19);
|
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 19);
|
||||||
copyXPMArea(16, 46, 2, 14, 35, 16);
|
copyXPMArea(16, 46, 2, 14, 35, 16);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
copyXPMArea(16, 46, 2, 14, 41, 16);
|
copyXPMArea(16, 46, 2, 14, 41, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,8 +547,7 @@ float DrawMemSwap
|
||||||
/* SWAP Meter */
|
/* SWAP Meter */
|
||||||
if (swapMax == 0)
|
if (swapMax == 0)
|
||||||
MEMswap = 0;
|
MEMswap = 0;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (((float)swapMax / 1048576) >= 1)
|
if (((float)swapMax / 1048576) >= 1)
|
||||||
MEMswap = ((swapUsed * 31) / (float)swapMax);
|
MEMswap = ((swapUsed * 31) / (float)swapMax);
|
||||||
else
|
else
|
||||||
|
@ -577,18 +563,15 @@ float DrawMemSwap
|
||||||
tempy = ((tempa / 10) % 10);
|
tempy = ((tempa / 10) % 10);
|
||||||
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 33);
|
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 33);
|
||||||
tempy = ((tempa / 100) % 10);
|
tempy = ((tempa / 100) % 10);
|
||||||
if (tempy != 0)
|
if (tempy != 0) {
|
||||||
{
|
|
||||||
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 33);
|
copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 33);
|
||||||
copyXPMArea(16, 46, 2, 14, 42, 16);
|
copyXPMArea(16, 46, 2, 14, 42, 16);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
copyXPMArea(16, 46, 2, 14, 41, 30);
|
copyXPMArea(16, 46, 2, 14, 41, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (float)memMax;
|
return (float)memMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -596,129 +579,134 @@ float DrawMemSwap
|
||||||
float DrawMemSwap(float total, int allmem)
|
float DrawMemSwap(float total, int allmem)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if( (fp = fopen("/proc/meminfo", "r")) != NULL)
|
if ((fp = fopen("/proc/meminfo", "r")) != NULL) {
|
||||||
{
|
static float stotal = 0.0, sshared = 0.0, sbuffers =
|
||||||
static float stotal=0.0, sshared=0.0, sbuffers=0.0, scached=0.0;
|
0.0, scached = 0.0;
|
||||||
char junk[128];
|
char junk[128];
|
||||||
float used, freeM, shared, buffers, cached, swaptotal,
|
float used, freeM, shared, buffers, cached, swaptotal,
|
||||||
swapused, swapfreeM;
|
swapused, swapfreeM;
|
||||||
unsigned long MEMshar,MEMbuff, MEMswap;
|
unsigned long MEMshar, MEMbuff, MEMswap;
|
||||||
int tempy, tempa;
|
int tempy, tempa;
|
||||||
|
|
||||||
if( has_kern26 > 0 )
|
if (has_kern26 > 0) {
|
||||||
{
|
|
||||||
float scratch;
|
float scratch;
|
||||||
|
|
||||||
while(!feof(fp))
|
while (!feof(fp)) {
|
||||||
{
|
|
||||||
fgets(junk, 120, fp);
|
fgets(junk, 120, fp);
|
||||||
if (strstr(junk, "MemTotal"))
|
if (strstr(junk, "MemTotal")) {
|
||||||
{
|
sscanf(junk, "MemTotal: %f kB",
|
||||||
sscanf(junk, "MemTotal: %f kB", &scratch);
|
&scratch);
|
||||||
total = scratch * 1024;
|
total = scratch * 1024;
|
||||||
}
|
}
|
||||||
if (strstr(junk, "MemFree"))
|
if (strstr(junk, "MemFree")) {
|
||||||
{
|
sscanf(junk, "MemFree: %f kB",
|
||||||
sscanf(junk, "MemFree: %f kB", &scratch);
|
&scratch);
|
||||||
freeM = scratch * 1024;
|
freeM = scratch * 1024;
|
||||||
used = total - freeM;
|
used = total - freeM;
|
||||||
}
|
}
|
||||||
if (strstr(junk, "Buffers"))
|
if (strstr(junk, "Buffers")) {
|
||||||
{
|
sscanf(junk, "Buffers: %f kB",
|
||||||
sscanf(junk, "Buffers: %f kB", &scratch);
|
&scratch);
|
||||||
buffers = scratch * 1024;
|
buffers = scratch * 1024;
|
||||||
}
|
}
|
||||||
if (strstr(junk, "Cached"))
|
if (strstr(junk, "Cached")) {
|
||||||
{
|
|
||||||
sscanf(junk, "Cached: %f kB", &scratch);
|
sscanf(junk, "Cached: %f kB", &scratch);
|
||||||
cached = scratch * 1024;
|
cached = scratch * 1024;
|
||||||
}
|
}
|
||||||
if (strstr(junk, "SwapTotal"))
|
if (strstr(junk, "SwapTotal")) {
|
||||||
{
|
sscanf(junk, "SwapTotal: %f kB",
|
||||||
sscanf(junk, "SwapTotal: %f kB", &scratch);
|
&scratch);
|
||||||
swaptotal = scratch * 1024;
|
swaptotal = scratch * 1024;
|
||||||
}
|
}
|
||||||
if (strstr(junk, "SwapFree"))
|
if (strstr(junk, "SwapFree")) {
|
||||||
{
|
sscanf(junk, "SwapFree: %f kB",
|
||||||
sscanf(junk, "SwapFree: %f kB", &scratch);
|
&scratch);
|
||||||
swapfreeM = scratch * 1024;
|
swapfreeM = scratch * 1024;
|
||||||
swapused = swaptotal - swapfreeM;
|
swapused = swaptotal - swapfreeM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fgets(junk, 80, fp);
|
fgets(junk, 80, fp);
|
||||||
fscanf(fp, "Mem: %f %f %f %f %f %f\nSwap: %f %f %f", &total,
|
fscanf(fp, "Mem: %f %f %f %f %f %f\nSwap: %f %f %f",
|
||||||
&used, &freeM, &shared, &buffers, &cached,
|
&total, &used, &freeM, &shared, &buffers,
|
||||||
&swaptotal, &swapused, &swapfreeM);
|
&cached, &swaptotal, &swapused, &swapfreeM);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
/* All mem areas */
|
/* All mem areas */
|
||||||
if(stotal != total || sshared != shared || sbuffers != buffers || scached != cached)
|
if (stotal != total || sshared != shared || sbuffers != buffers
|
||||||
{
|
|| scached != cached) {
|
||||||
stotal = total; sshared = shared; sbuffers = buffers; scached = cached;
|
stotal = total;
|
||||||
if ( (total/101048576) >= 1)
|
sshared = shared;
|
||||||
{
|
sbuffers = buffers;
|
||||||
MEMshar=((used-buffers-cached)/total)*27;
|
scached = cached;
|
||||||
MEMbuff=(buffers/total)*27;
|
if ((total / 101048576) >= 1) {
|
||||||
|
MEMshar =
|
||||||
|
((used - buffers - cached) / total) * 27;
|
||||||
|
MEMbuff = (buffers / total) * 27;
|
||||||
} else {
|
} else {
|
||||||
MEMshar=((used-buffers-cached)/total)*33;
|
MEMshar =
|
||||||
MEMbuff=(buffers/total)*33;
|
((used - buffers - cached) / total) * 33;
|
||||||
|
MEMbuff = (buffers / total) * 33;
|
||||||
}
|
}
|
||||||
// refresh
|
// refresh
|
||||||
copyXPMArea(4, 115, 55, 11, 4, 18);
|
copyXPMArea(4, 115, 55, 11, 4, 18);
|
||||||
// Bar
|
// Bar
|
||||||
if ( (total/101048576) >= 1)
|
if ((total / 101048576) >= 1) {
|
||||||
{
|
copyXPMArea(3, 75, ((used / total) * 28), 9, 5,
|
||||||
copyXPMArea(3,75,((used/total)*28),9,5,19);
|
19);
|
||||||
} else {
|
} else {
|
||||||
copyXPMArea(3,75,((used/total)*34),9,5,19);
|
copyXPMArea(3, 75, ((used / total) * 34), 9, 5,
|
||||||
|
19);
|
||||||
}
|
}
|
||||||
// Separators
|
// Separators
|
||||||
copyXPMArea(15,105,1,9,5+MEMshar,19);
|
copyXPMArea(15, 105, 1, 9, 5 + MEMshar, 19);
|
||||||
copyXPMArea(15,105,1,9,7+MEMshar+MEMbuff,19);
|
copyXPMArea(15, 105, 1, 9, 7 + MEMshar + MEMbuff, 19);
|
||||||
copyXPMArea(15,105,(36-(used/total)*34),9,(5+(used/total)*34),19);
|
copyXPMArea(15, 105, (36 - (used / total) * 34), 9,
|
||||||
|
(5 + (used / total) * 34), 19);
|
||||||
// Numbers
|
// Numbers
|
||||||
tempa=used/1048576;
|
tempa = used / 1048576;
|
||||||
tempy=tempa%10;
|
tempy = tempa % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,19);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 19);
|
||||||
tempy=(tempa/10)%10;
|
tempy = (tempa / 10) % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,19);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 19);
|
||||||
tempy=(tempa/100)%10;
|
tempy = (tempa / 100) % 10;
|
||||||
if ( (total/101048576) >= 1) {
|
if ((total / 101048576) >= 1) {
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,38,19);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 38, 19);
|
||||||
copyXPMArea(16,46,2,14,35,16);
|
copyXPMArea(16, 46, 2, 14, 35, 16);
|
||||||
} else {
|
} else {
|
||||||
copyXPMArea(16,46,2,14,41,16);
|
copyXPMArea(16, 46, 2, 14, 41, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SWAP Meter */
|
/* SWAP Meter */
|
||||||
if ( swaptotal == 0 ) MEMswap = 0;
|
if (swaptotal == 0)
|
||||||
|
MEMswap = 0;
|
||||||
else {
|
else {
|
||||||
if ( (total/101048576) >= 1)
|
if ((total / 101048576) >= 1)
|
||||||
MEMswap=(swapused*31)/swaptotal;
|
MEMswap = (swapused * 31) / swaptotal;
|
||||||
else MEMswap=(swapused*36)/swaptotal;
|
else
|
||||||
|
MEMswap = (swapused * 36) / swaptotal;
|
||||||
}
|
}
|
||||||
// refresh
|
// refresh
|
||||||
copyXPMArea(4, 115, 55, 11, 4, 32);
|
copyXPMArea(4, 115, 55, 11, 4, 32);
|
||||||
// Bar
|
// Bar
|
||||||
copyXPMArea(3,75,MEMswap,9,5,33);
|
copyXPMArea(3, 75, MEMswap, 9, 5, 33);
|
||||||
copyXPMArea(15,105,(36-(MEMswap)),9,5+MEMswap,33);
|
copyXPMArea(15, 105, (36 - (MEMswap)), 9, 5 + MEMswap, 33);
|
||||||
// Numbers
|
// Numbers
|
||||||
tempa=swapused/1048576;
|
tempa = swapused / 1048576;
|
||||||
tempy=tempa%10;
|
tempy = tempa % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,33);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 33);
|
||||||
tempy=(tempa/10)%10;
|
tempy = (tempa / 10) % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,33);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 33);
|
||||||
tempy=tempa/100;
|
tempy = tempa / 100;
|
||||||
if ( tempy != 0 ) {
|
if (tempy != 0) {
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,38,33);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 38, 33);
|
||||||
copyXPMArea(16,46,2,14,35,30);
|
copyXPMArea(16, 46, 2, 14, 35, 30);
|
||||||
} else {
|
} else {
|
||||||
copyXPMArea(16,46,2,14,41,30);
|
copyXPMArea(16, 46, 2, 14, 41, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(total);
|
return (total);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -733,41 +721,40 @@ void DrawXmem(int Xpid, float total)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[128], XFileName[256];
|
char buf[128], XFileName[256];
|
||||||
float ratio;
|
float ratio;
|
||||||
long old_Xsize=-1, Xsize=0;
|
long old_Xsize = -1, Xsize = 0;
|
||||||
|
|
||||||
sprintf(XFileName, "/proc/%d/status", Xpid);
|
sprintf(XFileName, "/proc/%d/status", Xpid);
|
||||||
|
|
||||||
if ((fp = fopen(XFileName, "r")) != NULL)
|
if ((fp = fopen(XFileName, "r")) != NULL) {
|
||||||
{
|
while (fgets(buf, 127, fp)) {
|
||||||
while( fgets(buf, 127, fp) )
|
|
||||||
{
|
|
||||||
if (strstr(buf, "VmSize"))
|
if (strstr(buf, "VmSize"))
|
||||||
sscanf(buf, "VmSize: %ld", &Xsize);
|
sscanf(buf, "VmSize: %ld", &Xsize);
|
||||||
}
|
}
|
||||||
if(old_Xsize!=Xsize)
|
if (old_Xsize != Xsize) {
|
||||||
{
|
|
||||||
int tempy, tempa, tempb;
|
int tempy, tempa, tempb;
|
||||||
old_Xsize=Xsize;
|
old_Xsize = Xsize;
|
||||||
ratio=Xsize/(total/1024);
|
ratio = Xsize / (total / 1024);
|
||||||
if ( Xsize > (total/1024) ) Xsize=total/1024;
|
if (Xsize > (total / 1024))
|
||||||
Xsize=Xsize/1024;
|
Xsize = total / 1024;
|
||||||
tempy=Xsize%10;
|
Xsize = Xsize / 1024;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,48);
|
tempy = Xsize % 10;
|
||||||
tempa=Xsize/10;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
|
||||||
tempy=tempa%10;
|
tempa = Xsize / 10;
|
||||||
tempb=Xsize/100;
|
tempy = tempa % 10;
|
||||||
if ( Xsize > 100 )
|
tempb = Xsize / 100;
|
||||||
{
|
if (Xsize > 100) {
|
||||||
copyXPMArea(3,84,((ratio)*17),11,18,47);
|
copyXPMArea(3, 84, ((ratio) * 17), 11, 18, 47);
|
||||||
copyXPMArea(15,105,(23-((ratio)*17)),11,(18+(ratio*22)),47);
|
copyXPMArea(15, 105, (23 - ((ratio) * 17)), 11,
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,48);
|
(18 + (ratio * 22)), 47);
|
||||||
copyXPMArea(3+(tempb*6),66,6,9,38,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
|
||||||
copyXPMArea(16,46,2,14,36,46);
|
copyXPMArea(3 + (tempb * 6), 66, 6, 9, 38, 48);
|
||||||
|
copyXPMArea(16, 46, 2, 14, 36, 46);
|
||||||
} else {
|
} else {
|
||||||
copyXPMArea(3,84,((ratio)*22),11,18,47);
|
copyXPMArea(3, 84, ((ratio) * 22), 11, 18, 47);
|
||||||
copyXPMArea(15,105,(23-((ratio)*22)),11,(18+(ratio*22)),47);
|
copyXPMArea(15, 105, (23 - ((ratio) * 22)), 11,
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,48);
|
(18 + (ratio * 22)), 47);
|
||||||
copyXPMArea(16,46,2,14,41,46);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
|
||||||
|
copyXPMArea(16, 46, 2, 14, 41, 46);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -781,10 +768,10 @@ void DrawXmem(int Xpid, float total)
|
||||||
/* Uptime */
|
/* Uptime */
|
||||||
void DrawUptime(void)
|
void DrawUptime(void)
|
||||||
{
|
{
|
||||||
int upt, days=0,hours=0,mins=0, old_mins=-1,old_hours=-1;
|
int upt, days = 0, hours = 0, mins = 0, old_mins = -1, old_hours = -1;
|
||||||
|
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
struct utmp * pUtmp;
|
struct utmp *pUtmp;
|
||||||
struct utmp idUtmp;
|
struct utmp idUtmp;
|
||||||
idUtmp.ut_type = BOOT_TIME;
|
idUtmp.ut_type = BOOT_TIME;
|
||||||
setutent();
|
setutent();
|
||||||
|
@ -792,46 +779,44 @@ void DrawUptime(void)
|
||||||
upt = (time(0) - pUtmp->ut_time);
|
upt = (time(0) - pUtmp->ut_time);
|
||||||
#else
|
#else
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if( (fp = fopen("/proc/uptime", "r")) != NULL)
|
if ((fp = fopen("/proc/uptime", "r")) != NULL)
|
||||||
fscanf(fp, "%d",&upt);
|
fscanf(fp, "%d", &upt);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#endif
|
#endif
|
||||||
mins=(upt/60)%60;
|
mins = (upt / 60) % 60;
|
||||||
hours=(upt/3600)%24;
|
hours = (upt / 3600) % 24;
|
||||||
days=(upt/86400);
|
days = (upt / 86400);
|
||||||
if(old_hours!=hours)
|
if (old_hours != hours)
|
||||||
old_hours=hours;
|
old_hours = hours;
|
||||||
if(old_mins!=mins)
|
if (old_mins != mins) {
|
||||||
{
|
|
||||||
int tempy;
|
int tempy;
|
||||||
old_mins=mins;
|
old_mins = mins;
|
||||||
if ( days > 9 )
|
if (days > 9) {
|
||||||
{
|
copyXPMArea(20, 105, 36, 9, 18, 48);
|
||||||
copyXPMArea(20,105,36,9,18,48);
|
tempy = hours % 10;
|
||||||
tempy=hours%10;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,48);
|
tempy = hours / 10;
|
||||||
tempy=hours/10;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,48);
|
copyXPMArea(63, 66, 3, 9, 41, 48);
|
||||||
copyXPMArea(63,66,3,9,41,48);
|
tempy = days % 10;
|
||||||
tempy=days%10;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 48);
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,34,48);
|
tempy = (days / 10) % 10;
|
||||||
tempy=(days/10)%10;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 28, 48);
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,28,48);
|
tempy = days / 100;
|
||||||
tempy=days/100;
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 22, 48);
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,22,48);
|
|
||||||
} else {
|
} else {
|
||||||
tempy=mins%10;
|
tempy = mins % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,50,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
|
||||||
tempy=mins/10;
|
tempy = mins / 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,44,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
|
||||||
copyXPMArea(63,66,3,9,41,48);
|
copyXPMArea(63, 66, 3, 9, 41, 48);
|
||||||
tempy=hours%10;
|
tempy = hours % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,34,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 48);
|
||||||
tempy=hours/10;
|
tempy = hours / 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,28,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 28, 48);
|
||||||
copyXPMArea(63,66,3,9,25,48);
|
copyXPMArea(63, 66, 3, 9, 25, 48);
|
||||||
tempy=days%10;
|
tempy = days % 10;
|
||||||
copyXPMArea(3+(tempy*6),66,6,9,18,48);
|
copyXPMArea(3 + (tempy * 6), 66, 6, 9, 18, 48);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,8 +827,7 @@ void DrawUptime(void)
|
||||||
/* Drawing LED's */
|
/* Drawing LED's */
|
||||||
void DrawLite(int state, int dx, int dy)
|
void DrawLite(int state, int dx, int dy)
|
||||||
{
|
{
|
||||||
switch(state)
|
switch (state) {
|
||||||
{
|
|
||||||
case B_RED:
|
case B_RED:
|
||||||
copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
|
copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue