[docs][userguide] Use literalinclude instead of duplicating the sample configs
[barometer.git] / docs / release / userguide / feature.userguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) Anuket and others
4
5 ===========================
6 Anuket Barometer User Guide
7 ===========================
8
9 Barometer collectd plugins description
10 ---------------------------------------
11 .. Describe the specific features and how it is realised in the scenario in a brief manner
12 .. to ensure the user understand the context for the user guide instructions to follow.
13
14 Collectd is a daemon which collects system performance statistics periodically
15 and provides a variety of mechanisms to publish the collected metrics. It
16 supports more than 90 different input and output plugins. Input plugins
17 retrieve metrics and publish them to the collectd deamon, while output plugins
18 publish the data they receive to an end point. collectd also has infrastructure
19 to support thresholding and notification.
20
21 Barometer has enabled the following collectd plugins:
22
23 * *dpdkstat plugin*: A read plugin that retrieves stats from the DPDK extended
24   NIC stats API.
25
26 * *dpdkevents plugin*:  A read plugin that retrieves DPDK link status and DPDK
27   forwarding cores liveliness status (DPDK Keep Alive).
28
29 * *dpdk_telemetry plugin*:  A read plugin to collect dpdk interface stats and
30   application or global stats from dpdk telemetry library. Both 'dpdkstat' and
31   'dpdk_telemetry' plugins provides dpdk NIC Stats, but only 'dpdk_telemetry'
32   provides the DPDK Application stats. So in other words, 'dpdk_telemetry' is
33   an advanced version of dpdkstat. This plugin don't deal with dpdk events.
34   So not in related with 'dpdkevents' plugin. The mimimum dpdk version required
35   to use this plugin is 19.08.
36
37 .. note::
38   dpdpkstat and dpdk_telemetry should not be used together. Use dpdk_telemetry
39   if your version of dpdk supports it (i.e. DPDK >= 19.08) and use dpdkstat otherwise.
40   dpdkstat, dpdkevents and dpdk_telemetry plugins should only be used if your dpdk
41   application doesn't already have more relevant metrics available(e.g.ovs_stats).
42
43
44 * `gnocchi plugin`_: A write plugin that pushes the retrieved stats to
45   Gnocchi. It's capable of pushing any stats read through collectd to
46   Gnocchi, not just the DPDK stats.
47
48 * `aodh plugin`_: A notification plugin that pushes events to Aodh, and
49   creates/updates alarms appropriately.
50
51 * *hugepages plugin*:  A read plugin that retrieves the number of available
52   and free hugepages on a platform as well as what is available in terms of
53   hugepages per socket.
54
55 * *Open vSwitch events Plugin*: A read plugin that retrieves events from OVS.
56
57 * *Open vSwitch stats Plugin*: A read plugin that retrieves flow and interface
58   stats from OVS.
59
60 * *mcelog plugin*: A read plugin that uses mcelog client protocol to check for
61   memory Machine Check Exceptions and sends the stats for reported exceptions.
62
63 * *PMU plugin*: A read plugin that provides performance counters data on
64   Intel CPUs using Linux perf interface.
65
66 * *RDT plugin*: A read plugin that provides the last level cache utilization and
67   memory bandwidth utilization.
68
69 * *virt*: A read plugin that uses virtualization API *libvirt* to gather
70   statistics about virtualized guests on a system directly from the hypervisor,
71   without a need to install collectd instance on the guest.
72
73 * *SNMP Agent*: A write plugin that will act as a AgentX subagent that receives
74   and handles queries from SNMP master agent and returns the data collected
75   by read plugins. The SNMP Agent plugin handles requests only for OIDs
76   specified in configuration file. To handle SNMP queries the plugin gets data
77   from collectd and translates requested values from collectd's internal format
78   to SNMP format. Supports SNMP: get, getnext and walk requests.
79
80 All the plugins above are available on the collectd main branch, except for
81 the Gnocchi and Aodh plugins as they are Python-based plugins and only C
82 plugins are accepted by the collectd community. The Gnocchi and Aodh plugins
83 live in the OpenStack repositories.
84
85 .. TODO: Update this to reflect merging of these PRs
86 Other plugins existing as a pull request into collectd main:
87
88 * *Legacy/IPMI*: A read plugin that reports platform thermals, voltages,
89   fanspeed, current, flow, power etc. Also, the plugin monitors Intelligent
90   Platform Management Interface (IPMI) System Event Log (SEL) and sends the
91   appropriate notifications based on monitored SEL events.
92
93 * *PCIe AER*: A read plugin that monitors PCIe standard and advanced errors and
94   sends notifications about those errors.
95
96
97 Third party application in Barometer repository:
98
99 * *Open vSwitch PMD stats*: An aplication that retrieves PMD stats from OVS. It is run
100   through exec plugin.
101
102 **Plugins and application included in the Euphrates release:**
103
104 Write Plugins: aodh plugin, SNMP agent plugin, gnocchi plugin.
105
106 Read Plugins/application: Intel RDT plugin, virt plugin, Open vSwitch stats plugin,
107 Open vSwitch PMD stats application.
108
109 Collectd capabilities and usage
110 -------------------------------
111 .. Describe the specific capabilities and usage for <XYZ> feature.
112 .. Provide enough information that a user will be able to operate the feature on a deployed scenario.
113
114 The collectd plugins in Anuket are configured with reasonable defaults, but can
115 be overridden.
116
117 Building all Barometer upstreamed plugins from scratch
118 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119 The plugins that have been merged to the collectd main branch can all be
120 built and configured through the barometer repository.
121
122 .. note::
123  * sudo permissions are required to install collectd.
124  * These instructions are for Centos 7.
125
126 To build all the upstream plugins, clone the barometer repo:
127
128 .. code:: c
129
130     $ git clone https://gerrit.opnfv.org/gerrit/barometer
131
132 To install collectd as a service and install all it's dependencies:
133
134 .. code:: bash
135
136     $ cd barometer/systems && ./build_base_machine.sh
137
138 This will install collectd as a service and the base install directory
139 will be /opt/collectd.
140
141 Sample configuration files can be found in '/opt/collectd/etc/collectd.conf.d'
142
143 .. note::
144   If you don't want to use one of the Barometer plugins, simply remove the
145   sample config file from '/opt/collectd/etc/collectd.conf.d'
146 .. note::
147   If you plan on using the Exec plugin (for OVS_PMD_STATS or for executing scripts
148   on notification generation), the plugin requires a non-root user to execute scripts.
149   By default, `collectd_exec` user is used in the exec.conf provided in the sample
150   configurations directory under src/collectd in the Barometer repo. These scripts *DO NOT* create this user.
151   You need to create this user or modify the configuration in the sample configurations directory
152   under src/collectd to use another existing non root user before running build_base_machine.sh.
153
154 .. note::
155   If you are using any Open vSwitch plugins you need to run:
156
157   .. code:: bash
158
159     $ sudo ovs-vsctl set-manager ptcp:6640
160
161 After this, you should be able to start collectd as a service
162
163 .. code:: bash
164
165     $ sudo systemctl status collectd
166
167 If you want to use granfana to display the metrics you collect, please see:
168 `grafana guide`_
169
170 For more information on configuring and installing OpenStack plugins for
171 collectd, check out the `collectd-openstack-plugins GSG`_.
172
173 Below is the per plugin installation and configuration guide, if you only want
174 to install some/particular plugins.
175
176 DPDK plugins
177 ^^^^^^^^^^^^^
178 Repo: https://github.com/collectd/collectd
179
180 Branch: main
181
182 Dependencies: `DPDK <https://www.dpdk.org/>`_
183
184 .. note:: DPDK statistics plugin requires DPDK version 16.04 or later.
185
186 To build and install DPDK to /usr please see:
187 https://github.com/collectd/collectd/blob/main/docs/BUILD.dpdkstat.md
188
189 Building and installing collectd:
190
191 .. code:: bash
192
193     $ git clone https://github.com/collectd/collectd.git
194     $ cd collectd
195     $ ./build.sh
196     $ ./configure --enable-syslog --enable-logfile --enable-debug
197     $ make
198     $ sudo make install
199
200 .. note:: If DPDK was installed in a non standard location you will need to
201     specify paths to the header files and libraries using *LIBDPDK_CPPFLAGS* and
202     *LIBDPDK_LDFLAGS*. You will also need to add the DPDK library symbols to the
203     shared library path using *ldconfig*. Note that this update to the shared
204     library path is not persistant (i.e. it will not survive a reboot).
205
206 Example of specifying custom paths to DPDK headers and libraries:
207
208 .. code:: bash
209
210     $ ./configure LIBDPDK_CPPFLAGS="path to DPDK header files" LIBDPDK_LDFLAGS="path to DPDK libraries"
211
212 This will install collectd to default folder ``/opt/collectd``. The collectd
213 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
214 To configure the dpdkstats plugin you need to modify the configuration file to
215 include (uncomment lines as appropriate):
216
217 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/dpdkstat.conf
218    :start-at: LoadPlugin
219    :language: bash
220
221 To configure the dpdkevents plugin you need to modify the configuration file to
222 include (uncomment lines as appropriate):
223
224 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/dpdkevents.conf
225    :start-at: LoadPlugin
226    :language: bash
227
228 .. note:: Currently, the DPDK library doesn’t support API to de-initialize
229  the DPDK resources allocated on the initialization. It means, the collectd
230  plugin will not be able to release the allocated DPDK resources
231  (locks/memory/pci bindings etc.) correctly on collectd shutdown or reinitialize
232  the DPDK library if primary DPDK process is restarted. The only way to release
233  those resources is to terminate the process itself. For this reason, the plugin
234  forks off a separate collectd process. This child process becomes a secondary
235  DPDK process which can be run on specific CPU cores configured by user through
236  collectd configuration file (“Coremask” EAL configuration option, the
237  hexadecimal bitmask of the cores to run on).
238
239 For more information on the plugin parameters, please see:
240 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
241
242 .. note:: dpdkstat plugin initialization time depends on read interval. It
243  requires 5 read cycles to set up internal buffers and states, during that time
244  no statistics are submitted. Also, if plugin is running and the number of DPDK
245  ports is increased, internal buffers are resized. That requires 3 read cycles
246  and no port statistics are submitted during that time.
247
248 The Address-Space Layout Randomization (ASLR) security feature in Linux should be
249 disabled, in order for the same hugepage memory mappings to be present in all
250 DPDK multi-process applications.
251
252 To disable ASLR:
253
254 .. code:: bash
255
256     $ sudo echo 0 > /proc/sys/kernel/randomize_va_space
257
258 To fully enable ASLR:
259
260 .. code:: bash
261
262     $ sudo echo 2 > /proc/sys/kernel/randomize_va_space
263
264 .. warning:: Disabling Address-Space Layout Randomization (ASLR) may have security
265     implications. It is recommended to be disabled only when absolutely necessary,
266     and only when all implications of this change have been understood.
267
268 For more information on multi-process support, please see:
269 https://doc.dpdk.org/guides/prog_guide/multi_proc_support.html
270
271 **DPDK stats plugin limitations:**
272
273 1. The DPDK primary process application should use the same version of DPDK
274    that collectd DPDK plugin is using;
275
276 2. L2 statistics are only supported;
277
278 3. The plugin has been tested on Intel NIC’s only.
279
280 **DPDK stats known issues:**
281
282 * DPDK port visibility
283
284   When network port controlled by Linux is bound to DPDK driver, the port
285   will not be available in the OS. It affects the SNMP write plugin as those
286   ports will not be present in standard IF-MIB. Thus, additional work is
287   required to be done to support DPDK ports and statistics.
288
289 **DPDK telemetry plugin**
290
291 Please refer to https://wiki.anuket.io/display/HOME/DPDK+Telemetry+Plugin
292
293 Hugepages Plugin
294 ^^^^^^^^^^^^^^^^^
295 Repo: https://github.com/collectd/collectd
296
297 Branch: main
298
299 Dependencies: None, but assumes hugepages are configured.
300
301 To configure some hugepages:
302
303 .. code:: bash
304
305    $ sudo mkdir -p /mnt/huge
306    $ sudo mount -t hugetlbfs nodev /mnt/huge
307    $ sudo bash -c "echo 14336 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages"
308
309 Building and installing collectd:
310
311 .. code:: bash
312
313     $ git clone https://github.com/collectd/collectd.git
314     $ cd collectd
315     $ ./build.sh
316     $ ./configure --enable-syslog --enable-logfile --enable-hugepages --enable-debug
317     $ make
318     $ sudo make install
319
320 This will install collectd to default folder ``/opt/collectd``. The collectd
321 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
322 To configure the hugepages plugin you need to modify the configuration file to
323 include:
324
325 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/hugepages.conf
326    :start-at: LoadPlugin
327    :language: bash
328
329 For more information on the plugin parameters, please see:
330 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
331
332 Intel PMU Plugin
333 ^^^^^^^^^^^^^^^^
334 Repo: https://github.com/collectd/collectd
335
336 Branch: main
337
338 Dependencies:
339
340   * PMU tools (jevents library) https://github.com/andikleen/pmu-tools
341
342 To be suitable for use in collectd plugin shared library *libjevents* should be
343 compiled as position-independent code. To do this add the following line to
344 *pmu-tools/jevents/Makefile*:
345
346 .. code:: bash
347
348     CFLAGS += -fPIC
349
350 Building and installing *jevents* library:
351
352 .. code:: bash
353
354     $ git clone https://github.com/andikleen/pmu-tools.git
355     $ cd pmu-tools/jevents/
356     $ make
357     $ sudo make install
358
359 Download the Hardware Events that are relevant to your CPU, download the appropriate
360 CPU event list json file:
361
362 .. code:: bash
363
364     $ wget https://raw.githubusercontent.com/andikleen/pmu-tools/main/event_download.py
365     $ python event_download.py
366
367 This will download the json files to the location: $HOME/.cache/pmu-events/. If you don't want to
368 download these files to the aforementioned location, set the environment variable XDG_CACHE_HOME to
369 the location you want the files downloaded to.
370
371 Building and installing collectd:
372
373 .. code:: bash
374
375     $ git clone https://github.com/collectd/collectd.git
376     $ cd collectd
377     $ ./build.sh
378     $ ./configure --enable-syslog --enable-logfile --with-libjevents=/usr/local --enable-debug
379     $ make
380     $ sudo make install
381
382 This will install collectd to default folder ``/opt/collectd``. The collectd
383 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
384 To configure the PMU plugin you need to modify the configuration file to
385 include:
386
387 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/intel_pmu.conf
388    :start-at: LoadPlugin
389    :language: bash
390
391 If you want to monitor Intel CPU specific CPU events, make sure to uncomment the
392 ``EventList`` and ``HardwareEvents`` options above.
393
394 .. note::
395     If you set XDG_CACHE_HOME to anything other than the variable above - you will need to modify
396     the path for the EventList configuration.
397
398 Use ``Cores`` option to monitor metrics only for configured cores. If an empty string is provided
399 as value for this field default cores configuration is applied - that is all available cores
400 are monitored separately. To limit monitoring to cores 0-7 set the option as shown below:
401
402 .. code:: bash
403
404     Cores "[0-7]"
405
406 For more information on the plugin parameters, please see:
407 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
408
409 .. note::
410
411     The plugin opens file descriptors whose quantity depends on number of
412     monitored CPUs and number of monitored counters. Depending on configuration,
413     it might be required to increase the limit on the number of open file
414     descriptors allowed. This can be done using 'ulimit -n' command. If collectd
415     is executed as a service 'LimitNOFILE=' directive should be defined in
416     [Service] section of *collectd.service* file.
417
418 Intel RDT Plugin
419 ^^^^^^^^^^^^^^^^
420 Repo: https://github.com/collectd/collectd
421
422 Branch: main
423
424 Dependencies:
425
426 * PQoS/Intel RDT library https://github.com/intel/intel-cmt-cat
427 * msr kernel module
428
429 Building and installing PQoS/Intel RDT library:
430
431 .. code:: bash
432
433     $ git clone https://github.com/intel/intel-cmt-cat
434     $ cd intel-cmt-cat
435     $ make
436     $ make install PREFIX=/usr
437
438 You will need to insert the msr kernel module:
439
440 .. code:: bash
441
442     $ modprobe msr
443
444 Building and installing collectd:
445
446 .. code:: bash
447
448     $ git clone https://github.com/collectd/collectd.git
449     $ cd collectd
450     $ ./build.sh
451     $ ./configure --enable-syslog --enable-logfile --with-libpqos=/usr/ --enable-debug
452     $ make
453     $ sudo make install
454
455 This will install collectd to default folder ``/opt/collectd``. The collectd
456 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
457 To configure the RDT plugin you need to modify the configuration file to
458 include:
459
460 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/rdt.conf
461    :start-at: LoadPlugin
462    :language: bash
463
464 For more information on the plugin parameters, please see:
465 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
466
467 IPMI Plugin
468 ^^^^^^^^^^^^
469 Repo: https://github.com/collectd/collectd
470
471 Branch: feat_ipmi_events, feat_ipmi_analog
472
473 Dependencies: `OpenIPMI library <https://openipmi.sourceforge.io/>`_
474
475 The IPMI plugin is already implemented in the latest collectd and sensors
476 like temperature, voltage, fanspeed, current are already supported there.
477 The list of supported IPMI sensors has been extended and sensors like flow,
478 power are supported now. Also, a System Event Log (SEL) notification feature
479 has been introduced.
480
481 * The feat_ipmi_events branch includes new SEL feature support in collectd
482   IPMI plugin. If this feature is enabled, the collectd IPMI plugin will
483   dispatch notifications about new events in System Event Log.
484
485 * The feat_ipmi_analog branch includes the support of extended IPMI sensors in
486   collectd IPMI plugin.
487
488 **Install dependencies**
489
490 On Centos, install OpenIPMI library:
491
492 .. code:: bash
493
494     $ sudo yum install OpenIPMI ipmitool
495
496 Anyway, it's recommended to use the latest version of the OpenIPMI library as
497 it includes fixes of known issues which aren't included in standard OpenIPMI
498 library package. The latest version of the library can be found at
499 https://sourceforge.net/p/openipmi/code/ci/master/tree/. Steps to install the
500 library from sources are described below.
501
502 Remove old version of OpenIPMI library:
503
504 .. code:: bash
505
506     $ sudo yum remove OpenIPMI ipmitool
507
508 Build and install OpenIPMI library:
509
510 .. code:: bash
511
512     $ git clone https://git.code.sf.net/p/openipmi/code openipmi-code
513     $ cd openipmi-code
514     $ autoreconf --install
515     $ ./configure --prefix=/usr
516     $ make
517     $ sudo make install
518
519 Add the directory containing ``OpenIPMI*.pc`` files to the ``PKG_CONFIG_PATH``
520 environment variable:
521
522 .. code:: bash
523
524     export PKG_CONFIG_PATH=/usr/lib/pkgconfig
525
526 Enable IPMI support in the kernel:
527
528 .. code:: bash
529
530     $ sudo modprobe ipmi_devintf
531     $ sudo modprobe ipmi_si
532
533 .. note::
534   If HW supports IPMI, the ``/dev/ipmi0`` character device will be
535   created.
536
537 Clone and install the collectd IPMI plugin:
538
539 .. code:: bash
540
541     $ git clone https://github.com/collectd/collectd
542     $ cd collectd
543     $ ./build.sh
544     $ ./configure --enable-syslog --enable-logfile --enable-debug
545     $ make
546     $ sudo make install
547
548 This will install collectd to default folder ``/opt/collectd``. The collectd
549 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
550 To configure the IPMI plugin you need to modify the file to include:
551
552 .. code:: bash
553
554     LoadPlugin ipmi
555     <Plugin ipmi>
556        <Instance "local">
557          SELEnabled true # only feat_ipmi_events branch supports this
558        </Instance>
559     </Plugin>
560
561 .. note::
562   By default, IPMI plugin will read all available analog sensor values,
563   dispatch the values to collectd and send SEL notifications.
564
565 For more information on the IPMI plugin parameters and SEL feature configuration,
566 please see: https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
567
568 Extended analog sensors support doesn't require additional configuration. The usual
569 collectd IPMI documentation can be used:
570
571 - https://collectd.org/wiki/index.php/Plugin:IPMI
572 - https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_ipmi
573
574 IPMI documentation:
575
576 - https://www.kernel.org/doc/Documentation/IPMI.txt
577 - https://www.intel.com/content/www/us/en/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html
578
579 Mcelog Plugin
580 ^^^^^^^^^^^^^^
581 Repo: https://github.com/collectd/collectd
582
583 Branch: main
584
585 Dependencies: `mcelog <http://mcelog.org/>`_
586
587 Start by installing mcelog.
588
589 .. note::
590   The kernel has to have CONFIG_X86_MCE enabled. For 32bit kernels you
591   need atleast a 2.6,30 kernel.
592
593 On Centos:
594
595 .. code:: bash
596
597     $ sudo yum install mcelog
598
599 Or build from source
600
601 .. code:: bash
602
603     $ git clone https://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git
604     $ cd mcelog
605     $ make
606     ... become root ...
607     $ make install
608     $ cp mcelog.service /etc/systemd/system/
609     $ systemctl enable mcelog.service
610     $ systemctl start mcelog.service
611
612
613 Verify you got a /dev/mcelog. You can verify the daemon is running completely
614 by running:
615
616 .. code:: bash
617
618      $ mcelog --client
619
620 This should query the information in the running daemon. If it prints nothing
621 that is fine (no errors logged yet). More info @
622 http://www.mcelog.org/installation.html
623
624 Modify the mcelog configuration file "/etc/mcelog/mcelog.conf" to include or
625 enable:
626
627 .. code:: bash
628
629     socket-path = /var/run/mcelog-client
630     [dimm]
631     dimm-tracking-enabled = yes
632     dmi-prepopulate = yes
633     uc-error-threshold = 1 / 24h
634     ce-error-threshold = 10 / 24h
635
636     [socket]
637     socket-tracking-enabled = yes
638     mem-uc-error-threshold = 100 / 24h
639     mem-ce-error-threshold = 100 / 24h
640     mem-ce-error-log = yes
641
642     [page]
643     memory-ce-threshold = 10 / 24h
644     memory-ce-log = yes
645     memory-ce-action = soft
646
647     [trigger]
648     children-max = 2
649     directory = /etc/mcelog
650
651
652 Clone and install the collectd mcelog plugin:
653
654 .. code:: bash
655
656     $ git clone https://github.com/collectd/collectd
657     $ cd collectd
658     $ ./build.sh
659     $ ./configure --enable-syslog --enable-logfile --enable-debug
660     $ make
661     $ sudo make install
662
663 This will install collectd to default folder ``/opt/collectd``. The collectd
664 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
665 To configure the mcelog plugin you need to modify the configuration file to
666 include:
667
668 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/mcelog.conf
669    :start-at: LoadPlugin
670    :language: bash
671
672 For more information on the plugin parameters, please see:
673 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
674
675 Simulating a Machine Check Exception can be done in one of 3 ways:
676
677 * Running $make test in the mcelog cloned directory - mcelog test suite
678 * using mce-inject
679 * using mce-test
680
681 **mcelog test suite:**
682
683 It is always a good idea to test an error handling mechanism before it is
684 really needed. mcelog includes a test suite. The test suite relies on
685 mce-inject which needs to be installed and in $PATH.
686
687 You also need the mce-inject kernel module configured (with
688 CONFIG_X86_MCE_INJECT=y), compiled, installed and loaded:
689
690 .. code:: bash
691
692     $ modprobe mce-inject
693
694 Then you can run the mcelog test suite with
695
696 .. code:: bash
697
698     $ make test
699
700 This will inject different classes of errors and check that the mcelog triggers
701 runs. There will be some kernel messages about page offlining attempts. The
702 test will also lose a few pages of memory in your system (not significant).
703
704 .. note::
705   This test will kill any running mcelog, which needs to be restarted
706   manually afterwards.
707
708 **mce-inject:**
709
710 A utility to inject corrected, uncorrected and fatal machine check exceptions
711
712 .. code:: bash
713
714     $ git clone https://git.kernel.org/pub/scm/utils/cpu/mce/mce-inject.git
715     $ cd mce-inject
716     $ make
717     $ modprobe mce-inject
718
719 Modify the test/corrected script to include the following:
720
721 .. code:: bash
722
723     CPU 0 BANK 0
724     STATUS 0xcc00008000010090
725     ADDR 0x0010FFFFFFF
726
727 Inject the error:
728 .. code:: bash
729
730     $ ./mce-inject < test/corrected
731
732 .. note::
733   The uncorrected and fatal scripts under test will cause a platform reset.
734   Only the fatal script generates the memory errors**. In order to  quickly
735   emulate uncorrected memory errors and avoid host reboot following test errors
736   from mce-test suite can be injected:
737
738 .. code:: bash
739
740        $ mce-inject  mce-test/cases/coverage/soft-inj/recoverable_ucr/data/srao_mem_scrub
741
742 **mce-test:**
743
744 In addition a more in-depth test of the Linux kernel machine check facilities
745 can be done with the mce-test test suite. mce-test supports testing uncorrected
746 error handling, real error injection, handling of different soft offlining
747 cases, and other tests.
748
749 **Corrected memory error injection:**
750
751 To inject corrected memory errors:
752
753 * Remove sb_edac and edac_core kernel modules: rmmod sb_edac rmmod edac_core
754 * Insert einj module: modprobe einj param_extension=1
755 * Inject an error by specifying details (last command should be repeated at least two times):
756
757 .. code:: bash
758
759     $ APEI_IF=/sys/kernel/debug/apei/einj
760     $ echo 0x8 > $APEI_IF/error_type
761     $ echo 0x01f5591000 > $APEI_IF/param1
762     $ echo 0xfffffffffffff000 > $APEI_IF/param2
763     $ echo 1 > $APEI_IF/notrigger
764     $ echo 1 > $APEI_IF/error_inject
765
766 * Check the MCE statistic: mcelog --client. Check the mcelog log for injected error details: less /var/log/mcelog.
767
768 Open vSwitch Plugins
769 ^^^^^^^^^^^^^^^^^^^^
770 OvS Plugins Repo: https://github.com/collectd/collectd
771
772 OvS Plugins Branch: main
773
774 OvS Events MIBs: The SNMP OVS interface link status is provided by standard
775 `IF-MIB <http://www.net-snmp.org/docs/mibs/IF-MIB.txt>`_
776
777 Dependencies: Open vSwitch, `Yet Another JSON Library <https://github.com/lloyd/yajl>`_
778
779 On Centos, install the dependencies and Open vSwitch:
780
781 .. code:: bash
782
783     $ sudo yum install yajl-devel
784
785 Steps to install Open vSwtich can be found at
786 https://docs.openvswitch.org/en/latest/intro/install/fedora/
787
788 Start the Open vSwitch service:
789
790 .. code:: bash
791
792     $ sudo service openvswitch-switch start
793
794 Configure the ovsdb-server manager:
795
796 .. code:: bash
797
798     $ sudo ovs-vsctl set-manager ptcp:6640
799
800 Clone and install the collectd ovs plugin:
801
802 .. code:: bash
803
804     $ git clone $REPO
805     $ cd collectd
806     $ git checkout main
807     $ ./build.sh
808     $ ./configure --enable-syslog --enable-logfile --enable-debug
809     $ make
810     $ sudo make install
811
812 This will install collectd to default folder ``/opt/collectd``. The collectd
813 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
814 To configure the OVS events plugin you need to modify the configuration file
815 (uncommenting and updating values as appropriate) to include:
816
817 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/ovs_events.conf
818    :start-at: LoadPlugin
819    :language: bash
820
821 To configure the OVS stats plugin you need to modify the configuration file
822 (uncommenting and updating values as appropriate) to include:
823
824 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/ovs_stats.conf
825    :start-at: LoadPlugin
826    :language: bash
827
828 For more information on the plugin parameters, please see:
829 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
830
831 OVS PMD stats
832 ^^^^^^^^^^^^^
833 Repo: https://gerrit.opnfv.org/gerrit/gitweb?p=barometer.git
834
835 Prequistes:
836
837 #. Open vSwitch dependencies are installed.
838 #. Open vSwitch service is running.
839 #. Ovsdb-server manager is configured.
840
841 You can refer `Open vSwitch Plugins`_ section above for each one of them.
842
843 OVS PMD stats application is run through the exec plugin.
844
845 To configure the OVS PMD stats application you need to modify the exec plugin configuration
846 to include:
847
848 .. code:: bash
849
850     <LoadPlugin exec>
851        Interval 1
852     </LoadPlugin
853     <Plugin exec>
854         Exec "user:group" "<path to ovs_pmd_stat.sh>"
855     </Plugin>
856
857 .. note:: Exec plugin configuration has to be changed to use appropriate user before starting collectd service.
858
859 ``ovs_pmd_stat.sh`` calls the script for OVS PMD stats application with its argument:
860
861 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/ovs_pmd_stats.sh
862    :start-at: python
863    :language: bash
864
865 SNMP Agent Plugin
866 ^^^^^^^^^^^^^^^^^
867 Repo: https://github.com/collectd/collectd
868
869 Branch: main
870
871 Dependencies: NET-SNMP library
872
873 Start by installing net-snmp and dependencies.
874
875 On Centos 7:
876
877 .. code:: bash
878
879     $ sudo yum install net-snmp net-snmp-libs net-snmp-utils net-snmp-devel
880     $ sudo systemctl start snmpd.service
881
882 go to the `snmp configuration`_ steps.
883
884 From source:
885
886 Clone and build net-snmp:
887
888 .. code:: bash
889
890     $ git clone https://github.com/haad/net-snmp.git
891     $ cd net-snmp
892     $ ./configure --with-persistent-directory="/var/net-snmp" --with-systemd --enable-shared --prefix=/usr
893     $ make
894
895 Become root
896
897 .. code:: bash
898
899     $ make install
900
901 Copy default configuration to persistent folder:
902
903 .. code:: bash
904
905     $ cp EXAMPLE.conf /usr/share/snmp/snmpd.conf
906
907 Set library path and default MIB configuration:
908
909 .. code:: bash
910
911     $ cd ~/
912     $ echo export LD_LIBRARY_PATH=/usr/lib >> .bashrc
913     $ net-snmp-config --default-mibdirs
914     $ net-snmp-config --snmpconfpath
915
916 Configure snmpd as a service:
917
918 .. code:: bash
919
920     $ cd net-snmp
921     $ cp ./dist/snmpd.service /etc/systemd/system/
922     $ systemctl enable snmpd.service
923     $ systemctl start snmpd.service
924
925 .. _`snmp configuration`:
926
927 Add the following line to snmpd.conf configuration file
928 ``/etc/snmp/snmpd.conf`` to make all OID tree visible for SNMP clients:
929
930 .. code:: bash
931
932     view    systemview    included   .1
933
934 To verify that SNMP is working you can get IF-MIB table using SNMP client
935 to view the list of Linux interfaces:
936
937 .. code:: bash
938
939     $ snmpwalk -v 2c -c public localhost IF-MIB::interfaces
940
941 Get the default MIB location:
942
943 .. code:: bash
944
945     $ net-snmp-config --default-mibdirs
946     /opt/stack/.snmp/mibs:/usr/share/snmp/mibs
947
948 Install Intel specific MIBs (if needed) into location received by
949 ``net-snmp-config`` command (e.g. ``/usr/share/snmp/mibs``).
950
951 .. code:: bash
952
953     $ git clone https://gerrit.opnfv.org/gerrit/barometer.git
954     $ sudo cp -f barometer/mibs/*.txt /usr/share/snmp/mibs/
955     $ sudo systemctl restart snmpd.service
956
957 Clone and install the collectd snmp_agent plugin:
958
959 .. code:: bash
960
961     $ cd ~
962     $ git clone https://github.com/collectd/collectd
963     $ cd collectd
964     $ ./build.sh
965     $ ./configure --enable-syslog --enable-logfile --enable-debug --enable-snmp --with-libnetsnmp
966     $ make
967     $ sudo make install
968
969 This will install collectd to default folder ``/opt/collectd``. The collectd
970 configuration file (``collectd.conf``) can be found at ``/opt/collectd/etc``.
971
972 **SNMP Agent plugin is a generic plugin and cannot work without configuration**.
973 To configure the snmp_agent plugin you need to modify the configuration file to
974 include OIDs mapped to collectd types. The following example maps scalar
975 memAvailReal OID to value represented as free memory type of memory plugin:
976
977 .. code:: bash
978
979     LoadPlugin snmp_agent
980     <Plugin "snmp_agent">
981       <Data "memAvailReal">
982         Plugin "memory"
983         Type "memory"
984         TypeInstance "free"
985         OIDs "1.3.6.1.4.1.2021.4.6.0"
986       </Data>
987     </Plugin>
988
989
990 The ``snmpwalk`` command can be used to validate the collectd configuration:
991
992 .. code:: bash
993
994     $ snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.2021.4.6.0
995     UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 135237632 kB
996
997
998 **Limitations**
999
1000 * Object instance with Counter64 type is not supported in SNMPv1. When GetNext
1001   request is received, Counter64 type objects will be skipped. When Get
1002   request is received for Counter64 type object, the error will be returned.
1003 * Interfaces that are not visible to Linux like DPDK interfaces cannot be
1004   retreived using standard IF-MIB tables.
1005
1006 For more information on the plugin parameters, please see:
1007 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
1008
1009 For more details on AgentX subagent, please see:
1010 http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/
1011
1012 .. _virt-plugin:
1013
1014 virt plugin
1015 ^^^^^^^^^^^
1016 Repo: https://github.com/collectd/collectd
1017
1018 Branch: main
1019
1020 Dependencies: `libvirt <https://libvirt.org/>`_, libxml2
1021
1022 On Centos, install the dependencies:
1023
1024 .. code:: bash
1025
1026     $ sudo yum install libxml2-devel libpciaccess-devel yajl-devel device-mapper-devel
1027
1028 Install libvirt:
1029
1030 .. note:: libvirt version in package manager might be quite old and offer only
1031     limited functionality. Hence, building and installing libvirt from sources
1032     is recommended. Detailed instructions can bet found at:
1033     https://libvirt.org/compiling.html
1034
1035 .. code:: bash
1036
1037     $ sudo yum install libvirt-devel
1038
1039 Certain metrics provided by the plugin have a requirement on a minimal version of
1040 the libvirt API. *File system information* statistics require a *Guest Agent (GA)*
1041 to be installed and configured in a VM. User must make sure that installed GA
1042 version supports retrieving file system information. Number of *Performance monitoring events*
1043 metrics depends on running libvirt daemon version.
1044
1045 .. note:: Please keep in mind that RDT metrics (part of *Performance monitoring
1046     events*) have to be supported by hardware. For more details on hardware support,
1047     please see:
1048     https://github.com/intel/intel-cmt-cat
1049
1050     Additionally perf metrics **cannot** be collected if *Intel RDT* plugin is enabled.
1051
1052 libvirt version can be checked with following commands:
1053
1054 .. code:: bash
1055
1056     $ virsh --version
1057     $ libvirtd --version
1058
1059 .. table:: Extended statistics requirements
1060
1061     +-------------------------------+--------------------------+-------------+
1062     | Statistic                     | Min. libvirt API version | Requires GA |
1063     +===============================+==========================+=============+
1064     | Domain reason                 | 0.9.2                    | No          |
1065     +-------------------------------+--------------------------+-------------+
1066     | Disk errors                   | 0.9.10                   | No          |
1067     +-------------------------------+--------------------------+-------------+
1068     | Job statistics                | 1.2.9                    | No          |
1069     +-------------------------------+--------------------------+-------------+
1070     | File system information       | 1.2.11                   | Yes         |
1071     +-------------------------------+--------------------------+-------------+
1072     | Performance monitoring events | 1.3.3                    | No          |
1073     +-------------------------------+--------------------------+-------------+
1074
1075 Start libvirt daemon:
1076
1077 .. code:: bash
1078
1079     $ systemctl start libvirtd
1080
1081 Create domain (VM) XML configuration file. For more information on domain XML
1082 format and examples, please see:
1083 https://libvirt.org/formatdomain.html
1084
1085 .. note:: Installing additional hypervisor dependencies might be required before
1086     deploying virtual machine.
1087
1088 Create domain, based on created XML file:
1089
1090 .. code:: bash
1091
1092     $ virsh define DOMAIN_CFG_FILE.xml
1093
1094 Start domain:
1095
1096 .. code:: bash
1097
1098     $ virsh start DOMAIN_NAME
1099
1100 Check if domain is running:
1101
1102 .. code:: bash
1103
1104     $ virsh list
1105
1106 Check list of available *Performance monitoring events* and their settings:
1107
1108 .. code:: bash
1109
1110     $ virsh perf DOMAIN_NAME
1111
1112 Enable or disable *Performance monitoring events* for domain:
1113
1114 .. code:: bash
1115
1116     $ virsh perf DOMAIN_NAME [--enable | --disable] EVENT_NAME --live
1117
1118 Clone and install the collectd virt plugin:
1119
1120 .. code:: bash
1121
1122     $ git clone $REPO
1123     $ cd collectd
1124     $ ./build.sh
1125     $ ./configure --enable-syslog --enable-logfile --enable-debug
1126     $ make
1127     $ sudo make install
1128
1129 Where ``$REPO`` is equal to information provided above.
1130
1131 This will install collectd to ``/opt/collectd``. The collectd configuration file
1132 ``collectd.conf`` can be found at ``/opt/collectd/etc``.
1133 To load the virt plugin user needs to modify the configuration file to include:
1134
1135 .. code:: bash
1136
1137     LoadPlugin virt
1138
1139 Additionally, user can specify plugin configuration parameters in this file,
1140 such as connection URL, domain name and much more. By default extended virt plugin
1141 statistics are disabled. They can be enabled with ``ExtraStats`` option.
1142
1143 .. code:: bash
1144
1145     <Plugin virt>
1146        RefreshInterval 60
1147        ExtraStats "cpu_util disk disk_err domain_state fs_info job_stats_background pcpu perf vcpupin"
1148     </Plugin>
1149
1150 For more information on the plugin parameters, please see:
1151 https://github.com/collectd/collectd/blob/main/src/collectd.conf.pod
1152
1153 .. _install-collectd-as-a-service:
1154
1155 Installing collectd as a service
1156 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1157
1158 Collectd service scripts are available in the collectd/contrib directory.
1159 To install collectd as a service:
1160
1161 .. code:: bash
1162
1163     $ sudo cp contrib/systemd.collectd.service /etc/systemd/system/
1164     $ cd /etc/systemd/system/
1165     $ sudo mv systemd.collectd.service collectd.service
1166     $ sudo chmod +x collectd.service
1167
1168 Modify collectd.service
1169
1170 .. code:: bash
1171
1172     [Service]
1173     ExecStart=/opt/collectd/sbin/collectd
1174     EnvironmentFile=-/opt/collectd/etc/
1175     EnvironmentFile=-/opt/collectd/etc/
1176     CapabilityBoundingSet=CAP_SETUID CAP_SETGID
1177
1178 Reload
1179
1180 .. code:: bash
1181
1182     $ sudo systemctl daemon-reload
1183     $ sudo systemctl start collectd.service
1184     $ sudo systemctl status collectd.service should show success
1185
1186 Additional useful plugins
1187 ^^^^^^^^^^^^^^^^^^^^^^^^^
1188
1189 **Exec Plugin** : Can be used to show you when notifications are being
1190 generated by calling a bash script that dumps notifications to file. (handy
1191 for debug). Modify ``/opt/collectd/etc/collectd.conf`` to include the
1192 ``NotificationExec`` config option, taking care to add the right directory path
1193 to the ``write_notification.sh`` script:
1194
1195 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/exec.conf
1196    :start-at: LoadPlugin
1197    :emphasize-lines: 6
1198    :language: bash
1199
1200 ``write_notification.sh`` writes the notification passed from exec through
1201 STDIN to a file (``/tmp/notifications``):
1202
1203 .. literalinclude:: ../../../src/collectd/collectd_sample_configs/write_notification.sh
1204    :start-at: rm -f
1205    :language: bash
1206
1207 output to ``/tmp/notifications`` should look like:
1208
1209 .. code:: bash
1210
1211     Severity:WARNING
1212     Time:1479991318.806
1213     Host:localhost
1214     Plugin:ovs_events
1215     PluginInstance:br-ex
1216     Type:gauge
1217     TypeInstance:link_status
1218     uuid:f2aafeec-fa98-4e76-aec5-18ae9fc74589
1219
1220     linkstate of "br-ex" interface has been changed to "DOWN"
1221
1222 * **logfile plugin**: Can be used to log collectd activity. Modify
1223   /opt/collectd/etc/collectd.conf to include:
1224
1225 .. code:: bash
1226
1227     LoadPlugin logfile
1228     <Plugin logfile>
1229         LogLevel info
1230         File "/var/log/collectd.log"
1231         Timestamp true
1232         PrintSeverity false
1233     </Plugin>
1234
1235
1236 Monitoring Interfaces and Openstack Support
1237 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1238 .. Figure:: monitoring_interfaces.png
1239
1240    Monitoring Interfaces and Openstack Support
1241
1242 The figure above shows the DPDK L2 forwarding application running on a compute
1243 node, sending and receiving traffic. Collectd is also running on this compute
1244 node retrieving the stats periodically from DPDK through the dpdkstat plugin
1245 and publishing the retrieved stats to OpenStack through the
1246 collectd-openstack-plugins.
1247
1248 To see this demo in action please checkout: `Barometer OPNFV Summit demo`_
1249
1250 For more information on configuring and installing OpenStack plugins for
1251 collectd, check out the `collectd-openstack-plugins GSG`_.
1252
1253 Security
1254 ^^^^^^^^
1255 * AAA – on top of collectd there secure agents like SNMP V3, Openstack agents
1256   etc. with their own AAA methods.
1257
1258 * Collectd runs as a daemon with root permissions.
1259
1260 * The `Exec plugin`_ allows the execution of external programs but counters the security
1261   concerns by:
1262
1263   * Ensuring that only one instance of the program is executed by collectd at any time
1264   * Forcing the plugin to check that custom programs are never executed with superuser
1265     privileges.
1266
1267 * Protection of Data in flight:
1268
1269   * It's recommend to use a minimum version of 4.7 of the Network plugin which provides
1270     the possibility to cryptographically sign or encrypt the network traffic.
1271   * Write Redis plugin or the Write MongoDB plugin are recommended to store the data.
1272   * For more information, please see: https://collectd.org/wiki/index.php?title=Networking_introduction
1273
1274 * Known vulnerabilities include:
1275
1276   * https://www.cvedetails.com/vulnerability-list/vendor_id-11242/Collectd.html
1277
1278     * `CVE-2017-7401`_ fixed https://github.com/collectd/collectd/issues/2174 in Version 5.7.2.
1279     * `CVE-2016-6254`_ fixed https://mailman.verplant.org/pipermail/collectd/2016-July/006838.html
1280         in Version  5.4.3.
1281     * `CVE-2010-4336`_ fixed https://mailman.verplant.org/pipermail/collectd/2010-November/004277.html
1282         in Version 4.10.2.
1283
1284   * https://www.cvedetails.com/product/20310/Collectd-Collectd.html?vendor_id=11242
1285
1286 * It's recommended to only use collectd plugins from signed packages.
1287
1288 References
1289 ^^^^^^^^^^^
1290 .. [1] https://collectd.org/wiki/index.php/Naming_schema
1291 .. [2] https://github.com/collectd/collectd/blob/main/src/daemon/plugin.h
1292 .. [3] https://collectd.org/wiki/index.php/Value_list_t
1293 .. [4] https://collectd.org/wiki/index.php/Data_set
1294 .. [5] https://collectd.org/documentation/manpages/types.db.5.shtml
1295 .. [6] https://collectd.org/wiki/index.php/Data_source
1296 .. [7] https://collectd.org/wiki/index.php/Meta_Data_Interface
1297
1298 .. _Barometer OPNFV Summit demo: https://prezi.com/kjv6o8ixs6se/software-fastpath-service-quality-metrics-demo/
1299 .. _gnocchi plugin: https://opendev.org/x/collectd-openstack-plugins/src/branch/stable/ocata/
1300 .. _aodh plugin: https://opendev.org/x/collectd-openstack-plugins/src/branch/stable/ocata/
1301 .. _collectd-openstack-plugins GSG: https://opendev.org/x/collectd-openstack-plugins/src/branch/master/doc/source/GSG.rst
1302 .. _grafana guide: https://wiki.anuket.io/display/HOME/Installing+and+configuring+InfluxDB+and+Grafana+to+display+metrics+with+collectd 
1303 .. _CVE-2017-7401: https://www.cvedetails.com/cve/CVE-2017-7401/
1304 .. _CVE-2016-6254: https://www.cvedetails.com/cve/CVE-2016-6254/
1305 .. _CVE-2010-4336: https://www.cvedetails.com/cve/CVE-2010-4336/
1306 .. _Exec plugin: https://collectd.org/wiki/index.php/Plugin:Exec