Skip to content
Snippets Groups Projects
Commit aa9ebc1b authored by Georges Da Costa's avatar Georges Da Costa
Browse files

Adds the capability to detect the network device automatically

parent 426c7e23
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,7 @@ void usage(char** argv) {
printf("-p activates performance counters\n");
printf(" perf_list is coma separated list of performance counters without space. Ex: instructions,cache_misses\n");
printf("-l lists the possible performance counters and quits\n");
printf("-d activates network monitoring\n");
printf("-d activates network monitoring (if network_device is X tries to detect it automatically)\n");
printf("-s activates statistics of overhead in nanoseconds\n");
printf("-u activates report of system load\n");
exit(EXIT_SUCCESS);
......
......@@ -20,10 +20,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char **init_network(char* dev) {
if(dev==NULL)
return NULL;
if(strcmp(dev,"X")==0) {
FILE* f = fopen("/proc/net/route", "r");
char buffer[1000];
fgets(buffer, 999, f);
fgets(buffer, 999, f);
char *end_of_dev = index(buffer, '\t');
*end_of_dev='\0';
dev = buffer;
}
char *filenames[] = {"/sys/class/net/%s/statistics/rx_packets",
"/sys/class/net/%s/statistics/rx_bytes",
"/sys/class/net/%s/statistics/tx_packets",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment