struct activity cpu_act = {
.id = A_CPU,
.options = AO_COLLECTED + AO_COUNTED + AO_PERSISTENT +
- AO_MULTIPLE_OUTPUTS + AO_GRAPH_PER_ITEM,
+ AO_MULTIPLE_OUTPUTS + AO_GRAPH_PER_ITEM +
+ AO_ALWAYS_COUNTED,
.magic = ACTIVITY_MAGIC_BASE + 1,
.group = G_DEFAULT,
#ifdef SOURCE_SADC
* line for this activity (see options --dev=, --iface=, ...)
*/
#define AO_LIST_ON_CMDLINE 0x100
+/*
+ * Indicate that the number of items for this activity should always
+ * be counted, even if the activity is not collected.
+ */
+#define AO_ALWAYS_COUNTED 0x200
#define IS_COLLECTED(m) (((m) & AO_COLLECTED) == AO_COLLECTED)
#define IS_SELECTED(m) (((m) & AO_SELECTED) == AO_SELECTED)
#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 ALWAYS_COUNT_ITEMS(m) (((m) & AO_ALWAYS_COUNTED) == AO_ALWAYS_COUNTED)
#define _buf0 buf[0]
#define _nr0 nr[0]
/*
***************************************************************************
* Count activities items then allocate and init corresponding structures.
- * ALL activities are always counted (thus the number of CPU will always be
- * counted even if CPU activity is not collected), but ONLY those that will
- * be collected have allocated structures.
+ * Activities such A_CPU with AO_ALWAYS_COUNTED flag set are always counted
+ * (thus the number of CPU will always be counted even if CPU activity is
+ * not collected), but ONLY those that will be collected have allocated
+ * structures.
* This function is called when sadc is started, and when a file is rotated.
* If a file is rotated and structures are reallocated with a larger size,
* additional space is not initialized: It doesn't matter as reset_stats()
for (i = 0; i < NR_ACT; i++) {
- if ( ! (act[i]->options & AO_COLLECTED ) )
- continue;
-
- if (HAS_COUNT_FUNCTION(act[i]->options)) {
+ if ((HAS_COUNT_FUNCTION(act[i]->options) && IS_COLLECTED(act[i]->options)) ||
+ ALWAYS_COUNT_ITEMS(act[i]->options)) {
idx = act[i]->f_count_index;
/* Number of items is not a constant and should be calculated */
* This is a new file (or stdout): Set sa_cpu_nr field to the number
* of CPU of the machine (1 .. CPU_NR + 1). This is the number of CPU, whether
* online or offline, when sadc was started.
- * All activities (including A_CPU) are counted in sa_sys_init(), even
- * if they are not collected.
+ * A_CPU activity is always counted in sa_sys_init(), even if it's not collected.
*/
file_hdr.sa_cpu_nr = act[get_activity_position(act, A_CPU, EXIT_IF_NOT_FOUND)]->nr_ini;