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