Exemple #1
0
int main(int argc, char **argv) {
  int i;
  struct glibtop_netlist netlist;
  char **ifnames = glibtop_get_netlist(&netlist);
  for (i = 0; i < netlist.number; i++) {
    struct glibtop_netload netload;
    glibtop_get_netload(&netload, ifnames[i]);
    printf("%s\n", ifnames[i]);
    printf(" %lu, %lu\n", netload.bytes_in, netload.bytes_out);
  }

  struct glibtop_cpu cpu;
  glibtop_get_cpu(&cpu);
  printf("%lu, %lu, %lu\n", cpu.user, cpu.sys, cpu.nice);

  struct glibtop_mem mem;
  glibtop_get_mem(&mem);
  printf("%lu, %lu\n", mem.total, mem.used);

  struct glibtop_swap swap;
  glibtop_get_swap(&swap);
  printf("%lu, %lu\n", swap.total, swap.used);

  struct glibtop_conntrack conntrack;
  glibtop_get_conntrack(&conntrack);
  printf("%lu, %lu\n", conntrack.tcp_conns, conntrack.udp_conns);

  struct glibtop_wireless wireless;
  glibtop_get_wireless(&wireless, "wlan0");
  printf("%ld, %ld\n", wireless.signal_dbm, wireless.noise_dbm);

  return 0;
}
static void
get_interfaces(NetData* data)
{
  glibtop_netlist list;
  data->interfaces = glibtop_get_netlist(&list);
  data->num_interfaces = list.number;
}
GList* device_info_list_get() {
    glibtop_netlist netlist;
    char **devices, **dev;
    GList *device_glist = NULL;

    devices = glibtop_get_netlist(&netlist);

    for (dev = devices; *dev; ++dev) {
        device_glist = g_list_prepend(device_glist, g_strdup(*dev));
    }

    g_strfreev(devices);

    return device_glist;
}
Exemple #4
0
/* Check for all available devices. This really should be
 * portable for at least all plattforms using the gnu c lib
 * TODO: drop it, use glibtop_get_netlist directly / gchar**
 */
GList*
get_available_devices(void)
{
	glibtop_netlist buf;
	char **devices, **dev;
	GList *device_glist = NULL;

	devices = glibtop_get_netlist(&buf);

	for(dev = devices; *dev; ++dev) {
		device_glist = g_list_prepend(device_glist, g_strdup(*dev));
	}

	g_strfreev(devices);

	return device_glist;
}
Exemple #5
0
static PyObject* gtop_netlist(PyObject *self, PyObject *args)
{
	glibtop_netlist buf;
	PyObject *t;
	char **devices;

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

	devices = glibtop_get_netlist(&buf);

	INIT_LIST_WITH(t, PyS_S, devices, buf.number);

	g_strfreev(devices);

	return t;
}
Exemple #6
0
static void pprint_get_netlist(void)
{
  glibtop_netlist buf;
  char **devices;
  guint32 i;

  devices = glibtop_get_netlist(&buf);

  HEADER_PPRINT(glibtop_get_netlist);

  for(i = 0; i < buf.number; ++i)
  {
	  printf("\t%s\n", devices[i]);
  }

  FOOTER_PPRINT();

  g_strfreev(devices);
}
Exemple #7
0
int main(int argc, char *argv [])
{
	glibtop_netlist buf;
	char **devices;
	guint32 i;

	glibtop_init();

	devices = glibtop_get_netlist(&buf);

	for(i = 0; i < buf.number; ++i)
	{
		printf("net device '%s'\n", devices[i]);
	}

	g_strfreev(devices);

	glibtop_close();
	return 0;
}
Exemple #8
0
static GList *
info_get_interfaces (Netinfo *info)
{
	GList *items = NULL;
	glibtop_netlist netlist;
	gchar **devices;
	gchar *iface;
	gint i;

	devices = glibtop_get_netlist(&netlist);

	for(i = 0; i < netlist.number; ++i) {
		iface = g_strdup (devices[i]);
		if (g_list_find_custom (items, iface, 
					           (GCompareFunc) compare) == NULL) {
			items = g_list_append (items, iface);
		}
	}

	g_strfreev(devices);

	return items;
}
Exemple #9
0
int
main (int argc, char *argv [])
{
	glibtop_union data;
	unsigned c;
	struct rusage total_start, total_end;
	struct rusage rusage_start, rusage_end;
	struct timeval elapsed_utime, elapsed_stime;
	pid_t pid;

	pid = getpid ();

	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR);
	textdomain (GETTEXT_PACKAGE);


	glibtop_init_r (&glibtop_global_server, 0, 0);

	display_self_times();

	printf ("%-12s (%-10s): %7s - %9s - %9s\n",
		"Feature", "Flags", "Count", "utime", "stime");
	printf ("-------------------------------------------"
		"---------------\n");

	getrusage (RUSAGE_SELF, &total_start);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_cpu (&data.cpu);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("CPU          (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.cpu.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
		glibtop_get_mem (&data.mem);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Memory       (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.mem.flags, PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
		glibtop_get_swap (&data.swap);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Swap         (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.swap.flags, PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_uptime (&data.uptime);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Uptime       (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.uptime.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_loadavg (&data.loadavg);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Loadavg      (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.loadavg.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
		pid_t* ptr = glibtop_get_proclist (&data.proclist, 0, 0);
		g_free (ptr);
	}

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proclist     (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proclist.flags,
		PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
		char** ptr = glibtop_get_netlist (&data.netlist);
		g_strfreev (ptr);
	}

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Netlist      (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proclist.flags,
		PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_state (&data.proc_state, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_State   (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_state.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_uid (&data.proc_uid, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Uid     (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_uid.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_mem (&data.proc_mem, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Mem     (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_mem.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
		glibtop_map_entry* entries;
		entries = glibtop_get_proc_map (&data.proc_map, pid);
		g_free (entries);
	}

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Map     (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_map.flags, PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
		(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_segment (&data.proc_segment, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Segment (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_segment.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++) {
		char** argv;
		argv = glibtop_get_proc_argv (&data.proc_args, pid, 0);
		g_strfreev(argv);
	}

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Args    (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_args.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_time (&data.proc_time, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Time    (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_time.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_signal (&data.proc_signal, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Signal  (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_signal.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &rusage_start);

	for (c = 0; c < PROFILE_COUNT; c++)
		glibtop_get_proc_kernel (&data.proc_kernel, pid);

	getrusage (RUSAGE_SELF, &rusage_end);

	libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
			  &elapsed_stime);

	printf ("Proc_Kernel  (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
		(unsigned long) data.proc_kernel.flags, PROFILE_COUNT,
		(long double) ELAPSED_UTIME / PROFILE_COUNT,
		(long double) ELAPSED_STIME / PROFILE_COUNT);

	getrusage (RUSAGE_SELF, &total_end);

	libgtop_timersub (&total_end.ru_utime, &total_start.ru_utime,
			  &elapsed_utime);

	libgtop_timersub (&total_end.ru_stime, &total_start.ru_stime,
			  &elapsed_stime);

	printf ("-------------------------------------------"
		"---------------\n");

	printf ("%-36s %9lu - %9lu\n\n", "TOTAL",
		ELAPSED_UTIME, ELAPSED_STIME);

	printf ("All timings are in clock ticks "
		"(1000000 ticks per second).\n\n");

	display_self_times();

	glibtop_close ();

	exit (0);
}
Exemple #10
0
static void append_sysinfo()
{
  struct glibtop_cpu cpu;
  struct glibtop_mem mem;
  struct glibtop_swap swap;
  struct glibtop_conntrack conntrack;
#ifndef NETLOAD_IFACE
  struct glibtop_netlist netlist;
  int i;
  char **ifnames;
#endif

  const time_t timestamp = time(NULL);
  if (timestamp == data_history[last_index].timestamp) return;

  glibtop_get_cpu(&cpu);
  glibtop_get_mem(&mem);
  glibtop_get_swap(&swap);
  glibtop_get_conntrack(&conntrack);

  uint64_t in = 0;
  uint64_t out = 0;
#ifndef NETLOAD_IFACE
  ifnames = glibtop_get_netlist(&netlist);
  for (i = 0; i < netlist.number; ++i)
#endif
  {
    struct glibtop_netload netload;
#ifndef NETLOAD_IFACE
    glibtop_get_netload (&netload, ifnames[i]);

    if (netload.is_loopback)
      continue;

    /* Skip interfaces without any IPv4/IPv6 address (or
       those with only a LINK ipv6 addr) However we need to
       be able to exclude these while still keeping the
       value so when they get online (with NetworkManager
       for example) we don't get a suddent peak.  Once we're
       able to get this, ignoring down interfaces will be
       possible too.  */
    if (!netload.has_addr || (netload.has_addr && netload.is_linklocal))
        continue;
#else
    glibtop_get_netload (&netload, NETLOAD_IFACE);
#endif

    /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
       to avoid spikes when they are brought up */

    in  += netload.bytes_in;
    out += netload.bytes_out;

#ifndef NETLOAD_IFACE
    free(ifnames[i]);
#endif
  }
#ifndef NETLOAD_IFACE
  free(ifnames);
#endif

#ifdef IW_IFACE
  struct glibtop_wireless wireless;
  glibtop_get_wireless(&wireless, IW_IFACE);
#endif

  pthread_mutex_lock(&info_mutex);
  last_index = (last_index+1) % MAX_HISTORY;
  data_history[last_index].cpu_total = (float)cpu.total;
  data_history[last_index].cpu_used = (float)(cpu.user + cpu.nice + cpu.sys);
  data_history[last_index].memory_usage = ((float)mem.used) / ((float)mem.total);
  data_history[last_index].swap_usage = swap.total == 0 ? 0.0f : ((float)swap.used) / ((float)swap.total);
  data_history[last_index].timestamp = timestamp;
  data_history[last_index].network_in = (float) in;
  data_history[last_index].network_out = (float) out;
  data_history[last_index].tcp_conns = (float) conntrack.tcp_conns;
  data_history[last_index].udp_conns = (float) conntrack.udp_conns;

#ifdef IW_IFACE
  data_history[last_index].iw_signal = (float) wireless.signal_dbm;
  data_history[last_index].iw_noise = (float) wireless.noise_dbm;
#else
  data_history[last_index].iw_signal = 0.0f;
  data_history[last_index].iw_noise = 0.0f;
#endif

  pthread_mutex_unlock(&info_mutex);
}
Exemple #11
0
void
GetNet (int Maximum, int data [4], LoadGraph *g)
{
    enum Types {
	IN_COUNT = 0,
	OUT_COUNT = 1,
	LOCAL_COUNT = 2,
	COUNT_TYPES = 3
	};

    static int ticks = 0;
    static gulong past[COUNT_TYPES] = {0};
    static AutoScaler scaler;

    gulong present[COUNT_TYPES] = {0};

    guint i;
    gchar **devices;
    glibtop_netlist netlist;


    if(ticks == 0)
    {
	autoscaler_init(&scaler, 60, 501);
    }


    devices = glibtop_get_netlist(&netlist);

    for(i = 0; i < netlist.number; ++i)
    {
	int index;
	glibtop_netload netload;

	glibtop_get_netload(&netload, devices[i]);

	g_return_if_fail((netload.flags & needed_netload_flags) == needed_netload_flags);

	if (!(netload.if_flags & (1L << GLIBTOP_IF_FLAGS_UP)))
	    continue;

	if (netload.if_flags & (1L << GLIBTOP_IF_FLAGS_LOOPBACK)) {
	    /* for loopback in and out are identical, so only count in */
	    present[LOCAL_COUNT] += netload.bytes_in;
	    continue;
	}

	/*
	 * Do not include virtual devices (VPN, PPPOE...) to avoid
	 * counting the same throughput several times.
	 */
	if (is_net_device_virtual(devices[i]))
		continue;

	present[IN_COUNT] += netload.bytes_in;
	present[OUT_COUNT] += netload.bytes_out;
    }

    g_strfreev(devices);
    netspeed_add(g->netspeed_in, present[IN_COUNT]);
    netspeed_add(g->netspeed_out, present[OUT_COUNT]);

    if(ticks < 2) /* avoid initial spike */
    {
	ticks++;
	memset(data, 0, COUNT_TYPES * sizeof data[0]);
    }
    else
    {
	int delta[COUNT_TYPES];
	int max;
	int total = 0;

	for (i = 0; i < COUNT_TYPES; i++)
	{
	    /* protect against weirdness */
	    if (present[i] >= past[i])
		    delta[i] = (present[i] - past[i]);
	    else
		    delta[i] = 0;
	    total += delta[i];
	}

	max = autoscaler_get_max(&scaler, total);

	for (i = 0; i < COUNT_TYPES; i++)
	    data[i]   = rint (Maximum * (float)delta[i]  / max);
    }

    //data[4] = Maximum - data[3] - data[2] - data[1] - data[0];
    data[COUNT_TYPES] = Maximum;
    for (i = 0; i < COUNT_TYPES; i++)
	data[COUNT_TYPES] -= data[i];

    memcpy(past, present, sizeof past);
}
}

void get_net(int traffic[2])
{
    TRACE("\n")
    TRACE("getting net traffic...\n")
    TRACE("selected interface is %s\n", selected_if_name)
    static int bytes_in_old = 0;
    static int bytes_out_old = 0;
    glibtop_netload netload;
    glibtop_netlist netlist;
    int bytes_in = 0;
    int bytes_out = 0;
    int i = 0;

    gchar **interfaces = glibtop_get_netlist(&netlist);

    for(i = 0; i < netlist.number; i++)
    {
        TRACE("\n")
        TRACE("processing interface %s\n", interfaces[i])
        if (strcmp("lo", interfaces[i]) == 0)
        {
            TRACE("skipping loopback interface\n")
            continue;
        }

        if(strcmp("all", selected_if_name) == 0 || strcmp(selected_if_name, interfaces[i]) == 0) {
            glibtop_get_netload(&netload, interfaces[i]);
            TRACE("in: %ld, out: %ld\n", netload.bytes_in, netload.bytes_out)
            bytes_in += netload.bytes_in;
static void
get_net (LoadGraph *g)
{
	glibtop_netlist netlist;
	char **ifnames;
	guint32 i;
	guint64 in = 0, out = 0;
	GTimeVal time;
	unsigned din, dout;
	gchar *text1;

	ifnames = glibtop_get_netlist(&netlist);

	for (i = 0; i < netlist.number; ++i)
	{
		glibtop_netload netload;
		glibtop_get_netload (&netload, ifnames[i]);

		if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
			continue;

		/* Skip interfaces without any IPv4/IPv6 address (or
		 those with only a LINK ipv6 addr) However we need to
		 be able to exclude these while still keeping the
		 value so when they get online (with NetworkManager
		 for example) we don't get a suddent peak.  Once we're
		 able to get this, ignoring down interfaces will be
		 possible too.  */
		if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
			 and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
		    and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
			continue;

		/* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
		   to avoid spikes when they are brought up */

		in  += netload.bytes_in;
		out += netload.bytes_out;
	}

	g_strfreev(ifnames);

	g_get_current_time (&time);

	if (in >= g->net.last_in && out >= g->net.last_out &&
	    g->net.time.tv_sec != 0) {
		float dtime;
		dtime = time.tv_sec - g->net.time.tv_sec +
			(float) (time.tv_usec - g->net.time.tv_usec) / G_USEC_PER_SEC;
		din   = static_cast<unsigned>((in  - g->net.last_in)  / dtime);
		dout  = static_cast<unsigned>((out - g->net.last_out) / dtime);
	} else {
		/* Don't calc anything if new data is less than old (interface
		   removed, counters reset, ...) or if it is the first time */
		din  = 0;
		dout = 0;
	}

	g->net.last_in  = in;
	g->net.last_out = out;
	g->net.time     = time;

	net_scale(g, din, dout);


	gtk_label_set_text (GTK_LABEL (g->labels.net_in), procman::format_rate(din).c_str());

	text1 = SI_gnome_vfs_format_file_size_for_display (in);
	gtk_label_set_text (GTK_LABEL (g->labels.net_in_total), text1);
	g_free (text1);

	gtk_label_set_text (GTK_LABEL (g->labels.net_out), procman::format_rate(dout).c_str());

	text1 = SI_gnome_vfs_format_file_size_for_display (out);
	gtk_label_set_text (GTK_LABEL (g->labels.net_out_total), text1);
	g_free (text1);
}