0

I know that there is sysinfo structure under <sys/sysinfo.h> header file which stores the information.

But i wanted to know, how does Linux keep this information?, how does it initialize the structure?, When is it created and how is it stored?, How is it updated?, Can we customize the structure?

Is there are a file in which keep this information!?. Is there a alternate way to get system status information? can we bypass this and can directly get the status from the hardware.

(Attach resource if possible)

Rahul
  • 975
  • 9
  • 25
  • 1
    SO is for programming questions, not questions about using or configuring Linux and its applications. SuperUser.com or unix.stackexchange.com would be better places for questions like this. – Barmar Feb 23 '18 at 17:42
  • It's kept in kernel memory. Read a textbook on the design of the Linux OS to learn the details. – Barmar Feb 23 '18 at 17:43
  • how can i shift this question to unix.stackexchange.com? – Rahul Feb 23 '18 at 17:44
  • Flag it for the moderators to move it. – Barmar Feb 23 '18 at 17:45
  • @Barmar This question is perfectly fine on SO. `sysinfo()` is a system call; it's used in C programming on Linux systems. –  Feb 23 '18 at 17:46
  • Looks like a programming question to me too. – user3344003 Feb 23 '18 at 19:05

1 Answers1

1

The information returned by sysinfo() is collected on demand from various sources within the kernel. There isn't any one place it all comes from.

The structure is not practical to modify, as it is part of a shared kernel/userspace interface. Generally speaking, if you want to expose additional data to userspace, it should be published as a /proc node.

All of the information returned by sysinfo() is available from other sources within procfs:

  • info->uptime: /proc/uptime
  • info->loads: /proc/loadavg
  • info->totalram, etc: /proc/meminfo
  • info->procs: /proc itself (count the numbered subdirectories!)