/*
* sar/sadc: Report system activity
- * (C) 1999-2018 by Sebastien Godard (sysstat <at> orange.fr)
+ * (C) 1999-2019 by Sebastien Godard (sysstat <at> orange.fr)
*/
#ifndef _SA_H
*/
#define S_F_SINCE_BOOT 0x00000001
-#define S_F_SA_ROTAT 0x00000002
+#define S_F_SA_ROTAT 0x00000002 /* Only used by sadc */
+#define S_F_DEV_SID 0x00000002 /* Only used by sar/sadf */
#define S_F_DEV_PRETTY 0x00000004
#define S_F_FORCE_FILE 0x00000008
#define S_F_INTERVAL_SET 0x00000010
#define S_F_SVG_SHOW_INFO 0x00800000
#define S_F_HUMAN_READ 0x01000000
#define S_F_ZERO_OMIT 0x02000000
+#define S_F_SVG_SHOW_TOC 0x04000000
+#define S_F_FDATASYNC 0x08000000
+#define S_F_OPTION_A 0x10000000
+#define S_F_OPTION_P 0x20000000
+#define S_F_OPTION_I 0x40000000
#define WANT_SINCE_BOOT(m) (((m) & S_F_SINCE_BOOT) == S_F_SINCE_BOOT)
#define WANT_SA_ROTAT(m) (((m) & S_F_SA_ROTAT) == S_F_SA_ROTAT)
+#define USE_STABLE_ID(m) (((m) & S_F_DEV_SID) == S_F_DEV_SID)
#define USE_PRETTY_OPTION(m) (((m) & S_F_DEV_PRETTY) == S_F_DEV_PRETTY)
#define FORCE_FILE(m) (((m) & S_F_FORCE_FILE) == S_F_FORCE_FILE)
#define INTERVAL_SET(m) (((m) & S_F_INTERVAL_SET) == S_F_INTERVAL_SET)
#define DISPLAY_ZERO_OMIT(m) (((m) & S_F_ZERO_OMIT) == S_F_ZERO_OMIT)
#define DISPLAY_DEBUG_MODE(m) (((m) & S_F_RAW_DEBUG_MODE) == S_F_RAW_DEBUG_MODE)
#define AUTOSCALE_ON(m) (((m) & S_F_SVG_AUTOSCALE) == S_F_SVG_AUTOSCALE)
-#define DISPLAY_ONE_DAY(m) (((m) & S_F_SVG_ONE_DAY) == S_F_SVG_ONE_DAY)
+#define DISPLAY_ONE_DAY(m) (((m) & S_F_SVG_ONE_DAY) == S_F_SVG_ONE_DAY)
#define DISPLAY_IDLE(m) (((m) & S_F_SVG_SHOW_IDLE) == S_F_SVG_SHOW_IDLE)
#define DISPLAY_INFO(m) (((m) & S_F_SVG_SHOW_INFO) == S_F_SVG_SHOW_INFO)
-#define DISPLAY_UNIT(m) (((m) & S_F_UNIT) == S_F_UNIT)
-#define SET_CANVAS_HEIGHT(m) (((m) & S_F_SVG_HEIGHT) == S_F_SVG_HEIGHT)
-#define PACK_VIEWS(m) (((m) & S_F_SVG_PACKED) == S_F_SVG_PACKED)
-#define DISPLAY_HUMAN_READ(m) (((m) & S_F_HUMAN_READ) == S_F_HUMAN_READ)
+#define DISPLAY_UNIT(m) (((m) & S_F_UNIT) == S_F_UNIT)
+#define SET_CANVAS_HEIGHT(m) (((m) & S_F_SVG_HEIGHT) == S_F_SVG_HEIGHT)
+#define PACK_VIEWS(m) (((m) & S_F_SVG_PACKED) == S_F_SVG_PACKED)
+#define DISPLAY_HUMAN_READ(m) (((m) & S_F_HUMAN_READ) == S_F_HUMAN_READ)
+#define DISPLAY_TOC(m) (((m) & S_F_SVG_SHOW_TOC) == S_F_SVG_SHOW_TOC)
+#define FDATASYNC(m) (((m) & S_F_FDATASYNC) == S_F_FDATASYNC)
+#define USE_OPTION_A(m) (((m) & S_F_OPTION_A) == S_F_OPTION_A)
+#define USE_OPTION_P(m) (((m) & S_F_OPTION_P) == S_F_OPTION_P)
+#define USE_OPTION_I(m) (((m) & S_F_OPTION_I) == S_F_OPTION_I)
#define AO_F_NULL 0x00000000
/* Keywords */
#define K_A_NULL "A_NULL"
-#define K_XALL "XALL"
-#define K_SUM "SUM"
+#define K_CPU "CPU"
#define K_DEV "DEV"
#define K_EDEV "EDEV"
-#define K_NFS "NFS"
-#define K_NFSD "NFSD"
-#define K_SOCK "SOCK"
-#define K_IP "IP"
-#define K_EIP "EIP"
-#define K_ICMP "ICMP"
#define K_EICMP "EICMP"
-#define K_TCP "TCP"
-#define K_ETCP "ETCP"
-#define K_UDP "UDP"
-#define K_SOCK6 "SOCK6"
-#define K_IP6 "IP6"
-#define K_EIP6 "EIP6"
-#define K_ICMP6 "ICMP6"
#define K_EICMP6 "EICMP6"
-#define K_UDP6 "UDP6"
-#define K_CPU "CPU"
+#define K_EIP "EIP"
+#define K_EIP6 "EIP6"
+#define K_ETCP "ETCP"
#define K_FAN "FAN"
-#define K_TEMP "TEMP"
-#define K_IN "IN"
+#define K_FC "FC"
#define K_FREQ "FREQ"
+#define K_ICMP "ICMP"
+#define K_ICMP6 "ICMP6"
+#define K_IN "IN"
+#define K_IP "IP"
+#define K_IP6 "IP6"
#define K_MOUNT "MOUNT"
-#define K_FC "FC"
+#define K_NFS "NFS"
+#define K_NFSD "NFSD"
+#define K_SID "SID"
+#define K_SOCK "SOCK"
+#define K_SOCK6 "SOCK6"
#define K_SOFT "SOFT"
+#define K_SUM "SUM"
+#define K_TCP "TCP"
+#define K_TEMP "TEMP"
+#define K_UDP "UDP"
+#define K_UDP6 "UDP6"
+#define K_XALL "XALL"
#define K_INT "INT"
#define K_DISK "DISK"
#define K_DEBUG "debug"
#define K_HEIGHT "height="
#define K_PACKED "packed"
+#define K_SHOWTOC "showtoc"
+#define K_CUSTOMCOL "customcol"
+#define K_BWCOL "bwcol"
+#define K_PCPARCHIVE "pcparchive="
+
+/* Environment variables */
+#define ENV_COLORS_PALETTE "S_COLORS_PALETTE"
/* Groups of activities */
#define G_DEFAULT 0x00
#define END_OF_DATA_UNEXPECTED 1
#define INCONSISTENT_INPUT_DATA 2
+#define UEOF_STOP 0
+#define UEOF_CONT 1
+
#define CLOSE_XML_MARKUP 0
#define OPEN_XML_MARKUP 1
unsigned long long ust_time_first; /* Time (in seconds since the epoch) for first sample */
int graph_no; /* Total number of views already displayed */
int restart; /* TRUE if we have just met a RESTART record */
- __nr_t nr_max; /* Maximum number of items for this activity */
+ int nr_act_dispd; /* Number of activities that will be displayed */
struct file_header *file_hdr; /* Pointer on file header structure */
};
struct svg_hdr_parm {
int graph_nr; /* Number of rows of views to display or canvas height entered on the command line */
int views_per_row; /* Maximum number of views on a single row */
+ int nr_act_dispd; /* Number of activities that will be displayed */
};
/*
*
* If the record header's type is R_COMMENT then we find only a comment
* following the record_header structure.
+ *
* If the record_header's type is R_RESTART then we find only the number of CPU
* (of type __nr_t) of the machine following the record_header structure.
+ * This number is 1 for 1 CPU and not an SMP kernel (CPU "all"),
+ * 2 for 1 CPU and SMP kernel (CPU "all" and CPU 0), etc.
+ * Of course we display the real number of CPU (e.g. "1" for 1 CPU and SMP
+ * kernel) with the LINUX RESTART message.
***************************************************************************
*/
* Indicate that this activity may have sub-items.
*/
#define AO_MATRIX 0x80
+/*
+ * Indicate that a list of devices has been entered on the command
+ * line for this activity (see options --dev=, --iface=, ...)
+ */
+#define AO_LIST_ON_CMDLINE 0x100
+/*
+ * Indicate that the number of items for this activity should always
+ * be counted, even if the activity is not collected.
+ */
+#define AO_ALWAYS_COUNTED 0x200
#define IS_COLLECTED(m) (((m) & AO_COLLECTED) == AO_COLLECTED)
#define IS_SELECTED(m) (((m) & AO_SELECTED) == AO_SELECTED)
#define HAS_MULTIPLE_OUTPUTS(m) (((m) & AO_MULTIPLE_OUTPUTS) == AO_MULTIPLE_OUTPUTS)
#define ONE_GRAPH_PER_ITEM(m) (((m) & AO_GRAPH_PER_ITEM) == AO_GRAPH_PER_ITEM)
#define IS_MATRIX(m) (((m) & AO_MATRIX) == AO_MATRIX)
+#define HAS_LIST_ON_CMDLINE(m) (((m) & AO_LIST_ON_CMDLINE) == AO_LIST_ON_CMDLINE)
+#define ALWAYS_COUNT_ITEMS(m) (((m) & AO_ALWAYS_COUNTED) == AO_ALWAYS_COUNTED)
#define _buf0 buf[0]
#define _nr0 nr[0]
* This function is used by sadf to display activity statistics in raw format.
*/
__print_funct_t (*f_raw_print) (struct activity *, char *, int);
+ /*
+ * This function is used by sadf to display activity statistics in PCP format.
+ */
+ __print_funct_t (*f_pcp_print) (struct activity *, int, unsigned long long,
+ struct record_header *);
+ /*
+ * This function is used by sadf to count the number of new items in current
+ * sample and add them to the linked list @item_list.
+ */
+ __nr_t (*f_count_new) (struct activity *, int);
+ /*
+ * Linked list containing item names. This is either all the different items
+ * found in a file for activities that have a @f_count_function() (used by sadf),
+ * or a list entered on the command line (used by sadf and sar).
+ */
+ struct sa_item *item_list;
+ /*
+ * Number of different items found in file (calculated by sadf).
+ * This is also the number of items in @item_list if this list exists.
+ */
+ __nr_t item_list_sz;
/*
* Header string displayed by sadf -d.
* Header lines for each output (for activities with multiple outputs) are
* (eg. -r ALL) begins with a '&' character.
*/
char *hdr_line;
+ /*
+ * Description of activity.
+ */
+ char *desc;
/*
* Name of activity.
*/
struct activity * [], unsigned int [], struct file_activity *);
/*
* This function defines the statistics part of the report.
- * Used only with textual (XML-like) reports.
+ * Used only with textual (XML-like) reports and PCP archives.
*/
- __printf_funct_t (*f_statistics) (int *, int);
+ __printf_funct_t (*f_statistics) (int *, int, struct activity * [], unsigned int []);
/*
* This function defines the timestamp part of the report.
* Used only with textual (XML-like) reports.
*/
__tm_funct_t (*f_timestamp) (void *, int, char *, char *, unsigned long long,
- struct file_header *, unsigned int);
+ struct record_header *, struct file_header *, unsigned int);
/*
* This function displays the restart messages.
*/
- __printf_funct_t (*f_restart) (int *, int, char *, char *, int, struct file_header *);
+ __printf_funct_t (*f_restart) (int *, int, char *, char *, int,
+ struct file_header *, struct record_header *);
/*
* This function displays the comments.
*/
- __printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *, struct file_header *);
+ __printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *,
+ struct file_header *, struct record_header *);
+ /*
+ * This is the main function used to display all the statistics for current format.
+ */
+ void (*f_display) (int, char *, struct file_activity *, struct file_magic *,
+ struct tm *, void *);
};
+
/* Possible actions for functions used to display reports */
#define F_BEGIN 0x01
#define F_MAIN 0x02
* ^
* 1 | General header
* v
+ * ^
+ * 9 | One line from table of contents (if any)
+ * v
* ^ ^ ^
* | | 4 | Graph title
* | | v
/* #5 */
#define SVG_G_YSIZE 200
/* #1 */
-#define SVG_H_YSIZE 50
+#define SVG_H_YSIZE 60
/* #4 */
#define SVG_M_YSIZE 50
/* #2 */
#define SVG_T_YSIZE 310
/* #3 */
#define SVG_V_YSIZE 300
+/* #9 */
+#define SVG_C_YSIZE 20
/* Grid: Nr of horizontal lines */
#define SVG_H_GRIDNR 3
/* Maximum number of horizontal lines for the background grid */
#define MAX_HLINES_NR 10
+/* Color palette constants */
+#define SVG_COLORS_IDX_MASK 0x0f
+#define SVG_COL_PALETTE_SIZE 24
+#define SVG_COL_PALETTE_NR 3
+#define SVG_COL_BCKGRD_IDX 16
+#define SVG_COL_AXIS_IDX 17
+#define SVG_COL_GRID_IDX 18
+#define SVG_COL_TITLE_IDX 19
+#define SVG_COL_INFO_IDX 20
+#define SVG_COL_DEFAULT_IDX 21
+#define SVG_COL_HEADER_IDX 22
+#define SVG_COL_ERROR_IDX 23
+
+#define SVG_DEFAULT_COL_PALETTE 0
+#define SVG_CUSTOM_COL_PALETTE 1
+#define SVG_BW_COL_PALETTE 2
+
#define MAYBE 0x80
/*
int use;
};
-/* List of devices entered on the command line */
-struct sa_dlist {
- /* Device name */
- char dev_name[MAX_NAME_LEN];
+/* Structure for items in list */
+struct sa_item {
+ char *item_name;
+ struct sa_item *next;
};
-#define SA_DLIST_SIZE (sizeof(struct sa_dlist))
-
/*
***************************************************************************
***************************************************************************
*/
+/*
+ * Prototypes used to count new items
+ */
+__nr_t count_new_net_dev
+ (struct activity *, int);
+__nr_t count_new_net_edev
+ (struct activity *, int);
+__nr_t count_new_filesystem
+ (struct activity *, int);
+__nr_t count_new_fchost
+ (struct activity *, int);
+__nr_t count_new_disk
+ (struct activity *, int);
+
/* Functions used to count number of items */
__nr_t wrap_get_cpu_nr
(struct activity *);
(struct activity * [], unsigned int, int);
int get_activity_position
(struct activity * [], unsigned int, int);
-void set_default_file
- (char *, int, int);
void handle_invalid_sa_file
(int, struct file_magic *, char *, int);
void print_collect_error
(void);
+int set_default_file
+ (char *, int, int);
+int write_all
+ (int, const void *, int);
#ifndef SOURCE_SADC
+int add_list_item
+ (struct sa_item **, char *, int);
void allocate_bitmaps
(struct activity * []);
void allocate_structures
int check_disk_reg
(struct activity *, int, int, int);
void check_file_actlst
- (int *, char *, struct activity * [], struct file_magic *, struct file_header *,
- struct file_activity **, unsigned int [], int, int *, int *);
+ (int *, char *, struct activity * [], unsigned int, struct file_magic *,
+ struct file_header *, struct file_activity **, unsigned int [], int, int *, int *);
int check_net_dev_reg
(struct activity *, int, int, int);
int check_net_edev_reg
void copy_structures
(struct activity * [], unsigned int [], struct record_header [], int, int);
int datecmp
- (struct tm *, struct tstamp *);
+ (struct tm *, struct tstamp *, int);
void display_sa_file_version
(FILE *, struct file_magic *);
void free_bitmaps
char *get_devname
(unsigned int, unsigned int, int);
char *get_sa_devname
- (unsigned int, unsigned int, unsigned int);
+ (unsigned int, unsigned int, unsigned long long [], unsigned int, unsigned int);
void get_file_timestamp_struct
(unsigned int, struct tm *, struct file_header *);
unsigned long long get_global_cpu_statistics
(struct activity *, int, int, unsigned int, unsigned char []);
void get_itv_value
(struct record_header *, struct record_header *, unsigned long long *);
+void init_custom_color_palette
+ (void);
int next_slice
(unsigned long long, unsigned long long, int, long);
void parse_sa_devices
- (char *, struct sa_dlist **, int *, int *, int);
+ (char *, struct activity *, int, int *, int);
int parse_sar_opt
(char * [], int *, struct activity * [], unsigned int *, int);
int parse_sar_I_opt
- (char * [], int *, struct activity * []);
+ (char * [], int *, unsigned int *, struct activity * []);
int parse_sa_P_opt
(char * [], int *, unsigned int *, struct activity * []);
int parse_sar_m_opt
void print_report_hdr
(unsigned int, struct tm *, struct file_header *);
void print_sar_comment
- (int *, int, char *, char *, int, char *, struct file_header *);
+ (int *, int, char *, char *, int, char *, struct file_header *,
+ struct record_header *);
__printf_funct_t print_sar_restart
- (int *, int, char *, char *, int, struct file_header *);
+ (int *, int, char *, char *, int, struct file_header *, struct record_header *);
int print_special_record
(struct record_header *, unsigned int, struct tstamp *, struct tstamp *,
- int, int, struct tm *, struct tm *, char *, int, struct file_magic *,
+ int, int, struct tm *, char *, int, struct file_magic *,
struct file_header *, struct activity * [], struct report_format *, int, int);
-void read_file_stat_bunch
+int read_file_stat_bunch
(struct activity * [], int, int, int, struct file_activity *, int, int,
- char *, struct file_magic *);
+ char *, struct file_magic *, int);
__nr_t read_nr_value
(int, char *, struct file_magic *, int, int, int);
int read_record_hdr
- (int, void *, struct record_header *, struct file_header *, int, int);
+ (int, void *, struct record_header *, struct file_header *, int, int,
+ int, size_t);
void reallocate_all_buffers
(struct activity *, __nr_t);
-void remap_struct
- (unsigned int [], unsigned int [], void *, unsigned int);
void replace_nonprintable_char
(int, char *);
int sa_fread
- (int, void *, size_t, int);
+ (int, void *, size_t, int, int);
int sa_get_record_timestamp_struct
- (unsigned int, struct record_header *, struct tm *, struct tm *);
+ (unsigned int, struct record_header *, struct tm *);
int sa_open_read_magic
(int *, char *, struct file_magic *, int, int *, int);
-int search_sa_dlist
- (struct sa_dlist *, int, char *);
+int search_list_item
+ (struct sa_item *, char *);
void select_all_activities
(struct activity * []);
void select_default_activity
(struct activity * []);
-void set_bitmap
- (unsigned char [], unsigned char, unsigned int);
+void set_bitmaps
+ (struct activity * [], unsigned int *);
void set_hdr_rectime
(unsigned int, struct tm *, struct file_header *);
void set_record_timestamp_string