Changes:
xxxx/xx/xx: Version 9.1.7 - Sebastien Godard (sysstat <at> orange.fr)
+ * sar now tells sadc to read only the necessary groups of
+ activities.
* sar manual page updated.
2010/11/10: Version 9.1.6 - Sebastien Godard (sysstat <at> orange.fr)
* Although undocumented, option -S followed by a numerical value
* enables the user to select each activity that should be
* collected. "-S 0" unselects all activities but CPU.
+ * A value greater than 255 enables the user to select groups
+ * of activities.
*/
int act_id;
act_id = atoi(argv[opt]);
- if ((act_id < 0) || (act_id > NR_ACT)) {
+ if (act_id > 255) {
+ act_id >>= 8;
+ for (i = 0; i < NR_ACT; i++) {
+ if (act[i]->group & act_id) {
+ act[i]->options |= AO_COLLECTED;
+ }
+ }
+ }
+ else if ((act_id < 0) || (act_id > NR_ACT)) {
usage(argv[0]);
}
- if (!act_id) {
+ else if (!act_id) {
/* Unselect all activities but CPU */
for (i = 0; i < NR_ACT; i++) {
act[i]->options &= ~AO_COLLECTED;
*/
int main(int argc, char **argv)
{
- int opt = 1, args_idx = 2;
+ int i, opt = 1, args_idx = 2;
int fd[2];
char from_file[MAX_FILE_LEN], to_file[MAX_FILE_LEN];
char ltemp[20];
/* Flags to be passed to sadc */
salloc(args_idx++, "-z");
- salloc(args_idx++, "-S");
- salloc(args_idx++, K_ALL);
-
- /* Outfile arg */
+
+ /* Writing data to a file (option -o) */
if (to_file[0]) {
+ /* Collect all possible activities (option -S ALL for sadc) */
+ salloc(args_idx++, "-S");
+ salloc(args_idx++, K_ALL);
+ /* Outfile arg */
salloc(args_idx++, to_file);
}
+ else {
+ /*
+ * If option -o hasn't been used, then tell sadc
+ * to collect only activities that will be displayed.
+ */
+ int act_id = 0;
+
+ for (i = 0; i < NR_ACT; i++) {
+ if (IS_SELECTED(act[i]->options)) {
+ act_id |= act[i]->group;
+ }
+ }
+ if (act_id) {
+ act_id <<= 8;
+ snprintf(ltemp, 19, "%d", act_id);
+ ltemp[19] = '\0';
+ salloc(args_idx++, "-S");
+ salloc(args_idx++, ltemp);
+ }
+ }
/* Last arg is NULL */
args[args_idx] = NULL;