1 /*
2 Copyright 2020 Northern.tech AS
3
4 This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; version 3.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18
19 To the extent this program is licensed as part of the Enterprise
20 versions of CFEngine, the applicable Commercial Open Source License
21 (COSL) may apply to this file if you as a licensee so wish it. See
22 included file COSL.txt.
23 */
24
25
26 #include <probes.h>
27
28
29 /* Structs */
30
31 typedef struct
32 {
33 const char *name;
34 ProbeInit init;
35 } Probe;
36
37 /* Constants */
38
39 static const Probe ENTERPRISE_PROBES[] =
40 {
41 {"Input/output", &MonIoInit},
42 {"Memory", &MonMemoryInit},
43 };
44
45 /* Globals */
46
47 static ProbeGatherData ENTERPRISE_PROBES_GATHERERS[sizeof(ENTERPRISE_PROBES) / sizeof(ENTERPRISE_PROBES[0])];
48
49
MonOtherInit()50 void MonOtherInit()
51 {
52 int i;
53
54 Log(LOG_LEVEL_VERBOSE, "Starting initialization of static Nova monitoring probes.");
55
56 for (i = 0; i < sizeof(ENTERPRISE_PROBES) / sizeof(ENTERPRISE_PROBES[0]); ++i)
57 {
58 const Probe *probe = &ENTERPRISE_PROBES[i];
59 const char *provider;
60 const char *error;
61
62 if ((ENTERPRISE_PROBES_GATHERERS[i] = (probe->init) (&provider, &error)))
63 {
64 Log(LOG_LEVEL_VERBOSE, " * %s: %s.", probe->name, provider);
65 }
66 else
67 {
68 Log(LOG_LEVEL_VERBOSE, " * %s: Disabled: %s.", probe->name, error);
69 }
70 }
71
72 Log(LOG_LEVEL_VERBOSE, "Initialization of static Nova monitoring probes is finished.");
73 }
74
75 /****************************************************************************/
76
MonOtherGatherData(double * cf_this)77 void MonOtherGatherData(double *cf_this)
78 {
79 int i;
80
81 Log(LOG_LEVEL_VERBOSE, "Gathering data from static Nova monitoring probes.");
82
83 for (i = 0; i < sizeof(ENTERPRISE_PROBES) / sizeof(ENTERPRISE_PROBES[0]); ++i)
84 {
85 const char *probename = ENTERPRISE_PROBES[i].name;
86 ProbeGatherData gatherer = ENTERPRISE_PROBES_GATHERERS[i];
87
88 if (gatherer)
89 {
90 Log(LOG_LEVEL_VERBOSE, " * %s", probename);
91 (*gatherer) (cf_this);
92 }
93 }
94 Log(LOG_LEVEL_VERBOSE, "Gathering data from static Nova monitoring probes is finished.");
95 }
96