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" |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 21 | ", totalhigh=%llu" |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 22 | ", freehigh=%llu" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 23 | ", mem_unit=%u" |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 24 | "}", |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 25 | (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. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 35 | , (unsigned) si.procs |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 36 | , (unsigned long long) si.totalhigh |
Dmitry V. Levin | 822892b | 2015-03-02 14:34:25 +0000 | [diff] [blame] | 37 | , (unsigned long long) si.freehigh |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 38 | , si.mem_unit |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 39 | ); |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 40 | } |
Dmitry V. Levin | 82a528d | 2014-09-29 23:29:56 +0000 | [diff] [blame] | 41 | |
Dmitry V. Levin | 57d45a2 | 2014-09-29 23:13:05 +0000 | [diff] [blame] | 42 | return 0; |
| 43 | } |