From: Sebastien GODARD Date: Fri, 12 Apr 2019 16:29:50 +0000 (+0200) Subject: sadf: Add new flag FO_ITEM_LIST X-Git-Tag: v12.1.4~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd3ca2084daa8a7ff32ff28b699bcbcb09732285;p=sysstat sadf: Add new flag FO_ITEM_LIST This flag indicates that the linked list containing items names should be created. Signed-off-by: Sebastien GODARD --- diff --git a/format.c b/format.c index 7d6987a..64c578a 100644 --- a/format.c +++ b/format.c @@ -155,7 +155,8 @@ struct report_format raw_fmt = { */ struct report_format pcp_fmt = { .id = F_PCP_OUTPUT, - .options = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME, + .options = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME + + FO_ITEM_LIST, .f_header = print_pcp_header, .f_statistics = print_pcp_statistics, .f_timestamp = print_pcp_timestamp, diff --git a/sadf.c b/sadf.c index 8e7100e..e19cb85 100644 --- a/sadf.c +++ b/sadf.c @@ -1025,9 +1025,11 @@ void logic1_display_loop(int ifd, char *file, struct file_activity *file_actlst, long cnt = 1; char *pcparchive = (char *) dparm; - /* Count items in file. Needed only for PCP output */ - if (format == F_PCP_OUTPUT) { - count_file_items(ifd, file, file_magic, file_actlst, rectime, loctime); + if (CREATE_ITEM_LIST(fmt[f_position]->options)) { + /* Count items in file (e.g. for PCP output) */ + if (!count_file_items(ifd, file, file_magic, file_actlst, rectime, loctime)) + /* No record to display */ + return; } /* Save current file position */ diff --git a/sadf.h b/sadf.h index e93dd53..7e96abd 100644 --- a/sadf.h +++ b/sadf.h @@ -96,6 +96,12 @@ */ #define FO_NO_TRUE_TIME 0x100 +/* + * Indicate that the number of different items should be counted and + * a list created (see @item_list and @item_list_sz in struct activity). + */ +#define FO_ITEM_LIST 0x200 + #define SET_LC_NUMERIC_C(m) (((m) & FO_LC_NUMERIC_C) == FO_LC_NUMERIC_C) #define ACCEPT_HEADER_ONLY(m) (((m) & FO_HEADER_ONLY) == FO_HEADER_ONLY) #define ACCEPT_BAD_FILE_FORMAT(m) (((m) & FO_BAD_FILE_FORMAT) == FO_BAD_FILE_FORMAT) @@ -105,6 +111,7 @@ #define DISPLAY_FIELD_LIST(m) (((m) & FO_FIELD_LIST) == FO_FIELD_LIST) #define TEST_MARKUP(m) (((m) & FO_TEST_MARKUP) == FO_TEST_MARKUP) #define REJECT_TRUE_TIME(m) (((m) & FO_NO_TRUE_TIME) == FO_NO_TRUE_TIME) +#define CREATE_ITEM_LIST(m) (((m) & FO_ITEM_LIST) == FO_ITEM_LIST) /*