Sorry, the first message got sent as HTML, acc. to

https://lists.icinga.org/pipermail/icinga-users/attachments/20150728/a6bea150/attachment.html

which is barely readable.

I hope you don't mind if I resend as plain text ...

regards
Thorsten


***********************

Hi @ all,

I'm new to Icinga2 (and somewhat to monitoring in general).
I've already consulted http://docs.icinga.org/icinga2 and while the
documentation appears to be comprehensive, it is also very dense and
-- at least to me -- there is some sort of howto-like-glue missing,
to form the picture of all the bits an pieces :-)


What I'm trying to do for starters is to monitor some Cisco switches,
for instance port status.

I downloaded https://labs.consol.de/nagios/check_nwc_health/ and I'm using
this as check_command.

My idea now was to generate templates for the various Cisco Switch models,
e.g. the 2940 in my lab:


===========================================================================
template Host "cisco-2940"{

   /* "FastEthernet0/1" is the interface name,
    * and key name in service apply for later on
    */
   vars.interfaces["FastEthernet0/1"] = {
      /* define all custom attributes with the
       * same name required for command parameters/arguments
       * in service apply (look into your CheckCommand definition)
       */
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/2"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/3"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/4"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/5"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }
  vars.interfaces["FastEthernet0/6"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/7"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["FastEthernet0/8"] = {
      iftraffic_units = "f"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

   vars.interfaces["GigabitEthernet0/1"] = {
      iftraffic_units = "g"
      iftraffic_mode  = "interface-status"
      iftraffic_community = IftrafficSnmpCommunity
   }

}
===========================================================================


BTW: 'iftraffic_units = "f"' and  'iftraffic_community =
IftrafficSnmpCommunity'
are not used at the moment.


then I use the "apply Service" example from
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#custom-attributes



===========================================================================
* loop over the host.vars.interfaces dictionary
  * for (key => value in dict) means `interface_name` as key
  * and `interface_config` as value. Access config attributes
  * with the indexer (`.`) character.
  */
apply Service "if-" for (interface_name => interface_config in
host.vars.interfaces) {
   import "generic-service"
   check_command = "check_nwc_health_2c"
   display_name = "IF-" + interface_name


   /* use the key as interface argument (no duplication of values in
host.vars.interfaces) */
   vars.check_nwc_health_name = interface_name


   /* set the check mode */
   vars.check_nwc_health_mode = interface_config.iftraffic_mode


   /* map the custom attributes as command arguments */
   vars.iftraffic_units = interface_config.iftraffic_units
   vars.iftraffic_community = interface_config.iftraffic_community

   /* the above can be achieved in a shorter fashion if the names inside
host.vars.interfaces
    * are the _exact_ same as required as command parameter by the check
command
    * definition.
    */
   /* vars += interface_config*/


   /* set the global constant if not explicitely
    * not provided by the `interfaces` dictionary on the host
    */
   if (len(interface_config.iftraffic_community) == 0 ||
len(vars.iftraffic_community) == 0) {
     vars.iftraffic_community = IftrafficSnmpCommunity
   }

/* Calculate some additional object attributes after populating the
`vars` dictionary */
   notes = "Interface check for " + interface_name + " (units: '" +
interface_config.iftraffic_units + "') in VLAN '" + vars.vlan + "' with
' QoS '" + vars.qos + "'"
   notes_url = "http://foreman.company.com/hosts/"; + host.name
   action_url = "http://snmp.checker.company.com/"; + host.name + "/if-"
+ interface_name

     check_interval = 10
     retry_interval = 10
}

===========================================================================


The checkCommand looks as follow:


===========================================================================
object CheckCommand "check_nwc_health_2c" {
         import "plugin-check-command"
         command = [ PluginDir + "/check_nwc_health" ]
         arguments = {
                 "-H" = "$check_nwc_health_address$"
                 "--protocol" = "$check_nwc_health_protocol$"
                 "--community" = "$check_nwc_health_community$"
                 "--mode" = "$check_nwc_health_mode$"
                 "--name" = "$check_nwc_health_name$"
         }
         vars.check_nwc_health_address = "$address$"
         vars.check_nwc_health_protocol = "2c"
         vars.check_nwc_health_community = "private"
}

===========================================================================


Finally I have a config for my LAB switch:


===========================================================================
object Host "lab_switch"{
     import "generic-host"
     import "cisco-2940"
     vars.devicetype = "switch"
     vars.devicemanufacturer = "cisco"
     vars.deviceproduct = "2940"
     address = "172.30.100.36"
}

===========================================================================


Now as this works great for all ports, it also gives a CRITICAL messages for
the unconnected ports. Since I'd like to apply this to all our switches, I'm
looking for some way to specify in the 'object Host "lab_switch"' stanza
which
ports to monitor or which to ignore for each switch.

I also had a look at check_nwc_health_2c in order to see if I could
modify it
to return "OK" if a switch port is administrativly down, but had no luck
so far.


My concrete questions would be:

i) how do I add monitor / ignore directives to the Host object?

ii) is this a feasible way of implementing the monitoring for switch
ports or
     am I going totally in the wrong direction?

iii) if this is a bad idea in general, could you point me to some
examples on
      "how to do it right"? :-)

iv) one OT question to the book "Das Nagios-/Icinga-Kochbuch" ISBN
978-3868993462 -
     does it cover Icinga1 or Icinga2?


Any help / feedback would be greatly appreciated!


kind regards,

Thorsten



_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to