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