savoirfairelinux / mod-booster-snmp

Shinken module for boosting SNMP connections
GNU Affero General Public License v3.0
3 stars 9 forks source link

Use with Alignak ? #20

Open mohierf opened 7 years ago

mohierf commented 7 years ago

What about porting this module to the Alignak framework ?

I am interested in it and may help with:

?

fpeyre commented 7 years ago

Hello, We are interested in porting this module to Alignak, but we are busy at the moment.

To have an idea on how much time it can take, I have seen you port another module like the nrpe-booster. What are the main changes we must apply to transform a shinken module to an alignak module ? Is it just replacing the shinken library with its alignak equivalent or it is more complex ?

mohierf commented 7 years ago

I made a port of the nrpe-booster module and this took me no more than one day to have a full port of the module and its test environment.

If you have a look into this module: https://github.com/Alignak-monitoring-contrib/alignak-module-nrpe-booster it will give an idea of the main modifications ...

If I find some few time in the next days, I will try to submit a PR ...

mohierf commented 7 years ago

Are you using some specific Shinken features or modules for this module ?

fpeyre commented 7 years ago

After a quick review, just the shinken.logger and shinken.MacroResolver

mohierf commented 7 years ago

I see in the module doc that it requires : Shinken 1.2+ < 2.0 ... should I understand that this module is not compatible with Shinken 2.4 ?

fpeyre commented 7 years ago

I use it with Shinken 2.2 without problem. So it should works with shinken 2.4 (I can make a quick test)

Edit: I confirm, it wortks with shinken 2.4 too

mohierf commented 7 years ago

I created a repo here: https://github.com/Alignak-monitoring-contrib/alignak-module-snmp-booster. I will port your current version to the Alignak module architecture and we will be able to give a try :wink:

fpeyre commented 7 years ago

Ok, I give you the protocol and the file to make the test

First, you need: Snmpsim : It simulate a snmp device with a .snmprec file A redis server (Use like a cache) A .ini file who define which OID you want request and the trigger on this OID And the shinken/alignak config

For snmpsim : http://snmpsim.sourceforge.net/ For the snmprec file : I take this : https://github.com/murrant/librenms-snmpsim/blob/master/captures/localhost.snmprec For the .ini file : This : https://github.com/xkilian/genDevConfig/blob/master/sample-config/genConfig/Defaults_base.ini and this https://github.com/xkilian/genDevConfig/blob/2a62141a748b38ddab36f4fd249e64f20e0ee371/sample-config/genConfig/Defaults_plugin_netsnmp.ini

Now the fun part:

To simulate the device , you run the following command :

snmpsimd --v2c-arch --data-dir=./test --agent-udpv4-endpoint=0.0.0.0:9999

--data-dir is the path of your snmprec file --agent-udpv4-endpoint is the ip+the port of your simulator (Here : localhost on port 9999)

You paste the .ini file in the directory define in your file to configure the alignak module (called datasource)

And now the configuration :

define host {
   host_name                    172.17.0.1
   display_name                 172.17.0.1
   _MAXOIDREQUEST               64
   _SNMPCOMMUNITYREAD           test
   _sys_location                "Mobile"
   address                      172.17.0.1
   use                          SnmpBooster-host
   business_impact              0
   register                     1
}

define service {
   host_name                    172.17.0.1
   service_description          chassis
   display_name                 host - *nix box
   _class                       IbmIMM_x3550
   _display_order               999
   _dstemplate                  generic-box-netsnmp-nonice
   _inst                        0
   notes                        Linux tmurray-linux.exchange.ncn.net 4.5.3-gentoo #1 SMP Mon May 9 15:23:37 CDT 2016 x86_64<BR>1<BR>\"Mobile\"<BR>sysLocation: \"Mobile\"<BR>sysContact: \"tonym@ncn.net\"
   use                          default-snmp-template
   business_impact              0
   register                     1
}

define service {
   host_name                    172.17.0.1
   service_description          chassis.device-traffic
   service_dependencies         ,chassis
   display_name                 Switch fabric statistics - Packets per Second
   _display_order               998
   _dstemplate                  Device-Traffic
   notes                        Switch fabric statistics - Packets per Second
   use                          default-snmp-template
   business_impact              0
   register                     1
}

define service {
   host_name                    172.17.0.1
   service_description          172.17.0.1_system
   service_dependencies         ,chassis
   display_name                 172.17.0.1_system
   _display_order               997
   _dstemplate                  hr_System
   _inst
   use                          default-snmp-template
   business_impact              0
   register                     1
}

define host{
  name                    SnmpBooster-host
  alias                   SnmpBooster-host template
  check_command           check_host_alive
  max_check_attempts      3
  check_interval          5
  retry_interval          1
  hostgroup                 +SNMP
  use                     pack-generic-host
  register                0
  _SNMPCOMMUNITYREAD        $SNMPCOMMUNITYREAD$
}

define command {
  command_name    check_snmp_booster
  command_line    check_snmp_booster -H $HOSTNAME$ -A $HOSTADDRESS$ -S '$SERVICEDESC$' -C $_HOSTSNMPCOMMUNITYREAD$ -V 2c -t $ARG1$ -i $_SERVICEINST$ -T $_SERVICETRIGGERGROUP$ -P 9999 -n '$_SERVICEINSTNAME$' -N $_SERVICEMAPPING$
  module_type     snmp_booster
}

define service {
  name                    default-snmp-template
  check_command           check_snmp_booster!$_SERVICEDSTEMPLATE$!$_SERVICEINST$!$_SERVICETRIGGERGROUP
  _inst                   None
  _triggergroup           None
  _mapping                None
  max_check_attempts      3
  check_interval          1
  retry_interval          1
  register                0
}

Maybe you must change some things:

_SNMPCOMMUNITYREAD : It's the name oy your snmprec file (For example here, my file called test.snmprec) The address of the host (Must match the adresse of the snmpsim)

After that, you run your redis-server (Don't forget to change db_host and db_port in the snmp-booster module configuration to match your redis server)

And finally , run alignak and check if the service obtain value