| 1 |
/* |
| 2 |
* Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. |
| 3 |
* Use of this source code is governed by a BSD-style license that can be |
| 4 |
* found in the LICENSE file. |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <Python.h> |
| 8 |
#include <sys/sysinfo.h> |
| 9 |
|
| 10 |
#include "../../arch/all/init.h" |
| 11 |
|
| 12 |
|
| 13 |
PyObject * |
| 14 |
psutil_linux_sysinfo(PyObject *self, PyObject *args) { |
| 15 |
struct sysinfo info; |
| 16 |
|
| 17 |
if (sysinfo(&info) != 0) |
| 18 |
return PyErr_SetFromErrno(PyExc_OSError); |
| 19 |
// note: boot time might also be determined from here |
| 20 |
return Py_BuildValue( |
| 21 |
"(kkkkkkI)", |
| 22 |
info.totalram, // total |
| 23 |
info.freeram, // free |
| 24 |
info.bufferram, // buffer |
| 25 |
info.sharedram, // shared |
| 26 |
info.totalswap, // swap tot |
| 27 |
info.freeswap, // swap free |
| 28 |
info.mem_unit // multiplier |
| 29 |
); |
| 30 |
} |