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