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