extern int dis;
extern char timestamp[][TIMESTAMP_LEN];
extern unsigned long avg_count;
-
+extern struct sa_dlist *st_dev_list;
+extern int dlist_idx;
/*
***************************************************************************
if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sndp, sndc, STATS_NET_DEV_SIZE2CMP))
continue;
+ if (dlist_idx) {
+ /* A list of devices has been entered on the command line */
+ if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
+ A_NET_DEV))
+ /* Device not found */
+ continue;
+ }
+
printf("%-11s", timestamp[curr]);
if (!DISPLAY_HUMAN_READ(flags)) {
if (DISPLAY_ZERO_OMIT(flags) && !memcmp(snedp, snedc, STATS_NET_EDEV_SIZE2CMP))
continue;
+ if (dlist_idx) {
+ /* A list of devices has been entered on the command line */
+ if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
+ A_NET_DEV))
+ /* Device not found */
+ continue;
+ }
+
printf("%-11s", timestamp[curr]);
if (!DISPLAY_HUMAN_READ(flags)) {
int use;
};
+/* List of devices entered on the command line */
+struct sa_dlist {
+ /* Device type */
+ int dev_id __attribute__ ((aligned (4)));
+ /* Device name */
+ char dev_name[MAX_NAME_LEN];
+};
+
+#define SA_DLIST_SIZE (sizeof(struct sa_dlist))
+
/*
***************************************************************************
(struct record_header *, struct record_header *, unsigned long long *);
int next_slice
(unsigned long long, unsigned long long, int, long);
+void parse_sa_devices
+ (int, char *[], struct sa_dlist **, int *, 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);
+void salloc_sa_dlist
+ (struct sa_dlist **, int);
+int search_sa_dlist
+ (struct sa_dlist *, int, char *, int);
void select_all_activities
(struct activity * []);
void select_default_activity
return n;
}
+/*
+ ***************************************************************************
+ * Allocate structures for devices entered on the command line.
+ *
+ * IN:
+ * @list_len Number of arguments on the command line.
+ *
+ * OUT:
+ * @st_dev_list Address of allocated structures.
+ ***************************************************************************
+ */
+void salloc_sa_dlist(struct sa_dlist **st_dev_list, int list_len)
+{
+ if ((*st_dev_list = (struct sa_dlist *) malloc(SA_DLIST_SIZE * list_len)) == NULL) {
+ perror("malloc");
+ exit(4);
+ }
+ memset(*st_dev_list, 0, SA_DLIST_SIZE * list_len);
+}
+
+/*
+ ***************************************************************************
+ * Look for device in list.
+ *
+ * IN:
+ * @st_dev_list Structure where devices are saved.
+ * @dlist_idx Number of devices in the list.
+ * @d_name Device name to look for.
+ * @d_id Device type.
+ *
+ * RETURNS:
+ * 1 if device found in list, 0 otherwise.
+ ***************************************************************************
+ */
+int search_sa_dlist(struct sa_dlist *st_dev_list, int dlist_idx, char *d_name, int d_id)
+{
+ int i;
+ struct sa_dlist *st_dev_list_i;
+
+ for (i = 0; i < dlist_idx; i++) {
+ st_dev_list_i = st_dev_list + i;
+ if ((st_dev_list_i->dev_id == d_id) &&
+ !strcmp(st_dev_list_i->dev_name, d_name))
+ return 1;
+ }
+
+ return 0;
+}
+
/*
***************************************************************************
* Look for the most recent of saDD and saYYYYMMDD to decide which one to
return 1;
}
+/*
+ ***************************************************************************
+ * Parse devices entered on the command line.
+ *
+ * IN:
+ * @argc Number of arguments in the list.
+ * @argv Arguments list.
+ * @st_dev_list Structure where devices will be saved.
+ * @dlist_idx Number of devices previously saved in the list.
+ * @opt Index in list of arguments.
+ * @d_id Type of device.
+ * @pos Position is string where is located the first device.
+ *
+ * OUT:
+ * @st_dev_list Structure where devices have been saved.
+ * @dlist_idx Total number of devices saved in the list.
+ * @opt Index on next argument.
+ ***************************************************************************
+ */
+void parse_sa_devices(int argc, char *argv[], struct sa_dlist **st_dev_list,
+ int *dlist_idx, int *opt, int d_id, int pos)
+{
+ char *t;
+ struct sa_dlist *st_dev_list_i;
+
+ if (*st_dev_list == NULL) {
+ /* Allocate device list */
+ salloc_sa_dlist(st_dev_list, argc - 1 + count_csvalues(argc, argv));
+ }
+ for (t = strtok(argv[*opt] + pos, ","); t; t = strtok(NULL, ",")) {
+ st_dev_list_i = *st_dev_list + (*dlist_idx)++;
+ st_dev_list_i->dev_id = d_id;
+ strncpy(st_dev_list_i->dev_name, t, MAX_NAME_LEN - 1);
+ }
+ (*opt)++;
+}
+
/*
***************************************************************************
* Compute network interface utilization.
*/
unsigned int id_seq[NR_ACT];
+/* Devices entered on the command line */
+struct sa_dlist *st_dev_list = NULL;
+int dlist_idx = 0;
+
struct tm rectime;
/* Contain the date specified by -s and -e options */
"[ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F [ MOUNT ] ] [ -H ] [ -h ]\n"
"[ -p ] [ -q ] [ -r [ ALL ] ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ]\n"
"[ -v ] [ -W ] [ -w ] [ -y ] [ -z ]\n"
- "[ --dec={ 0 | 1 | 2 } ] [ --help ] [ --human ] [ --sadc ]\n"
"[ -I { <int_list> | SUM | ALL } ] [ -P { <cpu_list> | ALL } ]\n"
"[ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ]\n"
+ "[ --dec={ 0 | 1 | 2 } ] [ --iface=<iface_list> ]\n"
+ "[ --help ] [ --human ] [ --sadc ]\n"
"[ -j { ID | LABEL | PATH | UUID | ... } ]\n"
"[ -f [ <filename> ] | -o [ <filename> ] | -[0-9]+ ]\n"
"[ -i <interval> ] [ -s [ <hh:mm[:ss]> ] ] [ -e [ <hh:mm[:ss]> ] ]\n"));
which_sadc();
}
+ else if (!strncmp(argv[opt], "--iface=", 8)) {
+ /* Parse devices entered on the command line */
+ parse_sa_devices(argc, argv, &st_dev_list,
+ &dlist_idx, &opt, A_NET_DEV, 8);
+ }
+
else if (!strcmp(argv[opt], "--help")) {
/* Display help message */
display_help(argv[0]);
/* Free stuctures and activity bitmaps */
free_bitmaps(act);
free_structures(act);
+ if (st_dev_list) {
+ free(st_dev_list);
+ }
return 0;
}
/* Free structures and activity bitmaps */
free_bitmaps(act);
free_structures(act);
+ if (st_dev_list) {
+ free(st_dev_list);
+ }
return 0;
}