11 #define NETIF_BASEDIR "/sys/class/net/"
15 void status_netif(GlobalData *g, char *ifname)
18 char text[16] = { 0 };
34 ifpathlen = sizeof(NETIF_BASEDIR) - 1 + strlen(ifname);
35 if (ifpathlen + 1 + sizeof("/statistics/rx_bytes") >= sizeof(ifpath)) {
36 statusError("status_netif",
37 "ifpath buffer too small",
41 strcpy(ifpath, NETIF_BASEDIR);
42 strcat(ifpath, ifname);
45 /* Is the interface up? */
46 if (access(ifpath, F_OK)) {
47 //s.color = "#BEBEBE"; // grey
52 strcpy(&ifpath[ifpathlen], "/carrier");
53 stlen = fileRead(stline, sizeof(stline), ifpath);
55 if (stline[0] == '1') {
56 s.color = "#FFFF00"; // yellow
58 //s.color = "#FF0000"; // red
65 strcpy(&ifpath[ifpathlen], "/statistics/rx_bytes");
66 stlen = fileRead(stline, sizeof(stline), ifpath);
71 strcpy(&ifpath[ifpathlen], "/statistics/tx_bytes");
72 stlen = fileRead(stline, sizeof(stline), ifpath);
74 ifsum += atof(stline);
78 for(ifsumpower = 0; ifsum >= 1024.0; ifsumpower++) {
82 snprintf(text, sizeof(text), "%s: %.*f %c",
84 ifsumpower ? ifsumpower - 1 : ifsumpower,
86 powerToChar(ifsumpower));
88 line_append_item(g, &s);