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