]> granicus.if.org Git - sysstat/commitdiff
sar: Define new AO_COUNTED and AO_PERSISTENT flags
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 13 Dec 2017 14:48:42 +0000 (15:48 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 13 Dec 2017 14:48:42 +0000 (15:48 +0100)
See comments in code for explanations of these flags.
AO_PERSISTENT is for a later use.

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

index b9acfba42b0c9ae2cd8d1f45913281880b204df5..526e2c45ac24901405aa37ef30a906e42a5c34eb 100644 (file)
@@ -71,8 +71,8 @@ struct act_bitmap irq_bitmap = {
  */
 struct activity cpu_act = {
        .id             = A_CPU,
-       .options        = AO_COLLECTED + AO_MULTIPLE_OUTPUTS +
-                         AO_GRAPH_PER_ITEM,
+       .options        = AO_COLLECTED + AO_COUNTED + AO_PERSISTENT +
+                         AO_MULTIPLE_OUTPUTS + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
@@ -151,7 +151,7 @@ struct activity pcsw_act = {
 /* Interrupts statistics */
 struct activity irq_act = {
        .id             = A_IRQ,
-       .options        = AO_NULL,
+       .options        = AO_COUNTED,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_INT,
 #ifdef SOURCE_SADC
@@ -426,7 +426,7 @@ struct activity queue_act = {
 /* Serial lines activity */
 struct activity serial_act = {
        .id             = A_SERIAL,
-       .options        = AO_COLLECTED,
+       .options        = AO_COLLECTED + AO_COUNTED,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
@@ -465,7 +465,7 @@ struct activity serial_act = {
 /* Block devices activity */
 struct activity disk_act = {
        .id             = A_DISK,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE + 1,
        .group          = G_DISK,
 #ifdef SOURCE_SADC
@@ -504,7 +504,7 @@ struct activity disk_act = {
 /* Network interfaces activity */
 struct activity net_dev_act = {
        .id             = A_NET_DEV,
-       .options        = AO_COLLECTED + AO_GRAPH_PER_ITEM,
+       .options        = AO_COLLECTED + AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE + 2,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
@@ -543,7 +543,7 @@ struct activity net_dev_act = {
 /* Network interfaces (errors) activity */
 struct activity net_edev_act = {
        .id             = A_NET_EDEV,
-       .options        = AO_COLLECTED + AO_GRAPH_PER_ITEM,
+       .options        = AO_COLLECTED + AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE + 1,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
@@ -1215,7 +1215,7 @@ struct activity net_udp6_act = {
 /* CPU frequency */
 struct activity pwr_cpufreq_act = {
        .id             = A_PWR_CPUFREQ,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1254,7 +1254,7 @@ struct activity pwr_cpufreq_act = {
 /* Fan */
 struct activity pwr_fan_act = {
        .id             = A_PWR_FAN,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1293,7 +1293,7 @@ struct activity pwr_fan_act = {
 /* Temperature */
 struct activity pwr_temp_act = {
        .id             = A_PWR_TEMP,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1332,7 +1332,7 @@ struct activity pwr_temp_act = {
 /* Voltage inputs */
 struct activity pwr_in_act = {
        .id             = A_PWR_IN,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1410,7 +1410,7 @@ struct activity huge_act = {
 /* CPU weighted frequency */
 struct activity pwr_wghfreq_act = {
        .id             = A_PWR_WGHFREQ,
-       .options        = AO_MATRIX,
+       .options        = AO_COUNTED + AO_MATRIX,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1449,7 +1449,7 @@ struct activity pwr_wghfreq_act = {
 /* USB devices plugged into the system */
 struct activity pwr_usb_act = {
        .id             = A_PWR_USB,
-       .options        = AO_CLOSE_MARKUP,
+       .options        = AO_COUNTED + AO_CLOSE_MARKUP,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_POWER,
 #ifdef SOURCE_SADC
@@ -1488,7 +1488,7 @@ struct activity pwr_usb_act = {
 /* Filesystem usage activity */
 struct activity filesystem_act = {
        .id             = A_FILESYSTEM,
-       .options        = AO_GRAPH_PER_ITEM + AO_MULTIPLE_OUTPUTS,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM + AO_MULTIPLE_OUTPUTS,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_XDISK,
 #ifdef SOURCE_SADC
@@ -1528,7 +1528,7 @@ struct activity filesystem_act = {
 /* Fibre Channel HBA usage activity */
 struct activity fchost_act = {
        .id             = A_NET_FC,
-       .options        = AO_GRAPH_PER_ITEM,
+       .options        = AO_COUNTED + AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DISK,
 #ifdef SOURCE_SADC
@@ -1567,7 +1567,8 @@ struct activity fchost_act = {
 /* Softnet activity */
 struct activity softnet_act = {
        .id             = A_NET_SOFT,
-       .options        = AO_COLLECTED + AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM,
+       .options        = AO_COLLECTED + AO_COUNTED + AO_CLOSE_MARKUP +
+                         AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
diff --git a/sa.h b/sa.h
index 88315ce646aa0c1a85ff3483c3f869ccc22e17a0..e774b42f8f94a0897e810eac509cceac4d95f0e7 100644 (file)
--- a/sa.h
+++ b/sa.h
@@ -620,9 +620,18 @@ struct record_header {
  */
 #define AO_SELECTED            0x02
 /*
- * 0x04: Unused.
- * 0x08: Unused.
+ * Indicate that corresponding activity has items that need to be counted.
+ * This means that its @f_count_index values is >= 0.
+ * (We use AO_COUNTED instead of @f_count_index because @f_count_index
+ * is available (initialized) only for sadc).
  */
+#define AO_COUNTED             0x04
+/*
+ * Indicate that activity's metrics have persistent values when devices
+ * are registered again (this means that when the device is registered again,
+ * the metrics pick the values they had when they had been unregistered).
+ */
+#define AO_PERSISTENT          0x08
 /*
  * This flag should be set for every activity closing a markup used
  * by several activities. Used by sadf f_xml_print() functions to
@@ -649,6 +658,8 @@ struct record_header {
 
 #define IS_COLLECTED(m)                (((m) & AO_COLLECTED)        == AO_COLLECTED)
 #define IS_SELECTED(m)         (((m) & AO_SELECTED)         == AO_SELECTED)
+#define HAS_COUNT_FUNCTION(m)  (((m) & AO_COUNTED)          == AO_COUNTED)
+#define HAS_PERSISTENT_VALUES(m) (((m) & AO_PERSISTENT)      == AO_PERSISTENT)
 #define CLOSE_MARKUP(m)                (((m) & AO_CLOSE_MARKUP)     == AO_CLOSE_MARKUP)
 #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)
diff --git a/sadc.c b/sadc.c
index 14c2a90b719e5fdb66b17909c0f4c58e42b7dcf0..89fb934ef547b0969c4089f8dbc32c6ce3a87bba 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -311,9 +311,9 @@ void sa_sys_init(void)
 
        for (i = 0; i < NR_ACT; i++) {
 
-               idx = act[i]->f_count_index;
+               if (HAS_COUNT_FUNCTION(act[i]->options)) {
+                       idx = act[i]->f_count_index;
 
-               if (idx >= 0) {
                        /* Number of items is not a constant and should be calculated */
                        if (f_count_results[idx] >= 0) {
                                act[i]->nr = f_count_results[idx];