char line[1024];
char dev_name[MAX_NAME_LEN];
struct stats_disk *st_disk_i;
- unsigned int major, minor, rd_ticks, wr_ticks, dc_ticks, tot_ticks, rq_ticks;
+ unsigned int major, minor, rd_ticks, wr_ticks, dc_ticks, tot_ticks, rq_ticks, part_nr;
unsigned long rd_ios, wr_ios, dc_ios, rd_sec, wr_sec, dc_sec;
+ unsigned long long wwn[2];
__nr_t dsk_read = 0;
if ((fp = fopen(DISKSTATS, "r")) == NULL)
st_disk_i->dc_ticks = dc_ticks;
st_disk_i->tot_ticks = tot_ticks;
st_disk_i->rq_ticks = rq_ticks;
+
+ if (get_wwnid_from_pretty(dev_name, wwn, &part_nr) < 0) {
+ st_disk_i->wwn[0] = 0ULL;
+ }
+ else {
+ st_disk_i->wwn[0] = wwn[0];
+ st_disk_i->wwn[1] = wwn[1];
+ st_disk_i->part_nr = part_nr;
+ }
}
}
}
{
FILE *fp;
char line[1024];
+ static char format[256] = "";
int sw = FALSE;
if ((fp = fopen(NET_SNMP, "r")) == NULL)
if (!strncmp(line, "Icmp:", 5)) {
if (sw) {
- sscanf(line + 5, "%*u %lu %lu %lu %lu %lu %lu %*u %*u "
- "%*u %*u %*u %*u %*u %lu %lu %lu %lu %lu %lu",
+ sscanf(line + 5, format,
&st_net_eicmp->InErrors,
&st_net_eicmp->InDestUnreachs,
&st_net_eicmp->InTimeExcds,
break;
}
else {
+ if (!strlen(format)) {
+ if (strstr(line, "InCsumErrors")) {
+ /*
+ * New format: InCsumErrors field exists at position #3.
+ * Capture: 2,4,5,6,7,8,16,17,18,19,20,21
+ */
+ strcpy(format, "%*u %lu %*u %lu %lu %lu %lu %lu %*u %*u "
+ "%*u %*u %*u %*u %*u %lu %lu %lu %lu %lu %lu");
+ }
+ else {
+ /*
+ * Old format: InCsumErrors field doesn't exist.
+ * Capture: 2,3,4,5,6,7,15,16,17,18,19,20
+ */
+ strcpy(format, "%*u %lu %lu %lu %lu %lu %lu %*u %*u "
+ "%*u %*u %*u %*u %*u %lu %lu %lu %lu %lu %lu");
+
+ }
+ }
sw = TRUE;
}
}
unsigned long rx_frames, tx_frames, rx_words, tx_words;
/* Each host, if present, will have its own hostX entry within SYSFS_FCHOST */
- if ((dir = opendir(SYSFS_FCHOST)) == NULL)
+ if ((dir = __opendir(SYSFS_FCHOST)) == NULL)
return 0; /* No FC hosts */
/*
* Read each of the counters via sysfs, where they are
* returned as hex values (e.g. 0x72400).
*/
- while ((drd = readdir(dir)) != NULL) {
+ while ((drd = __readdir(dir)) != NULL) {
rx_frames = tx_frames = rx_words = tx_words = 0;
if (!strncmp(drd->d_name, "host", 4)) {
}
}
- closedir(dir);
+ __closedir(dir);
return fch_read;
}