Permalink
Browse files

add net_stat Python binding

  • Loading branch information...
1 parent 129062d commit 73b0850a52b39cd4ebaf1f63980749617de18149 @dougm dougm committed Jun 15, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 bindings/python/_sigar.c
@@ -395,6 +395,29 @@ static PyObject *pysigar_arp_list(PyObject *self, PyObject *args)
return RETVAL;
}
+static PyObject *pysigar_net_stat(PyObject *self, PyObject *args)
+{
+ int status, flags;
+ sigar_t *sigar = PySIGAR;
+ sigar_net_stat_t *RETVAL;
+
+ if (!PyArg_ParseTuple(args, "i", &flags)) {
+ return NULL;
+ }
+
+ RETVAL = malloc(sizeof(*RETVAL));
+ if ((status = sigar_net_stat_get(sigar, RETVAL, flags)) != SIGAR_OK) {
+ free(RETVAL);
+ PySigar_Croak();
+ return NULL;
+ }
+ else {
+ PyObject *self = PySigar_new(pysigar_PySigarNetStatType);
+ PySIGAR_OBJ->ptr = RETVAL;
+ return self;
+ }
+}
+
static PyObject *pysigar_cpu_list(PyObject *self, PyObject *args)
{
int status;
@@ -608,6 +631,7 @@ static PyMethodDef pysigar_methods[] = {
{ "net_route_list", pysigar_net_route_list, METH_NOARGS, NULL },
{ "file_system_list", pysigar_file_system_list, METH_NOARGS, NULL },
{ "arp_list", pysigar_arp_list, METH_NOARGS, NULL },
+ { "net_stat", pysigar_net_stat, METH_VARARGS, NULL },
{ "cpu_list", pysigar_cpu_list, METH_NOARGS, NULL },
{ "cpu_info_list", pysigar_cpu_info_list, METH_NOARGS, NULL },
{ "loadavg", pysigar_loadavg, METH_NOARGS, NULL },

0 comments on commit 73b0850

Please sign in to comment.