blob: 0e724dad8b7e08406f31ac586296e911f3836085 [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"
21#ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
Dmitry V. Levin822892b2015-03-02 14:34:25 +000022 ", totalhigh=%llu"
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000023#endif
24#ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
Dmitry V. Levin822892b2015-03-02 14:34:25 +000025 ", freehigh=%llu"
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000026#endif
27#ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
28 ", mem_unit=%u"
29#endif
30 "}",
Dmitry V. Levin822892b2015-03-02 14:34:25 +000031 (unsigned long long) si.uptime
32 , (unsigned long long) si.loads[0]
33 , (unsigned long long) si.loads[1]
34 , (unsigned long long) si.loads[2]
35 , (unsigned long long) si.totalram
36 , (unsigned long long) si.freeram
37 , (unsigned long long) si.sharedram
38 , (unsigned long long) si.bufferram
39 , (unsigned long long) si.totalswap
40 , (unsigned long long) si.freeswap
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000041 , (unsigned) si.procs
42#ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
Dmitry V. Levin822892b2015-03-02 14:34:25 +000043 , (unsigned long long) si.totalhigh
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000044#endif
45#ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
Dmitry V. Levin822892b2015-03-02 14:34:25 +000046 , (unsigned long long) si.freehigh
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000047#endif
48#ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
49 , si.mem_unit
50#endif
51 );
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000052 }
Dmitry V. Levin82a528d2014-09-29 23:29:56 +000053
Dmitry V. Levin57d45a22014-09-29 23:13:05 +000054 return 0;
55}