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