2014-09-30 03:13:05 +04:00
# include "defs.h"
# include <sys/sysinfo.h>
2015-04-07 04:36:50 +03:00
SYS_FUNC ( sysinfo )
2014-09-30 03:13:05 +04:00
{
struct sysinfo si ;
2014-09-30 03:29:56 +04:00
if ( entering ( tcp ) )
return 0 ;
2015-07-17 01:08:02 +03:00
if ( ! umove_or_printaddr ( tcp , tcp - > u_arg [ 0 ] , & si ) ) {
2015-03-02 17:34:25 +03:00
tprintf ( " {uptime=%llu "
" , loads=[%llu, %llu, %llu] "
" , totalram=%llu "
" , freeram=%llu "
" , sharedram=%llu "
" , bufferram=%llu "
" , totalswap=%llu "
" , freeswap=%llu "
2014-09-30 03:29:56 +04:00
" , procs=%u "
# ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
2015-03-02 17:34:25 +03:00
" , totalhigh=%llu "
2014-09-30 03:29:56 +04:00
# endif
# ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
2015-03-02 17:34:25 +03:00
" , freehigh=%llu "
2014-09-30 03:29:56 +04:00
# endif
# ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
" , mem_unit=%u "
# endif
" } " ,
2015-03-02 17:34:25 +03:00
( unsigned long long ) si . uptime
, ( unsigned long long ) si . loads [ 0 ]
, ( unsigned long long ) si . loads [ 1 ]
, ( unsigned long long ) si . loads [ 2 ]
, ( unsigned long long ) si . totalram
, ( unsigned long long ) si . freeram
, ( unsigned long long ) si . sharedram
, ( unsigned long long ) si . bufferram
, ( unsigned long long ) si . totalswap
, ( unsigned long long ) si . freeswap
2014-09-30 03:29:56 +04:00
, ( unsigned ) si . procs
# ifdef HAVE_STRUCT_SYSINFO_TOTALHIGH
2015-03-02 17:34:25 +03:00
, ( unsigned long long ) si . totalhigh
2014-09-30 03:29:56 +04:00
# endif
# ifdef HAVE_STRUCT_SYSINFO_FREEHIGH
2015-03-02 17:34:25 +03:00
, ( unsigned long long ) si . freehigh
2014-09-30 03:29:56 +04:00
# endif
# ifdef HAVE_STRUCT_SYSINFO_MEM_UNIT
, si . mem_unit
# endif
) ;
2014-09-30 03:13:05 +04:00
}
2014-09-30 03:29:56 +04:00
2014-09-30 03:13:05 +04:00
return 0 ;
}