blob: 4d9e30c67ecaac21ca630f46517fbb36d464ce3d [file] [log] [blame]
Dmitry V. Levin57d45a22014-09-29 23:13:05 +00001#include "defs.h"
2#include <sys/sysinfo.h>
3
Dmitry V. Levina0bd3742015-04-07 01:36:50 +00004SYS_FUNC(sysinfo)
Dmitry V. Levin57d45a22014-09-29 23:13:05 +00005{
6 struct sysinfo si;
7
Dmitry V. Levin82a528d2014-09-29 23:29:56 +00008 if (entering(tcp))
9 return 0;
10
Dmitry V. Levinbe6d7912015-07-16 22:08:02 +000011 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &si)) {
Dmitry V. Levin822892b2015-03-02 14:34:25 +000012 tprintf("{uptime=%llu"
13 ", loads=[%llu, %llu, %llu]"
14 ", totalram=%llu"
15 ", freeram=%llu"
16 ", sharedram=%llu"
17 ", bufferram=%llu"
18 ", totalswap=%llu"
19 ", freeswap=%llu"
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000020 ", procs=%u"
Dmitry V. Levin822892b2015-03-02 14:34:25 +000021 ", totalhigh=%llu"
Dmitry V. Levin822892b2015-03-02 14:34:25 +000022 ", freehigh=%llu"
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000023 ", mem_unit=%u"
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000024 "}",
Dmitry V. Levin822892b2015-03-02 14:34:25 +000025 (unsigned long long) si.uptime
26 , (unsigned long long) si.loads[0]
27 , (unsigned long long) si.loads[1]
28 , (unsigned long long) si.loads[2]
29 , (unsigned long long) si.totalram
30 , (unsigned long long) si.freeram
31 , (unsigned long long) si.sharedram
32 , (unsigned long long) si.bufferram
33 , (unsigned long long) si.totalswap
34 , (unsigned long long) si.freeswap
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000035 , (unsigned) si.procs
Dmitry V. Levin822892b2015-03-02 14:34:25 +000036 , (unsigned long long) si.totalhigh
Dmitry V. Levin822892b2015-03-02 14:34:25 +000037 , (unsigned long long) si.freehigh
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000038 , si.mem_unit
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000039 );
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000040 }
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000041
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000042 return 0;
43}