]> granicus.if.org Git - sysstat/commitdiff
sadf -H: Display all the activities in file
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 31 Dec 2017 08:13:09 +0000 (09:13 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 31 Dec 2017 08:13:09 +0000 (09:13 +0100)
Make sadf -H display all the activities present in file, whether known
or unknown.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa.h
sadf.c
sadf.h
sadf_misc.c

diff --git a/sa.h b/sa.h
index b9eb4119263258bb832bea6df2400e0d52690787..6b4c2add1ae21cc41647d7226dc3c013f46b9b73 100644 (file)
--- a/sa.h
+++ b/sa.h
@@ -957,7 +957,7 @@ struct report_format {
         * (data displayed once at the beginning of the report).
         */
        __printf_funct_t (*f_header) (void *, int, char *, struct file_magic *, struct file_header *,
-                                     struct activity * [], unsigned int []);
+                                     struct activity * [], unsigned int [], struct file_activity *);
        /*
         * This function defines the statistics part of the report.
         * Used only with textual (XML-like) reports.
diff --git a/sadf.c b/sadf.c
index be25da16aa96b49153dd601de3ae24fe2eab1387..6f3ae03213af5c21f5c7564ee0a5d024680d9a9e 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -940,7 +940,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
        /* Print header (eg. XML file header) */
        if (*fmt[f_position]->f_header) {
                (*fmt[f_position]->f_header)(&tab, F_BEGIN, file, file_magic,
-                                            &file_hdr, act, id_seq);
+                                            &file_hdr, act, id_seq, file_actlst);
        }
 
        /* Process activities */
@@ -1059,7 +1059,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
        /* Print header trailer */
        if (*fmt[f_position]->f_header) {
                (*fmt[f_position]->f_header)(&tab, F_END, file, file_magic,
-                                            &file_hdr, act, id_seq);
+                                            &file_hdr, act, id_seq, file_actlst);
        }
 }
 
@@ -1243,7 +1243,7 @@ void logic3_display_loop(int ifd, struct file_activity *file_actlst,
        /* Print SVG header */
        if (*fmt[f_position]->f_header) {
                (*fmt[f_position]->f_header)(&parm, F_BEGIN + F_MAIN, file, file_magic,
-                                            &file_hdr, act, id_seq);
+                                            &file_hdr, act, id_seq, file_actlst);
        }
 
        /*
@@ -1311,7 +1311,7 @@ close_svg:
        /* Print SVG trailer */
        if (*fmt[f_position]->f_header) {
                (*fmt[f_position]->f_header)(&parm, F_END, file, file_magic,
-                                            &file_hdr, act, id_seq);
+                                            &file_hdr, act, id_seq, file_actlst);
        }
 }
 
@@ -1341,7 +1341,7 @@ void read_stats_from_file(char dfile[])
                if (*fmt[f_position]->f_header) {
                        /* Display only data file header then exit */
                        (*fmt[f_position]->f_header)(&tab, F_BEGIN + F_END, dfile, &file_magic,
-                                                    &file_hdr, act, id_seq);
+                                                    &file_hdr, act, id_seq, file_actlst);
                }
                exit(0);
        }
diff --git a/sadf.h b/sadf.h
index 7be036dc72ee73ef883a1fd7fd08005ac389f323..c3d99f698941d940a49638265c0bd72914ee4643 100644 (file)
--- a/sadf.h
+++ b/sadf.h
@@ -183,15 +183,15 @@ __tm_funct_t print_raw_timestamp
  */
 __printf_funct_t print_xml_header
        (void *, int, char *, struct file_magic *, struct file_header *,
-        struct activity * [], unsigned int []);
+        struct activity * [], unsigned int [], struct file_activity *);
 __printf_funct_t print_json_header
        (void *, int, char *, struct file_magic *, struct file_header *,
-        struct activity * [], unsigned int []);
+        struct activity * [], unsigned int [], struct file_activity *);
 __printf_funct_t print_hdr_header
        (void *, int, char *, struct file_magic *, struct file_header *,
-        struct activity * [], unsigned int []);
+        struct activity * [], unsigned int [], struct file_activity *);
 __printf_funct_t print_svg_header
        (void *, int, char *, struct file_magic *, struct file_header *,
-        struct activity * [], unsigned int []);
+        struct activity * [], unsigned int [], struct file_activity *);
 
 #endif  /* _SADF_H */
index b64fd75b6df287f6d63a65c0dc33bf0f4f018ce5..5f837eeb059c3efe2ee5faf809f9a815b1ecd41d 100644 (file)
@@ -682,6 +682,7 @@ __tm_funct_t print_raw_timestamp(void *parm, int action, char *cur_date,
  * @file_hdr   System activity file standard header.
  * @act                Array of activities (unused here).
  * @id_seq     Activity sequence (unused here).
+ * @file_actlst        List of (known or unknown) activities in file (unused here).
  *
  * OUT:
  * @parm       Number of tabulations.
@@ -690,7 +691,8 @@ __tm_funct_t print_raw_timestamp(void *parm, int action, char *cur_date,
 __printf_funct_t print_xml_header(void *parm, int action, char *dfile,
                                  struct file_magic *file_magic,
                                  struct file_header *file_hdr,
-                                 struct activity *act[], unsigned int id_seq[])
+                                 struct activity *act[], unsigned int id_seq[],
+                                 struct file_activity *file_actlst)
 {
        struct tm rectime, *loc_t;
        char cur_time[TIMESTAMP_LEN];
@@ -748,6 +750,7 @@ __printf_funct_t print_xml_header(void *parm, int action, char *dfile,
  * @file_hdr   System activity file standard header.
  * @act                Array of activities (unused here).
  * @id_seq     Activity sequence (unused here).
+ * @file_actlst        List of (known or unknown) activities in file (unused here).
  *
  * OUT:
  * @parm       Number of tabulations.
@@ -756,7 +759,8 @@ __printf_funct_t print_xml_header(void *parm, int action, char *dfile,
 __printf_funct_t print_json_header(void *parm, int action, char *dfile,
                                   struct file_magic *file_magic,
                                   struct file_header *file_hdr,
-                                  struct activity *act[], unsigned int id_seq[])
+                                  struct activity *act[], unsigned int id_seq[],
+                                  struct file_activity *file_actlst)
 {
        struct tm rectime, *loc_t;
        char cur_time[TIMESTAMP_LEN];
@@ -807,15 +811,18 @@ __printf_funct_t print_json_header(void *parm, int action, char *dfile,
  * @file_hdr   System activity file standard header.
  * @act                Array of activities.
  * @id_seq     Activity sequence.
+ * @file_actlst        List of (known or unknown) activities in file.
  ***************************************************************************
  */
 __printf_funct_t print_hdr_header(void *parm, int action, char *dfile,
                                  struct file_magic *file_magic,
                                  struct file_header *file_hdr,
-                                 struct activity *act[], unsigned int id_seq[])
+                                 struct activity *act[], unsigned int id_seq[],
+                                 struct file_activity *file_actlst)
 {
        int i, p;
        struct tm rectime, *loc_t;
+       struct file_activity *fal;
        char cur_time[TIMESTAMP_LEN];
 
        /* Actions F_MAIN and F_END ignored */
@@ -853,24 +860,27 @@ __printf_funct_t print_hdr_header(void *parm, int action, char *dfile,
 
                printf(_("Size of a long int: %d\n"), file_hdr->sa_sizeof_long);
                printf("HZ = %lu\n", file_hdr->sa_hz);
-
-               /* Number of activities in file */
-               printf("sa_act_nr: %u\n",
+               printf(_("Number of activities in file: %u\n"),
                       file_hdr->sa_act_nr);
 
                printf(_("List of activities:\n"));
+               fal = file_actlst;
+               for (i = 0; i < file_hdr->sa_act_nr; i++, fal++) {
 
-               for (i = 0; i < NR_ACT; i++) {
-                       if (!id_seq[i])
-                               continue;
-
-                       p = get_activity_position(act, id_seq[i], EXIT_IF_NOT_FOUND);
+                       p = get_activity_position(act, fal->id, RESUME_IF_NOT_FOUND);
 
-                       printf("%02d: %s\t(x%d)", act[p]->id, act[p]->name, act[p]->nr_ini);
-                       if (IS_MATRIX(act[p]->options)) {
-                               printf("\t(x%d)", act[p]->nr2);
+                       printf("%02d: ", fal->id);
+                       if (p >= 0) {
+                               printf("%-15s", act[p]->name);
+                       }
+                       else {
+                               printf(_("Unknown activity"));
+                       }
+                       printf("\t(x%d)", fal->nr);
+                       if (fal->nr2 > 1) {
+                               printf("\t(x%d)", fal->nr2);
                        }
-                       if (act[p]->magic == ACTIVITY_MAGIC_UNKNOWN) {
+                       if ((p >= 0) && (act[p]->magic == ACTIVITY_MAGIC_UNKNOWN)) {
                                printf(_("\t[Unknown activity format]"));
                        }
                        printf("\n");
@@ -892,12 +902,14 @@ __printf_funct_t print_hdr_header(void *parm, int action, char *dfile,
  * @file_hdr   System activity file standard header.
  * @act                Array of activities (unused here).
  * @id_seq     Activity sequence (unused here).
+ * @file_actlst        List of (known or unknown) activities in file (unused here).
  ***************************************************************************
  */
 __printf_funct_t print_svg_header(void *parm, int action, char *dfile,
                                  struct file_magic *file_magic,
                                  struct file_header *file_hdr,
-                                 struct activity *act[], unsigned int id_seq[])
+                                 struct activity *act[], unsigned int id_seq[],
+                                 struct file_activity *file_actlst)
 {
        struct svg_hdr_parm *hdr_parm = (struct svg_hdr_parm *) parm;