]> granicus.if.org Git - sysstat/commitdiff
sadc: Allow to unselect activities by name
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 6 Aug 2018 16:28:10 +0000 (18:28 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 6 Aug 2018 16:28:10 +0000 (18:28 +0200)
The idea here is to make it possible for the user to *unselect* an
activity which is collected by default by sadc.
For example, you can now choose to collect all
possible statistics except those for interrupts:

sadc -S XALL,-A_IRQ (...)

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sadc.c

diff --git a/sadc.c b/sadc.c
index 5f251b4bb0d983650274dddb023965f3ff242b54..826f4aed0c8adc945da9bd58f6c1e83c3b502fdd 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -195,6 +195,18 @@ void parse_sadc_S_option(char *argv[], int opt)
                                usage(argv[0]);
                        }
                }
+               else if (!strncmp(p, "-A_", 3)) {
+                       /* Unselect activity by name */
+                       for (i = 0; i < NR_ACT; i++) {
+                               if (!strcmp(p + 1, act[i]->name)) {
+                                       act[i]->options &= ~AO_COLLECTED;
+                                       break;
+                               }
+                       }
+                       if (i == NR_ACT) {
+                               usage(argv[0]);
+                       }
+               }
                else {
                        usage(argv[0]);
                }