Monitoring a switch with Icinga2 - revisited

This forum was archived to /woltlab and is now in read-only mode.
  • Hey all,


    Today, I configured an object to check traffic on physical firewall ports (which acts like a switch as well). It is successfully configured and it is based off of this thread from about 8 months ago, specifically the reply from @MarcusCaepio, where he posted his services.conf, commands.conf, and hosts.conf when integrating this script.


    If you'd like details on the specifics on how I configured it, contact me.


    If anyone is familiar with switches, they have ports, and Icinga2 is able to use a perl script (check_snmp_int.pl) to monitor the throughput of them. There is a port on my firewall that is by default, always off. This is a problem for Icinga2 because it detects it as a critical problem.


    Currently, to work around this problem, I have created TWO definitions for each file (services, commands, hosts), one for the regular interfaces and one for the mgmt interface. (regular and inverse)


    i.e.,



    I could post the other objects but that shouldn't be necessary. The point is that I have to make two definitions, one for the regular interfaces that should be UP and one for the MGMT interface that should always be DOWN, so that I can use the inverse (-i) parameter for the check_snmp_int.pl script (so that DOWN doesn't report as a critical problem).


    This works, but is a little bit ugly. I'd like to have it all integrated with one host so that it can all be viewed in one spot.


    Is this possible?


    I've tried to explain the dilemma as clearly as possible, but I know for a fact that it may get confusing. Please let me know if there's additional information that is needed.


    Thanks for any help!

  • Hello,


    I'm using my own couple of scripts to dynamically update daily the list of interfaces and switches(~20)
    https://github.com/Isma399/dyn…ches_dyn_update_icinga.py


    First, in the main block of switches_dyn_update_icinga.py, I declare my switches, for instance:


    Code
    1. switches = {'c3650': {"load":"1.3.6.1.4.1.9.2.1.58.0"}, \
    2. 'c2960g': {}, 'c2960s': {},\
    3. "c4500x" :{"load":"1.3.6.1.4.1.9.2.1.58.0"} \
    4. }


    The script generates a file containing declaration of switch like that (after removing unrouted VLAN, Stack, Null0 interfaces, interfaces down (ifOperStatus!=1), interfaces where ifSpeed not defined):

    Code
    1. object Host "c3750x" {
    2. import "generic-switch"
    3. groups = [ "switches" ]
    4. address = "x.x.x.x"
    5. vars.load = "1.3.6.1.4.1.9.9.109.1.1.1.1.5.1"
    6. vars.interfaces ="10623 10105 10104 10106 10101 10103 10102 10602 1 10603 10601 10606 10605 10621 10624 10701 10622 10612 "
    7. }


    Then, the check command uses the second script :
    https://github.com/Isma399/dyn…master/check_iftraffic.py


    More info: dynamically updates interfaces switches list and generate a grafana dashboard



    Hope that would be useful for you.

  • I do not know anything about smtp.
    But the thread you refer to creates a service for each port, so that all of these are below one host.


    So, why not do:


  • @Isma399


    Thanks! A few questions:
    1. It updates daily? How would you know if a port were to go down or not during a day? Does this mean that it's not being monitored in "real-time"?
    2. I noticed that in the thread you linked, it generates a Grafana dashboard. Could you post what that looks like? I'm curious because I'm thinking of using Grafana.


    @sru


    Thanks sru. This is snmp by the way. Not sure if you made a typo, but you said:



    sru wrote:

    I do not know anything about smtp.

    Your solution is more like what I was looking for since all I was looking for to slightly tweak my current configs because I didn't want two hosts for the same switch. I actually have the two services defined like you have it here, just need to tweak it so that it's being applied to host.vars.mgmtint and assigned to host.vars.int. Previously, I had it assigned to the host names (since I had two different hosts).


    I had some problems deploying your configuration the way it is, so I didn't use your configs but instead just added these lines tot my existing config:



    Code
    1. vars.mgmtint["MGMT"] = {
    2. int = "MGMT (MGMT)"
    3. }

    and also took out my second host definition.


    This seems to work fine, but the output shows an error for "use of uninitialized value $perf_out in print at /usr/lib64/nagios/plugins/check_snmp_int.pl line 809".


    I think I know why -- because the script usually takes in a value, but since I have the parameter to take the inverse (down is good, up is bad), the script doesn't receive a value for the $perf_out variable (which I assume is the performance output).


    Thanks for the quick reply Isma399 and sru!

  • This is snmp by the way. Not sure if you made a typo

    Yes, typo, sorry.



    I had some problems deploying your configuration the way it is

    I did type it into my machine and validated it before i posted. It is at least syntactically correct.


    With the error from your perl plugin, you are left alone...

  • Hello,
    1. It updates daily? How would you know if a port were to go down or not
    during a day? Does this mean that it's not being monitored in
    "real-time"?


    If a port goes down, we'll be alerted.
    If we put a port up, il will be monitored the next day.


    2. I noticed that in the thread you linked, it generates a Grafana
    dashboard. Could you post what that looks like? I'm curious because I'm
    thinking of using Grafana.
    The dashboard looks like that :
    Then, a clic on the switch open more infos :

  • What do you mean by


    Isma399 wrote:

    If we put a port up, il will be monitored the next day.

    How would you "put a port up"? Do you mean you "put a port up" when a certain port starts sending/receiving data?


    The script that I'm using monitors statically assigned ports (defined like sru posted below your post) and I don't really see a problem with that because I have all the ports predefined already, so there's no need for daily dynamic updates. I have two check commands, one for ports that should be UP and one for ports that should be DOWN. If they change states, I get alerts (just like you).


    Simply put, I don't see the benefit in using the scripts that you are using, especially considering the fact that it would take a day for Icinga2 to recognize a new port to monitor.


    On the other hand, those Grafana graphs look amazing! Definitely want to implement now. Do you have any guides for configuring/installing that you recommend? Or did you just use the official documentation?


    Thanks!


    P.S.


    How did you get those OID's for your switches? I am running the "snmpwalk" command, but all I see are MIB definitions.