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