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