Exemple #1
0
static PyObject* gtop_sysinfo(PyObject *self, PyObject *args)
{
	const glibtop_sysinfo *infos;
	PyObject *cpus;
	size_t i;

	if(!PyArg_ParseTuple(args, ""))
		return NULL;

	infos = glibtop_get_sysinfo();
	cpus = PyList_New(0);

	for (i = 0; i < GLIBTOP_NCPU; ++i) {

		const glibtop_entry *entry = &infos->cpuinfo[i];
		PyObject *d;

		if (!entry->values)
			break;

		d = PyDict_New();
		g_hash_table_foreach(entry->values, hash_table_to_dict_cb, d);
		PyList_Append(cpus, d);
		Py_DECREF(d);
	}

	return cpus;
}
Exemple #2
0
static void pprint_get_sysinfo(void)
{
  const glibtop_sysinfo *buf;

  buf = glibtop_get_sysinfo();

  HEADER_PPRINT(glibtop_get_sysinfo);
  //PPRINT(flags, "%#llx");
  //PPRINT(ncpu, "%llu");
  PPRINT_ENTRY_ARRAY(cpuinfo, 4);
  FOOTER_PPRINT();
}