Note that there are some explanatory texts on larger screens.

plurals
  1. POC - sysinfo() returning bad values i686
    primarykey
    data
    text
    <p>I'm trying to write a simple program to alert me when ram is getting fulled, but I've some problems with sysinfo(), the sample program is in C, I've grabbed it from a site with examples the code seems to be okay, any ideas of why this can be happening ? sorry about my english it's not my native language... </p> <p>code is below:</p> <pre><code>/* sysinfo.c by detour@metalshell.com * * Display the uptime, load averages, total ram, free ram, * shared ram, buffered ram, total swap, free swap, and * number of processes running on a linux machine. * * http://www.metalshell.com/ * */ #include &lt;sys/sysinfo.h&gt; #include &lt;stdio.h&gt; int main() { int days, hours, mins; struct sysinfo sys_info; if(sysinfo(&amp;sys_info) != 0) perror("sysinfo"); // Uptime days = sys_info.uptime / 86400; hours = (sys_info.uptime / 3600) - (days * 24); mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60); printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n", days, hours, mins, sys_info.uptime % 60); // Load Averages for 1,5 and 15 minutes printf("Load Avgs: 1min(%ld) 5min(%ld) 15min(%ld)\n", sys_info.loads[0], sys_info.loads[1], sys_info.loads[2]); // Total and free ram. printf("Total Ram: %ldk\tFree: %ldk\n", sys_info.totalram / 1024, sys_info.freeram / 1024); // Shared and buffered ram. printf("Shared Ram: %ldk\n", sys_info.sharedram / 1024); printf("Buffered Ram: %ldk\n", sys_info.bufferram / 1024); // Swap space printf("Total Swap: %ldk\tFree: %ldk\n", sys_info.totalswap / 1024, sys_info.freeswap / 1024); // Number of processes currently running. printf("Number of processes: %d\n", sys_info.procs); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload