.desc = "CPU utilization",
#endif
.name = "A_CPU",
+ .item_list_sz = 0,
.g_nr = 1,
.nr_ini = -1,
.nr2 = 1,
.desc = "Task creation and switching activity",
#endif
.name = "A_PCSW",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "Interrupts statistics",
#endif
.name = "A_IRQ",
+ .item_list_sz = 0,
.g_nr = 0,
.nr_ini = -1,
.nr2 = 1,
.desc = "Swap activity",
#endif
.name = "A_SWAP",
+ .item_list_sz = 0,
.g_nr = 1,
.nr_ini = 1,
.nr2 = 1,
.desc = "Paging activity",
#endif
.name = "A_PAGE",
+ .item_list_sz = 0,
.g_nr = 3,
.nr_ini = 1,
.nr2 = 1,
.desc = "I/O and transfer rate statistics",
#endif
.name = "A_IO",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "Memory and/or swap utilization",
#endif
.name = "A_MEMORY",
+ .item_list_sz = 0,
.g_nr = 9,
.nr_ini = 1,
.nr2 = 1,
.desc = "Kernel tables statistics",
#endif
.name = "A_KTABLES",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "Queue length and load average statistics",
#endif
.name = "A_QUEUE",
+ .item_list_sz = 0,
.g_nr = 3,
.nr_ini = 1,
.nr2 = 1,
.desc = "TTY devices statistics",
#endif
.name = "A_SERIAL",
+ .item_list_sz = 0,
.g_nr = 0,
.nr_ini = -1,
.nr2 = 1,
.desc = "Block devices statistics",
#endif
.name = "A_DISK",
+ .item_list_sz = 0,
.g_nr = 5,
.nr_ini = -1,
.nr2 = 1,
.desc = "Network interfaces statistics",
#endif
.name = "A_NET_DEV",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = -1,
.nr2 = 1,
.desc = "Network interfaces errors statistics",
#endif
.name = "A_NET_EDEV",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = -1,
.nr2 = 1,
.desc = "NFS client statistics",
#endif
.name = "A_NET_NFS",
+ .item_list_sz = 0,
.g_nr = 3,
.nr_ini = 1,
.nr2 = 1,
.desc = "NFS server statistics",
#endif
.name = "A_NET_NFSD",
+ .item_list_sz = 0,
.g_nr = 5,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv4 sockets statistics",
#endif
.name = "A_NET_SOCK",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv4 traffic statistics",
#endif
.name = "A_NET_IP",
+ .item_list_sz = 0,
.g_nr = 3,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv4 traffic errors statistics",
#endif
.name = "A_NET_EIP",
+ .item_list_sz = 0,
.g_nr = 3,
.nr_ini = 1,
.nr2 = 1,
.desc = "ICMPv4 traffic statistics",
#endif
.name = "A_NET_ICMP",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = 1,
.nr2 = 1,
.desc = "ICMPv4 traffic errors statistics",
#endif
.name = "A_NET_EICMP",
+ .item_list_sz = 0,
.g_nr = 6,
.nr_ini = 1,
.nr2 = 1,
.desc = "TCPv4 traffic statistics",
#endif
.name = "A_NET_TCP",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "TCPv4 traffic errors statistics",
#endif
.name = "A_NET_ETCP",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "UDPv4 traffic statistics",
#endif
.name = "A_NET_UDP",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv6 sockets statistics",
#endif
.name = "A_NET_SOCK6",
+ .item_list_sz = 0,
.g_nr = 1,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv6 traffic statistics",
#endif
.name = "A_NET_IP6",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = 1,
.nr2 = 1,
.desc = "IPv6 traffic errors statistics",
#endif
.name = "A_NET_EIP6",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = 1,
.nr2 = 1,
.desc = "ICMPv6 traffic statistics",
#endif
.name = "A_NET_ICMP6",
+ .item_list_sz = 0,
.g_nr = 5,
.nr_ini = 1,
.nr2 = 1,
.desc = "ICMPv6 traffic errors statistics",
#endif
.name = "A_NET_EICMP6",
+ .item_list_sz = 0,
.g_nr = 6,
.nr_ini = 1,
.nr2 = 1,
.desc = "UDPv6 traffic statistics",
#endif
.name = "A_NET_UDP6",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "CPU clock frequency",
#endif
.name = "A_PWR_CPU",
+ .item_list_sz = 0,
.g_nr = 1,
.nr_ini = -1,
.nr2 = 1,
.desc = "Fans speed",
#endif
.name = "A_PWR_FAN",
+ .item_list_sz = 0,
.g_nr = 1,
.nr_ini = -1,
.nr2 = 1,
.desc = "Devices temperature",
#endif
.name = "A_PWR_TEMP",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = -1,
.nr2 = 1,
.desc = "Voltage inputs statistics",
#endif
.name = "A_PWR_IN",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = -1,
.nr2 = 1,
.desc = "Huge pages utilization",
#endif
.name = "A_HUGE",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = 1,
.nr2 = 1,
.desc = "CPU weighted frequency",
#endif
.name = "A_PWR_FREQ",
+ .item_list_sz = 0,
.g_nr = 0,
.nr_ini = -1,
.nr2 = -1,
.desc = "USB devices",
#endif
.name = "A_PWR_USB",
+ .item_list_sz = 0,
.g_nr = 0,
.nr_ini = -1,
.nr2 = 1,
.desc = "Filesystems statistics",
#endif
.name = "A_FS",
+ .item_list_sz = 0,
.g_nr = 4,
.nr_ini = -1,
.nr2 = 1,
.desc = "Fibre Channel HBA statistics",
#endif
.name = "A_NET_FC",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = -1,
.nr2 = 1,
.desc = "Software-based network processing statistics",
#endif
.name = "A_NET_SOFT",
+ .item_list_sz = 0,
.g_nr = 2,
.nr_ini = -1,
.nr2 = 1,
#endif
extern unsigned int flags;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
/*
***************************************************************************
/* Get device name */
dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, dev_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}
extern int dis;
extern char timestamp[][TIMESTAMP_LEN];
extern unsigned long avg_count;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
/*
***************************************************************************
/* Get device name */
dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, dev_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}
#include "raw_stats.h"
extern unsigned int flags;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
/*
***************************************************************************
/* Get device name */
dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, dev_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}
#define IFNAMSIZ 16
#endif
+/* Maximum length of block device name */
+#define MAX_DEV_LEN 128
/* Maximum length of network interface name */
#define MAX_IFACE_LEN IFNAMSIZ
/* Maximum length of USB manufacturer string */
char *seps[] = {"\t", ";"};
extern unsigned int flags;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
/*
***************************************************************************
/* Get device name */
dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, dev_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}
int graph_no; /* Total number of views already displayed */
int restart; /* TRUE if we have just met a RESTART record */
int nr_act_dispd; /* Number of activities that will be displayed */
- __nr_t nr_max; /* Maximum number of items for this activity */
struct file_header *file_hdr; /* Pointer on file header structure */
};
* 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
#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 _buf0 buf[0]
#define _nr0 nr[0]
*/
__nr_t (*f_count_new) (struct activity *, int);
/*
- * Linked list containing all the different items found. Used by sadf.
+ * 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).
*/
- void *item_list;
+ 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
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))
-
/*
***************************************************************************
(void);
#ifndef SOURCE_SADC
+int add_list_item
+ (struct sa_item **, char *, int);
void allocate_bitmaps
(struct activity * []);
void allocate_structures
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
(unsigned int, struct record_header *, struct tm *, 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
return n;
}
-/*
- ***************************************************************************
- * Allocate structures for devices entered on the command line.
- *
- * IN:
- * @nr_alloc_slots Number of slots to allocate.
- * @nr_used_slots Number of slots currently used.
- *
- * OUT:
- * @st_list Address of allocated structures.
- ***************************************************************************
- */
-void salloc_sa_dlist(struct sa_dlist **st_list, int nr_alloc_slots, int nr_used_slots)
-{
- if (nr_alloc_slots) {
- SREALLOC(*st_list, struct sa_dlist, sizeof(struct sa_dlist) * (nr_used_slots + nr_alloc_slots));
- }
-}
-
-/*
- ***************************************************************************
- * Look for device in list.
- *
- * IN:
- * @st_list Structure where devices are saved.
- * @dlst_idx Number of devices in the list.
- * @d_name Device name to look for.
- *
- * RETURNS:
- * 1 if device found in list, 0 otherwise.
- ***************************************************************************
- */
-int search_sa_dlist(struct sa_dlist *st_list, int dlst_idx, char *d_name)
-{
- int i;
- struct sa_dlist *st_list_i;
-
- for (i = 0; i < dlst_idx; i++) {
- st_list_i = st_list + i;
- if (!strcmp(st_list_i->dev_name, d_name))
- return 1;
- }
-
- return 0;
-}
-
/*
***************************************************************************
* Look for the most recent of saDD and saYYYYMMDD to decide which one to
/*
***************************************************************************
- * Parse devices entered on the command line.
+ * Look for item in list.
+ *
+ * IN:
+ * @list Pointer on the start of the linked list.
+ * @item_name Item name to look for.
+ *
+ * RETURNS:
+ * 1 if item found in list, 0 otherwise.
+ ***************************************************************************
+ */
+int search_list_item(struct sa_item *list, char *item_name)
+{
+ while (list != NULL) {
+ if (!strcmp(list->item_name, item_name))
+ return 1; /* Item found in list */
+ list = list->next;
+ }
+
+ /* Item not found */
+ return 0;
+}
+
+/*
+ ***************************************************************************
+ * Add item to the list.
+ *
+ * IN:
+ * @list Address of pointer on the start of the linked list.
+ * @item_name Name of the item.
+ * @max_len Max length of an item.
+ *
+ * RETURNS:
+ * 1 if item has been added to the list (since it was not previously there),
+ * and 0 otherwise (item already in list or item name too long).
+ ***************************************************************************
+ */
+int add_list_item(struct sa_item **list, char *item_name, int max_len)
+{
+ struct sa_item *e;
+ int len;
+
+ if ((len = strnlen(item_name, max_len)) == max_len)
+ /* Item too long */
+ return 0;
+
+ while (*list != NULL) {
+ e = *list;
+ if (!strcmp(e->item_name, item_name))
+ return 0; /* Item found in list */
+ list = &(e->next);
+ }
+
+ /* Item not found: Add it to the list */
+ SREALLOC(*list, struct sa_item, sizeof(struct sa_item));
+ e = *list;
+ if ((e->item_name = (unsigned char *) malloc(len + 1)) == NULL) {
+ perror("malloc");
+ exit(4);
+ }
+ strcpy(e->item_name, item_name);
+
+ return 1;
+}
+
+/*
+ ***************************************************************************
+ * Parse devices entered on the command line and save them in activity's
+ * list.
*
* IN:
* @argv Argument with list of devices.
- * @st_list Structure where devices will be saved.
- * @dlst_idx Number of devices previously saved in the list.
+ * @a Activity for which devices are entered on the command line.
+ * @max_len Max length of a device name.
* @opt Index in list of arguments.
* @pos Position is string where is located the first device.
*
* OUT:
- * @st_list Structure where devices have been saved.
- * @dlst_idx Total number of devices saved in the list.
* @opt Index on next argument.
***************************************************************************
*/
-void parse_sa_devices(char *argv, struct sa_dlist **st_list,
- int *dlst_idx, int *opt, int pos)
+void parse_sa_devices(char *argv, struct activity *a, int max_len, int *opt, int pos)
{
char *t;
- struct sa_dlist *st_list_i;
-
- /* (Re)allocate device list */
- salloc_sa_dlist(st_list, count_csval_arg(argv + pos), *dlst_idx);
for (t = strtok(argv + pos, ","); t; t = strtok(NULL, ",")) {
- st_list_i = *st_list + (*dlst_idx)++;
- strncpy(st_list_i->dev_name, t, MAX_NAME_LEN - 1);
- st_list_i->dev_name[MAX_NAME_LEN - 1] = '\0';
+ a->item_list_sz += add_list_item(&(a->item_list), t, max_len);
+ }
+ if (a->item_list_sz) {
+ a->options |= AO_LIST_ON_CMDLINE;
}
(*opt)++;
}
*/
unsigned int id_seq[NR_ACT];
-/* Maximum number of items for each activity */
-__nr_t id_nr_max[NR_ACT];
-
/* Current record header */
struct record_header record_hdr[3];
struct tstamp tm_start, tm_end;
char *args[MAX_ARGV_NR];
-/* Devices entered on the command line */
-struct sa_dlist *st_iface_list = NULL, *st_dev_list = NULL, *st_fs_list = NULL;
-int dlst_iface_idx = 0, dlst_dev_idx = 0, dlst_fs_idx = 0;
-
extern struct activity *act[];
extern struct report_format *fmt[];
/*
***************************************************************************
- * Compute the number of rows that will contain SVG views. Usually only one
- * view is displayed on a row, unless the "packed" option has been entered.
- * Each activity selected may have several views. Moreover some activities
- * may have a number of items that vary within the file: In this case,
- * the number of views will depend on the highest number of items saved in
- * the file.
+ * Count number of different items in file. Save these numbers in fields
+ * @item_list_sz of structure activity, and create the corresponding list
+ * in field @item_list.
*
* IN:
- * @ifd File descriptor of input file.
- * @file Name of file being read.
- * @file_magic file_magic structure filled with file magic header data.
- * @file_actlst List of (known or unknown) activities in file.
- * @rectime Structure where timestamp (expressed in local time or
- * in UTC depending on whether options -T/-t have been
- * used or not) can be saved for current record.
- * @loctime Structure where timestamp (expressed in local time)
- * can be saved for current record.
- * @views_per_row Default number of views displayed on a single row.
- *
- * OUT:
- * @views_per_row Maximum number of views that will be displayed on a
- * single row (useful only if "packed" option entered).
- * @nr_act_dispd Number of activities that will be displayed.
- * May be 0.
+ * @ifd File descriptor of input file.
+ * @file Name of file being read.
+ * @file_magic file_magic structure filled with file magic header data.
+ * @file_actlst List of (known or unknown) activities in file.
+ * @rectime Structure where timestamp (expressed in local time or
+ * in UTC depending on whether options -T/-t have been
+ * used or not) can be saved for current record.
+ * @loctime Structure where timestamp (expressed in local time)
+ * can be saved for current record.
*
* RETURNS:
- * Number of rows containing views, taking into account only activities
- * to be displayed, and selected period of time (options -s/-e).
- * Result may be 0.
+ * 0 if no records are concerned in file, and 1 otherwise.
***************************************************************************
*/
-int get_svg_graph_nr(int ifd, char *file, struct file_magic *file_magic,
- struct file_activity *file_actlst, struct tm *rectime,
- struct tm *loctime, int *views_per_row, int *nr_act_dispd)
+int count_file_items(int ifd, char *file, struct file_magic *file_magic,
+ struct file_activity *file_actlst, struct tm *rectime,
+ struct tm *loctime)
{
- int i, n, p, eosaf;
- int rtype, tot_g_nr = 0;
-
- *nr_act_dispd = 0;
+ int i, eosaf, rtype;
/* Save current file position */
seek_file_position(ifd, DO_SAVE);
/* Init maximum number of items for each activity */
for (i = 0; i < NR_ACT; i++) {
- id_nr_max[i] = 0;
+ if (!HAS_LIST_ON_CMDLINE(act[i]->options)) {
+ act[i]->item_list_sz = 0;
+ }
}
/* Look for the first record that will be displayed */
0, file, &rtype, 0, file_magic, file_actlst,
rectime, loctime);
if (eosaf)
- /* No record to display => no graph too */
+ /* No record to display */
return 0;
}
while ((tm_start.use && (datecmp(loctime, &tm_start) < 0)) ||
*/
do {
for (i = 0; i < NR_ACT; i++) {
- if (act[i]->f_count_new) {
- id_nr_max[i] += (*act[i]->f_count_new)(act[i], 0);
- }
- else if (act[i]->nr[0] > id_nr_max[i]) {
- id_nr_max[i] = act[i]->nr[0];
+ if (!HAS_LIST_ON_CMDLINE(act[i]->options)) {
+ if (act[i]->f_count_new) {
+ act[i]->item_list_sz += (*act[i]->f_count_new)(act[i], 0);
+ }
+ else if (act[i]->nr[0] > act[i]->item_list_sz) {
+ act[i]->item_list_sz = act[i]->nr[0];
+ }
}
}
}
while (!eosaf && !(tm_end.use && (datecmp(loctime, &tm_end) >= 0)));
+ /* Rewind file */
+ seek_file_position(ifd, DO_RESTORE);
+
+ return 1;
+}
+
+/*
+ ***************************************************************************
+ * Compute the number of rows that will contain SVG views. Usually only one
+ * view is displayed on a row, unless the "packed" option has been entered.
+ * Each activity selected may have several views. Moreover some activities
+ * may have a number of items that vary within the file: In this case,
+ * the number of views will depend on the highest number of items saved in
+ * the file.
+ *
+ * IN:
+ * @ifd File descriptor of input file.
+ * @file Name of file being read.
+ * @file_magic file_magic structure filled with file magic header data.
+ * @file_actlst List of (known or unknown) activities in file.
+ * @rectime Structure where timestamp (expressed in local time or
+ * in UTC depending on whether options -T/-t have been
+ * used or not) can be saved for current record.
+ * @loctime Structure where timestamp (expressed in local time)
+ * can be saved for current record.
+ * @views_per_row Default number of views displayed on a single row.
+ *
+ * OUT:
+ * @views_per_row Maximum number of views that will be displayed on a
+ * single row (useful only if "packed" option entered).
+ * @nr_act_dispd Number of activities that will be displayed.
+ * May be 0.
+ *
+ * RETURNS:
+ * Number of rows containing views, taking into account only activities
+ * to be displayed, and selected period of time (options -s/-e).
+ * Result may be 0.
+ ***************************************************************************
+ */
+int get_svg_graph_nr(int ifd, char *file, struct file_magic *file_magic,
+ struct file_activity *file_actlst, struct tm *rectime,
+ struct tm *loctime, int *views_per_row, int *nr_act_dispd)
+{
+ int i, n, p, tot_g_nr = 0;
+
+ *nr_act_dispd = 0;
+
+ /* Count items in file */
+ if (!count_file_items(ifd, file, file_magic, file_actlst, rectime, loctime))
+ /* No record to display => No graph */
+ return 0;
+
for (i = 0; i < NR_ACT; i++) {
if (!id_seq[i])
continue;
(*nr_act_dispd)++;
- if (((act[p]->id == A_NET_DEV) || (act[p]->id == A_NET_EDEV)) &&
- (dlst_iface_idx > 0) && (dlst_iface_idx < id_nr_max[p])) {
- id_nr_max[p] = dlst_iface_idx;
- }
- if ((act[p]->id == A_DISK) &&
- (dlst_dev_idx > 0) && (dlst_dev_idx < id_nr_max[p])) {
- id_nr_max[p] = dlst_dev_idx;
- }
- if ((act[p]->id == A_FS) &&
- (dlst_fs_idx > 0) && (dlst_fs_idx < id_nr_max[p])) {
- id_nr_max[p] = dlst_fs_idx;
- }
-
if (PACK_VIEWS(flags)) {
/*
* One activity = one row with multiple views.
n = act[p]->g_nr;
}
if (ONE_GRAPH_PER_ITEM(act[p]->options)) {
- n = n * id_nr_max[p];
+ n = n * act[p]->item_list_sz;
}
if (act[p]->g_nr > *views_per_row) {
*views_per_row = act[p]->g_nr;
tot_g_nr += n;
}
- /* Rewind file */
- seek_file_position(ifd, DO_RESTORE);
-
if (*views_per_row > MAX_VIEWS_ON_A_ROW) {
*views_per_row = MAX_VIEWS_ON_A_ROW;
}
parm.ust_time_first = record_hdr[2].ust_time;
parm.restart = TRUE;
parm.file_hdr = &file_hdr;
- parm.nr_max = id_nr_max[p];
parm.nr_act_dispd = nr_act_dispd;
*cnt = count;
{
int opt = 1, sar_options = 0;
int day_offset = 0;
- int i, rc;
+ int i, rc, p, q;
char dfile[MAX_FILE_LEN];
char *t, *v;
else if (!strncmp(argv[opt], "--dev=", 6)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_dev_list,
- &dlst_dev_idx, &opt, 6);
+ p = get_activity_position(act, A_DISK, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_DEV_LEN, &opt, 6);
}
else if (!strncmp(argv[opt], "--fs=", 5)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_fs_list,
- &dlst_fs_idx, &opt, 5);
+ p = get_activity_position(act, A_FS, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_FS_LEN, &opt, 5);
}
else if (!strncmp(argv[opt], "--iface=", 8)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_iface_list,
- &dlst_iface_idx, &opt, 8);
+ p = get_activity_position(act, A_NET_DEV, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_IFACE_LEN, &opt, 8);
+ q = get_activity_position(act, A_NET_EDEV, EXIT_IF_NOT_FOUND);
+ act[q]->item_list = act[p]->item_list;
+ act[q]->item_list_sz = act[p]->item_list_sz;
+ act[q]->options |= AO_LIST_ON_CMDLINE;
}
else if (!strcmp(argv[opt], "-s")) {
#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)
-/* Structure for items in list */
-struct interface_lst {
- char name[MAX_IFACE_LEN];
- struct interface_lst *next;
-};
-
-struct filesystem_lst {
- char name[MAX_FS_LEN];
- struct filesystem_lst *next;
-};
-
-struct fchost_lst {
- char name[MAX_FCH_LEN];
- struct fchost_lst *next;
-};
-
-struct disk_lst {
- int major;
- int minor;
- struct disk_lst *next;
-};
/*
***************************************************************************
__nr_t count_new_net_dev(struct activity *a, int curr)
{
int i, nr = 0;
- struct interface_lst *e, **p;
struct stats_net_dev *sndc;
for (i = 0; i < a->nr[curr]; i++) {
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- p = (struct interface_lst **) &(a->item_list);
- while (*p != NULL) {
- e = *p;
- if (!strcmp(e->name, sndc->interface))
- break; /* Item found */
- p = &(e->next);
- }
- if (*p == NULL) {
- /*
- * Item not found: Increment total number
- * of new items found and add it to the list.
- */
- nr++;
- SREALLOC(*p, struct interface_lst, sizeof(struct interface_lst));
- e = *p;
- strcpy(e->name, sndc->interface);
- }
+ nr += add_list_item(&(a->item_list), sndc->interface, MAX_IFACE_LEN);
}
return nr;
__nr_t count_new_net_edev(struct activity *a, int curr)
{
int i, nr = 0;
- struct interface_lst *e, **p;
struct stats_net_edev *snedc;
for (i = 0; i < a->nr[curr]; i++) {
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- p = (struct interface_lst **) &(a->item_list);
- while (*p != NULL) {
- e = *p;
- if (!strcmp(e->name, snedc->interface))
- break; /* Item found */
- p = &(e->next);
- }
- if (*p == NULL) {
- /*
- * Item not found: Increment total number
- * of new items found and add it to the list.
- */
- nr++;
- SREALLOC(*p, struct interface_lst, sizeof(struct interface_lst));
- e = *p;
- strcpy(e->name, snedc->interface);
- }
+ nr += add_list_item(&(a->item_list), snedc->interface, MAX_IFACE_LEN);
}
return nr;
__nr_t count_new_filesystem(struct activity *a, int curr)
{
int i, nr = 0;
- struct filesystem_lst *e, **p;
struct stats_filesystem *sfc;
for (i = 0; i < a->nr[curr]; i++) {
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- p = (struct filesystem_lst **) &(a->item_list);
- while (*p != NULL) {
- e = *p;
- if (!strcmp(e->name, sfc->fs_name))
- break; /* Item found */
- p = &(e->next);
- }
- if (*p == NULL) {
- /*
- * Item not found: Increment total number
- * of new items found and add it to the list.
- */
- nr++;
- SREALLOC(*p, struct filesystem_lst, sizeof(struct filesystem_lst));
- e = *p;
- strcpy(e->name, sfc->fs_name);
- }
+ nr += add_list_item(&(a->item_list), sfc->fs_name, MAX_FS_LEN);
}
return nr;
__nr_t count_new_fchost(struct activity *a, int curr)
{
int i, nr = 0;
- struct fchost_lst *e, **p;
struct stats_fchost *sfcc;
for (i = 0; i < a->nr[curr]; i++) {
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- p = (struct fchost_lst **) &(a->item_list);
- while (*p != NULL) {
- e = *p;
- if (!strcmp(e->name, sfcc->fchost_name))
- break; /* Item found */
- p = &(e->next);
- }
- if (*p == NULL) {
- /*
- * Item not found: Increment total number
- * of new items found and add it to the list.
- */
- nr++;
- SREALLOC(*p, struct fchost_lst, sizeof(struct fchost_lst));
- e = *p;
- strcpy(e->name, sfcc->fchost_name);
- }
+ nr += add_list_item(&(a->item_list), sfcc->fchost_name, MAX_FCH_LEN);
}
return nr;
__nr_t count_new_disk(struct activity *a, int curr)
{
int i, nr = 0;
- struct disk_lst *e, **p;
struct stats_disk *sdc;
for (i = 0; i < a->nr[curr]; i++) {
sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
- p = (struct disk_lst **) &(a->item_list);
- while (*p != NULL) {
- e = *p;
- if ((e->major == sdc->major) && (e->minor == sdc->minor))
- break; /* Item found */
- p = &(e->next);
- }
- if (*p == NULL) {
- /*
- * Item not found: Increment total number
- * of new items found and add it to the list.
- */
- nr++;
- SREALLOC(*p, struct disk_lst, sizeof(struct disk_lst));
- e = *p;
- e->major = sdc->major;
- e->minor = sdc->minor;
- }
+ nr += add_list_item(&(a->item_list),
+ get_sa_devname(sdc->major, sdc->minor, flags),
+ MAX_DEV_LEN);
}
return nr;
*/
unsigned int id_seq[NR_ACT];
-/* Devices entered on the command line */
-struct sa_dlist *st_iface_list = NULL, *st_dev_list = NULL, *st_fs_list = NULL;
-int dlst_iface_idx = 0, dlst_dev_idx = 0, dlst_fs_idx = 0;
-
struct tm rectime;
/* Contain the date specified by -s and -e options */
*/
int main(int argc, char **argv)
{
- int i, rc, opt = 1, args_idx = 1;
+ int i, rc, opt = 1, args_idx = 1, p, q;
int fd[2];
int day_offset = 0;
char from_file[MAX_FILE_LEN], to_file[MAX_FILE_LEN];
else if (!strncmp(argv[opt], "--dev=", 6)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_dev_list,
- &dlst_dev_idx, &opt, 6);
+ p = get_activity_position(act, A_DISK, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_DEV_LEN, &opt, 6);
}
else if (!strncmp(argv[opt], "--fs=", 5)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_fs_list,
- &dlst_fs_idx, &opt, 5);
+ p = get_activity_position(act, A_FS, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_FS_LEN, &opt, 5);
}
else if (!strncmp(argv[opt], "--iface=", 8)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argv[opt], &st_iface_list,
- &dlst_iface_idx, &opt, 8);
+ p = get_activity_position(act, A_NET_DEV, EXIT_IF_NOT_FOUND);
+ parse_sa_devices(argv[opt], act[p], MAX_IFACE_LEN, &opt, 8);
+ q = get_activity_position(act, A_NET_EDEV, EXIT_IF_NOT_FOUND);
+ act[q]->item_list = act[p]->item_list;
+ act[q]->item_list_sz = act[p]->item_list_sz;
+ act[q]->options |= AO_LIST_ON_CMDLINE;
}
else if (!strcmp(argv[opt], "--help")) {
#endif
extern unsigned int flags;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
unsigned int svg_colors[] = {0x00cc00, 0xff00bf, 0x00ffff, 0xff0000,
0xe85f00, 0x0000ff, 0x006020, 0x7030a0,
return out;
}
-/*
- ***************************************************************************
- * Reallocate all the arrays used to save graphs data, min and max values.
- * The new size is the double of the original one.
- *
- * IN:
- * @n Number of slots currently allocated.
- * @out Current pointer on arrays containing the graphs data.
- * @outsize Current pointer on array containing the size of each element
- * in array of chars.
- * @spmin Current pointer on array containing min values.
- * @spmax Current pointer on array containing max values.
- *
- * OUT:
- * @out New pointer on arrays containing the graphs data.
- * @outsize New pointer on array containing the size of each element
- * in array of chars.
- * @spmin New pointer on array containing min values.
- * @spmax New pointer on array containing max values.
- ***************************************************************************
- */
-void reallocate_all_graph_lines(int n, char ***out, int **outsize,
- double **spmin, double **spmax)
-{
- char *out_p;
- int i;
-
- /* Reallocate all the arrays */
- SREALLOC(*out, char *, n * sizeof(char *) * 2);
- SREALLOC(*outsize, int, n * sizeof(int) * 2);
- SREALLOC(*spmin, double, n * sizeof(double) * 2);
- SREALLOC(*spmax, double, n * sizeof(double) * 2);
-
- /* Allocate arrays of chars that will contain graphs data for the newly allocated slots */
- for (i = 0; i < n; i++) {
- if ((out_p = (char *) malloc(CHUNKSIZE * sizeof(char))) == NULL) {
- perror("malloc");
- exit(4);
- }
- *(*out + n + i) = out_p;
- *out_p = '\0';
- *(*outsize + n + i) = CHUNKSIZE;
- *(*spmin + n + i) = DBL_MAX;
- *(*spmax + n + i) = -DBL_MAX;
- }
-}
-
/*
***************************************************************************
* Save SVG code for current graph.
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(10 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(10 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
group2[0]++;
}
- for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+ for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
/* Should current CPU (including CPU "all") be displayed? */
if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
* outsize + 8 will contain a positive value (TRUE) if the device
* has either still not been registered, or has been unregistered.
*/
- out = allocate_graph_lines(9 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(9 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
* Mark previously registered devices as now
* possibly unregistered for all graphs.
*/
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 9 + 8;
if (*unregistered == FALSE) {
*unregistered = MAYBE;
/* Get device name */
item_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, item_name))
+ if (!search_list_item(a->item_list, item_name))
/* Device not found */
continue;
}
/* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
if ((sdc->major == *(spmax + k * 9 + 8)) &&
(sdc->minor == *(spmin + k * 9 + 8)))
/* Graph found! */
break;
}
- if (k == svg_p->nr_max) {
+ if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
if (*(spmax + k * 9 + 8) == -DBL_MAX)
break;
}
- if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(9 * svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ if (k == a->item_list_sz) {
+ /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+ fprintf(stderr, "%s: Name=%s major=%d minor=%d\n",
+ __FUNCTION__, item_name, sdc->major, sdc->minor);
+#endif
+ continue;
}
}
pos = k * 9;
}
/* Mark devices not seen here as now unregistered */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 9 + 8;
if (*unregistered != FALSE) {
*unregistered = TRUE;
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
/* Check if there is something to display */
pos = i * 9;
if (!**(out + pos))
* outsize + 8 will contain a positive value (TRUE) if the interface
* has either still not been registered, or has been unregistered.
*/
- out = allocate_graph_lines(9 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(9 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
* Mark previously registered interfaces as now
* possibly unregistered for all graphs.
*/
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 9 + 8;
if (*unregistered == FALSE) {
*unregistered = MAYBE;
for (i = 0; i < a->nr[curr]; i++) {
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
/* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 9 + 8);
if (!strcmp(sndc->interface, item_name))
/* Graph found! */
break;
}
- if (k == svg_p->nr_max) {
+ if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 9 + 8);
if (!strcmp(item_name, ""))
break;
}
- if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(9 * svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ if (k == a->item_list_sz) {
+ /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+ fprintf(stderr, "%s: Name=%s\n",
+ __FUNCTION__, sndc->interface);
+#endif
+ continue;
}
}
pos = k * 9;
}
/* Mark interfaces not seen here as now unregistered */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 9 + 8;
if (*unregistered != FALSE) {
*unregistered = TRUE;
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
/*
* Check if there is something to display.
* Don't test sndc->interface because maybe the network
* outsize + 9 will contain a positive value (TRUE) if the interface
* has either still not been registered, or has been unregistered.
*/
- out = allocate_graph_lines(10 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(10 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
* Mark previously registered interfaces as now
* possibly unregistered for all graphs.
*/
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 10 + 9;
if (*unregistered == FALSE) {
*unregistered = MAYBE;
/* Empty structure: This is the end of the list */
break;
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
/* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 10 + 9);
if (!strcmp(snedc->interface, item_name))
/* Graph found! */
break;
}
- if (k == svg_p->nr_max) {
+ if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 10 + 9);
if (!strcmp(item_name, ""))
break;
}
- if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(10 * svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ if (k == a->item_list_sz) {
+ /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+ fprintf(stderr, "%s: Name=%s\n",
+ __FUNCTION__, snedc->interface);
+#endif
+ continue;
}
}
}
/* Mark interfaces not seen here as now unregistered */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 10 + 9;
if (*unregistered != FALSE) {
*unregistered = TRUE;
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
/*
* Check if there is something to display.
* Don't test snedc->interface because maybe the network
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
if (action & F_END) {
int xid = 0;
- for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+ for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
/* Should current CPU (including CPU "all") be displayed? */
if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(2 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(2 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(2 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(2 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
* out + 7 will contain the filesystem name,
* out + 8 will contain the mount point.
*/
- out = allocate_graph_lines(9 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(9 * 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);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}
/* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 9 + 7);
if (!strcmp(sfc->fs_name, item_name))
/* Graph found! */
break;
}
- if (k == svg_p->nr_max) {
+ if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 9 + 7);
if (!strcmp(item_name, ""))
break;
}
- if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(9 * svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ if (k == a->item_list_sz) {
+ /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+ fprintf(stderr, "%s: Name=%s\n",
+ __FUNCTION__, sfc->fs_name);
+#endif
+ continue;
}
}
if (action & F_END) {
int xid = 0;
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
/* Check if there is something to display */
pos = i * 9;
* has either still not been registered, or has been unregistered
* (outsize + 4).
*/
- out = allocate_graph_lines(5 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(5 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
* Mark previously registered interfaces as now
* possibly unregistered for all graphs.
*/
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 5 + 4;
if (*unregistered == FALSE) {
*unregistered = MAYBE;
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
/* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 5 + 4);
if (!strcmp(sfcc->fchost_name, item_name))
/* Graph found! */
break;
}
- if (k == svg_p->nr_max) {
+ if (k == a->item_list_sz) {
/* Graph not found: Look for first free entry */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
item_name = *(out + k * 5 + 4);
if (!strcmp(item_name, ""))
break;
}
- if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(5 * svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ if (k == a->item_list_sz) {
+ /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+ fprintf(stderr, "%s: Name=%s\n",
+ __FUNCTION__, sfcc->fchost_name);
+#endif
+ continue;
}
}
}
/* Mark interfaces not seen here as now unregistered */
- for (k = 0; k < svg_p->nr_max; k++) {
+ for (k = 0; k < a->item_list_sz; k++) {
unregistered = outsize + k * 5 + 4;
if (*unregistered != FALSE) {
*unregistered = TRUE;
}
if (action & F_END) {
- for (i = 0; i < svg_p->nr_max; i++) {
+ for (i = 0; i < a->item_list_sz; i++) {
/* Check if there is something to display */
pos = i * 5;
* Allocate arrays that will contain the graphs data
* and the min/max values.
*/
- out = allocate_graph_lines(5 * svg_p->nr_max, &outsize, &spmin, &spmax);
+ out = allocate_graph_lines(5 * a->item_list_sz, &outsize, &spmin, &spmax);
}
if (action & F_MAIN) {
}
if (action & F_END) {
- for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+ for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
/* Should current CPU (including CPU "all") be displayed? */
if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
#endif
extern unsigned int flags;
-extern struct sa_dlist *st_iface_list;
-extern struct sa_dlist *st_dev_list;
-extern struct sa_dlist *st_fs_list;
-extern int dlst_iface_idx;
-extern int dlst_dev_idx;
-extern int dlst_fs_idx;
/*
***************************************************************************
/* Get device name */
dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
- if (dlst_dev_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlst_dev_idx, dev_name))
+ if (!search_list_item(a->item_list, dev_name))
/* Device not found */
continue;
}
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+ if (!search_list_item(a->item_list, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_iface_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+ if (!search_list_item(a->item_list, snedc->interface))
/* Device not found */
continue;
}
sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
- if (dlst_fs_idx) {
+ if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
- DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+ if (!search_list_item(a->item_list,
+ DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
/* Device not found */
continue;
}