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