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