int i;
struct stats_filesystem *sfc;
int sep = FALSE;
+ char *dev_name;
xprintf(tab++, "\"filesystems\": [");
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
"\"Iused\": %llu, "
"\"%%Iused\": %.2f}",
DISPLAY_MOUNT(a->opt_flags) ? "mountpoint" : "filesystem",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+ dev_name,
(double) sfc->f_bfree / 1024 / 1024,
(double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
int i;
struct stats_filesystem *sfc;
char buf[64];
+ char *dev_name;
for (i = 0; i < a->nr[curr]; i++) {
-
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
snprintf(buf, sizeof(buf), "%.0f",
(double) sfc->f_bfree / 1024 / 1024);
- pmiPutValue("fs.util.fsfree",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.fsfree", dev_name, buf);
snprintf(buf, sizeof(buf), "%.0f",
(double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
- pmiPutValue("fs.util.fsused",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.fsused", dev_name, buf);
snprintf(buf, sizeof(buf), "%f",
sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
: 0.0);
- pmiPutValue("fs.util.fsused_pct",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.fsused_pct", dev_name, buf);
snprintf(buf, sizeof(buf), "%f",
sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
: 0.0);
- pmiPutValue("fs.util.ufsused_pct",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.ufsused_pct", dev_name, buf);
snprintf(buf, sizeof(buf), "%llu",
sfc->f_ffree);
- pmiPutValue("fs.util.ifree",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.ifree", dev_name, buf);
snprintf(buf, sizeof(buf), "%llu",
sfc->f_files - sfc->f_ffree);
- pmiPutValue("fs.util.iused",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.iused", dev_name, buf);
snprintf(buf, sizeof(buf), "%f",
sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
: 0.0);
- pmiPutValue("fs.util.iused_pct",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+ pmiPutValue("fs.util.iused_pct", dev_name, buf);
}
#endif /* HAVE_PCP */
}
{
int i;
struct stats_filesystem *sfc;
+ char *dev_name;
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
+ dev_name);
printf(" f_bfree; %llu;", sfc->f_bfree);
printf(" f_blocks; %llu;", sfc->f_blocks);
printf(" f_bavail; %llu;", sfc->f_bavail);
{
int i;
struct stats_filesystem *sfc;
+ char *dev_name;
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
render(isdb, pre, PT_USERND,
"%s\tMBfsfree",
"%s",
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
NOVAL,
(double) sfc->f_bfree / 1024 / 1024,
NULL);
render(isdb, pre, PT_USERND,
"%s\tMBfsused",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
NOVAL,
(double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
NULL);
render(isdb, pre, PT_NOFLAG,
"%s\t%%fsused",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
NOVAL,
sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
: 0.0,
render(isdb, pre, PT_NOFLAG,
"%s\t%%ufsused",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
NOVAL,
sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
: 0.0,
render(isdb, pre, PT_USEINT,
"%s\tIfree",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
sfc->f_ffree,
NOVAL,
NULL);
render(isdb, pre, PT_USEINT,
"%s\tIused",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
sfc->f_files - sfc->f_ffree,
NOVAL,
NULL);
(DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN),
"%s\t%%Iused",
NULL,
- cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+ cons(sv, dev_name, NOVAL),
NOVAL,
sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
: 0.0,
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
nr += add_list_item(&(a->item_list),
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+ get_fs_name_to_display(a, flags, sfc),
MAX_FS_LEN);
}
"%ufsused", "%fsused",
"Ifree/1000", "Iused/1000",
"%Iused"};
+ int nr_arrays = 8;
static double *spmin, *spmax;
static char **out;
static int *outsize;
- char *item_name;
+ char *dev_name, *item_name;
double tval;
int i, k, pos, restart;
/*
* Allocate arrays (#0..6) that will contain the graphs data
* and the min/max values.
- * Also allocate two additional arrays (#7..8) for each filesystem:
- * out + 7 will contain the filesystem name,
- * out + 8 will contain the mount point.
+ * Also allocate an additional arrays (#7) for each filesystem:
+ * out + 7 will contain the persistent or standard fs name, or mount point.
*/
- out = allocate_graph_lines(9 * a->item_list_sz, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(nr_arrays * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
/* Look for corresponding graph */
for (k = 0; k < a->item_list_sz; k++) {
- item_name = *(out + k * 9 + 7);
- if (!strcmp(sfc->fs_name, item_name))
+ item_name = *(out + k * nr_arrays + 7);
+ if (!strcmp(dev_name, item_name))
/* Graph found! */
break;
}
if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
for (k = 0; k < a->item_list_sz; k++) {
- item_name = *(out + k * 9 + 7);
+ item_name = *(out + k * nr_arrays + 7);
if (!strcmp(item_name, ""))
break;
}
}
}
- pos = k * 9;
+ pos = k * nr_arrays;
item_name = *(out + pos + 7);
if (!item_name[0]) {
/* Save filesystem name and mount point (if not already done) */
- strncpy(item_name, sfc->fs_name, CHUNKSIZE);
- item_name[CHUNKSIZE - 1] = '\0';
- item_name = *(out + pos + 8);
- strncpy(item_name, sfc->mountp, CHUNKSIZE);
+ strncpy(item_name, dev_name, CHUNKSIZE);
item_name[CHUNKSIZE - 1] = '\0';
}
for (i = 0; i < a->item_list_sz; i++) {
/* Check if there is something to display */
- pos = i * 9;
+ pos = i * nr_arrays;
if (!**(out + pos))
continue;
- /* Conversion B -> MB and inodes/1000 */
+ /* Conversion B -> MiB and inodes/1000 */
for (k = 0; k < 2; k++) {
*(spmin + pos + k) /= (1024 * 1024);
*(spmax + pos + k) /= (1024 * 1024);
*(spmax + pos + 4 + k) /= 1000;
}
- if (DISPLAY_MOUNT(a->opt_flags)) {
- item_name = *(out + pos + 8);
- }
- else {
- item_name = *(out + pos + 7);
- }
+ item_name = *(out + pos + 7);
if (draw_activity_graphs(a->g_nr, g_type, title, g_title, item_name, group,
spmin + pos, spmax + pos, out + pos, outsize + pos,
{
int i;
struct stats_filesystem *sfc;
+ char *dev_name;
xprintf(tab++, "<filesystems>");
for (i = 0; i < a->nr[curr]; i++) {
-
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
+ /* Get name to display (persistent or standard fs name, or mount point) */
+ dev_name = get_fs_name_to_display(a, flags, sfc);
+
if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_list_item(a->item_list,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
"Iused=\"%llu\" "
"Iused-percent=\"%.2f\"/>",
DISPLAY_MOUNT(a->opt_flags) ? "mountp" : "fsname",
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+ dev_name,
(double) sfc->f_bfree / 1024 / 1024,
(double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
/* f_blocks is not zero. But test it anyway ;-) */