1 #include "defs.h"
2 #include <sys/sysinfo.h>
3 
SYS_FUNC(sysinfo)4 SYS_FUNC(sysinfo)
5 {
6 	struct sysinfo si;
7 
8 	if (entering(tcp))
9 		return 0;
10 
11 	if (syserror(tcp) || !verbose(tcp) ||
12 	    umove(tcp, tcp->u_arg[0], &si) < 0) {
13 		tprintf("%#lx", tcp->u_arg[0]);
14 	} else {
15 		tprintf("{uptime=%llu"
16 			", loads=[%llu, %llu, %llu]"
17 			", totalram=%llu"
18 			", freeram=%llu"
19 			", sharedram=%llu"
20 			", bufferram=%llu"
21 			", totalswap=%llu"
22 			", freeswap=%llu"
23 			", procs=%u"
24 #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
25 			", totalhigh=%llu"
26 #endif
27 #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
28 			", freehigh=%llu"
29 #endif
30 #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
31 			", mem_unit=%u"
32 #endif
33 			"}",
34 			(unsigned long long) si.uptime
35 			, (unsigned long long) si.loads[0]
36 			, (unsigned long long) si.loads[1]
37 			, (unsigned long long) si.loads[2]
38 			, (unsigned long long) si.totalram
39 			, (unsigned long long) si.freeram
40 			, (unsigned long long) si.sharedram
41 			, (unsigned long long) si.bufferram
42 			, (unsigned long long) si.totalswap
43 			, (unsigned long long) si.freeswap
44 			, (unsigned) si.procs
45 #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
46 			, (unsigned long long) si.totalhigh
47 #endif
48 #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
49 			, (unsigned long long) si.freehigh
50 #endif
51 #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
52 			, si.mem_unit
53 #endif
54 			);
55 	}
56 
57 	return 0;
58 }
59