fixed small prob with memory stuff being wrong
[monky] / src / linux.c
index 2612d6f..fb57fe7 100644 (file)
@@ -122,12 +122,16 @@ void update_meminfo()
                        sscanf(buf, "%*s %lu", &info.cached);
                }
        }
-
+       
        info.mem = info.memmax - info.mem;
        info.swap = info.swapmax - info.swap;
 
        info.bufmem = info.cached + info.buffers;
 
+       /*if (no_buffers) {
+               info.mem -= info.bufmem;
+       }*/
+
        info.mask |= (1 << INFO_MEM) | (1 << INFO_BUFFERS);
 }
 
@@ -323,11 +327,11 @@ void update_total_processes()
 
 #define CPU_SAMPLE_COUNT 15
 struct cpu_info {
-       unsigned int cpu_user;
-       unsigned int cpu_system;
-       unsigned int cpu_nice;
+       unsigned long cpu_user;
+       unsigned long cpu_system;
+       unsigned long cpu_nice;
        double last_cpu_sum;
-       int clock_ticks;
+       unsigned long clock_ticks;
        double cpu_val[CPU_SAMPLE_COUNT];
 };
 static short cpu_setup = 0;
@@ -398,11 +402,11 @@ inline static void update_stat()
                        sscanf(buf, "%*s %d", &info.run_procs);
                        info.mask |= (1 << INFO_RUN_PROCS);
                } else if (strncmp(buf, "cpu ", 4) == 0) {
-                       sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
+                       sscanf(buf, "%*s %lu %lu %lu", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
                        index++;
                        info.mask |= (1 << INFO_CPU);
                } else if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3]) && index <= info.cpu_count) {
-                       sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
+                       sscanf(buf, "%*s %lu %lu %lu", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
                        index++;
                        info.mask |= (1 << INFO_CPU);
                }
@@ -910,7 +914,7 @@ passive:                 73 C: tc1=4 tc2=3 tsp=40 devices=0xcdf6e6c0
 int open_acpi_temperature(const char *name)
 {
        char path[256];
-       char buf[64];
+       char buf[256];
        int fd;
 
        if (name == NULL || strcmp(name, "*") == 0) {
@@ -1172,6 +1176,7 @@ void update_top()
 {
        show_nice_processes = 1;
        process_find_top(info.cpu, info.memu);
+       info.first_process = get_first_process();
 }