-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.c
51 lines (48 loc) · 1.49 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
int main(){
unsigned int data;
int i;
for (i = 0; i<4; i++){
/* The metric_index corresponds to the order in which
the metrics appear in the metric_info array
*/
switch (i) {
case 0:
{
FILE *fi;
fi = fopen("/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_data", "r");
if (fi != NULL ) fscanf(fi, "%u", &data);
fclose(fi);
}
break;
case 1:
{
FILE *fi;
fi = fopen("/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_data", "r");
if (fi != NULL ) fscanf(fi, "%u", &data);
fclose(fi);
}
break;
case 2:
{
FILE *fi;
fi = fopen("/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_packets", "r");
if (fi != NULL ) fscanf(fi, "%u", &data);
fclose(fi);
}
break;
case 3:
{
FILE *fi;
fi = fopen("/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_packets", "r");
if (fi != NULL ) fscanf(fi, "%u", &data);
fclose(fi);
}
break;
default: /* default case */
data = 0;
}
printf("data = %u", data);
}
return 0;
}