Getting system info:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found this structure in kernel.h and an example of a function that uses it but
I just want to make sure I understand.  Does the sysinfo function simply fill up
a sysinfo struct with the appropriate data like I'd expect or does it need to
have any additional actions taken to set it up?  Presumably I could just
include the appropriate headers and do this in sched.c to set the tunables
based on the current situation:

struct sysinfo s_info;
sysinfo(&s_info);



This was the original example from
http://www.linuxvalley.it/encyclopedia/ldp/manpage/man2/intro.2.php:

EXAMPLE
function
       #include <stdio.h>
       #include <linux/unistd.h>     /* for _syscallX macros/related stuff */
       #include <linux/kernel.h>     /* for struct sysinfo */

       _syscall1(int, sysinfo, struct sysinfo *, info);

       /* Note: if you copy directly from the nroff source, remember to
       REMOVE the extra backslashes in the printf statement. */
       int main(void)
       {
            struct sysinfo s_info;
            int error;

            error = sysinfo(&s_info);
            printf("code error = %d\n", error);
               printf("Uptime = %ds\nLoad: 1 min %d / 5 min %d / 15 min %d\n"
                       "RAM: total %d / free %d / shared %d\n"
                       "Memory in buffers = %d\nSwap: total %d / free %d\n"
                       "Number of processes = %d\n",
                 s_info.uptime, s_info.loads[0],
                 s_info.loads[1], s_info.loads[2],
                 s_info.totalram, s_info.freeram,
                 s_info.sharedram, s_info.bufferram,
                 s_info.totalswap, s_info.freeswap,
                 s_info.procs);
            return(0);
       }

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux