Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | #include <sys/sysinfo.h> |
| 3 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 4 | SYS_FUNC(sysinfo) |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 5 | { |
| 6 | struct sysinfo si; |
| 7 | |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 8 | if (entering(tcp)) |
| 9 | return 0; |
| 10 | |
Dmitry V. Levin | be6d791 | 2015-07-16 22:08:02 +0000 | [diff] [blame^] | 11 | if (!umove_or_printaddr(tcp, tcp->u_arg[0], &si)) { |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 12 | 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. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 20 | ", procs=%u" |
| 21 | #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 22 | ", totalhigh=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 23 | #endif |
| 24 | #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 25 | ", freehigh=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 26 | #endif |
| 27 | #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT |
| 28 | ", mem_unit=%u" |
| 29 | #endif |
| 30 | "}", |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 31 | (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. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 41 | , (unsigned) si.procs |
| 42 | #ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 43 | , (unsigned long long) si.totalhigh |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 44 | #endif |
| 45 | #ifdef HAVE_STRUCT_SYSINFO_FREEHIGH |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 46 | , (unsigned long long) si.freehigh |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 47 | #endif |
| 48 | #ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT |
| 49 | , si.mem_unit |
| 50 | #endif |
| 51 | ); |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 52 | } |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 53 | |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 54 | return 0; |
| 55 | } |