Monitoring switch HP ProCurve

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


    I m an absolute beginner in icinga2, monitoring, SNMP, MIB, OID...

    We have a small network with simple needs and until now we didn't have to use pro features.

    Now we are asked to start monitoring the network so:



    I've just installed icinga2 (on centos) and it works

    I did a simple monitoring to a PC "hostalive" and another one with agent and it s OK


    Now i'd like to Monitor a switch

    HP J4887A ProCurve Switch 4104GL


    I started with this

    https://docs.icinga.com/icinga…chapter/monitoring-basics

    and some other pages on the net.

    But until now, it isn't so clear for me.



    I have the MIB file for this switch


    I ran a snmp_check and it works


    root@7bea7dc73572:/usr/lib/nagios/plugins# ./check_snmp -H x.x.10.10 -C monitor -o .1.3.6.1.2.1.1.2.0


    Now i have to define a host, services and maybe a command file for monitoring this switch.


    I'd like to start with a simple thing, and for example monitor the fans status.


    I have created under /etc/icinga2/conf.d a file for this switch, and for now i have this inside it.


    object Host "1-ext_800" {


    address = "x.x.10.10"

    check_command = "hostalive"


    }


    /*


    object Service "fans" {


    host_name = "1-ext_800"

    ??


    }

    */



    How do i have to write this command

    ./check_snmp -H x.x.10.10 -C monitor -o .1.3.6.1.2.1.1.2.0


    in the object Service "fans" {}

    (.1.3.6.1.2.1.1.2.0 is not the fan status,

    i didn't find how to check the fan for now,

    but if this works, I'll just have to find the right OID)


    I'll be pleased if someone can help me or redirect me to a simple "tutorial".


    Thanks

    Sam

  • Hi Nsup,


    Take a look if you have the snmp CheckCommand already defined in:

    /usr/share/icinga2/include/command-plugins.conf (maybe other path...)

    I guess you do...


    Following the CheckCommand definition, just put this info inside Service on the host.cfg file:


    apply Service "FAN" {

    import "generic-service"

    vars.snmp_address = "x.x.10.10"

    vars.snmp_oid = ".1.3.6.1.2.1.1.2.0"

    vars.snmp_community = "monitor"

    check_command = "snmp" vars.snmp_arguments = [ vars.snmp_address, vars.snmp_community, vars.snmp_oid ]

    import "service-generic-instructions"

    assign where host.name == "1-ext_800"


    Let me know if it works.



  • First off you should check the documentation for the CheckCommand you're using. All paramters are documented over there. After that you'll need to understand how to pass command arguments by just defining custom attributes on the service.


    https://docs.icinga.com/icinga…plugin-check-command-snmp


    • x.x.10.10 is an IP address, that should be set on the Host object already, no need to specify that for the service again (unless it differs)
    • monitor is the snmp community
    • .1.3.... is the OID


    Tip: It really helps to call the plugin with --help and look at the long options, not the short ones.

  • Hello,

    branvan2k

    I have a SNMP check command under

    /usr/lib/nagios/plugins

    Under /etc/icinga2/conf.d

    I create a file with this inside

    and when I restart the icinga2 service I get this error:

    information/cli: Icinga application loader (version: r2.6.0-1)



    information/cli: Loading configuration file(s).



    critical/config: Error: syntax error, unexpected T_IDENTIFIER, expecting '}'



    Location: in /etc/icinga2/conf.d/hosts.conf: 64:25-64:28



    /etc/icinga2/conf.d/hosts.conf(62):



    /etc/icinga2/conf.d/hosts.conf(63): # check_command = "snmp" vars.snmp_arguments = [ vars.snmp_address, vars.snmp_community, vars.snmp_oid ]



    /etc/icinga2/conf.d/hosts.conf(64): check_command = "snmp" vars.snmp_arguments = [ vars.snmp_community, vars.snmp_oid ]



                                                                                                                    ^^^^



    /etc/icinga2/conf.d/hosts.conf(65):



    /etc/icinga2/conf.d/hosts.conf(66): import "service-generic-instructions"

    I suppose that the “snmp_arguments” is the problem because this attribute doesn’t appear in this list

    https://docs.icinga.com/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/plugin-check-commands#plugin-check-command-snmp

    dnsmichi

    Based on this

    https://docs.icinga.com/icinga…ommand-passing-parameters

    I’m not sure, but I suppose that I don’t have to write my own command in

    /etc/icinga2/conf.d/commands.conf

    like the example we can see in the page .../monitoring-basics#command-passing-parameters

    object CheckCommand "my-mysql" {…}

    I have an object CheckCommand "snmp" {…} in

    /usr/share/icinga2/include/command-plugins.conf

    Also, I don’t think that it’s important, but my “check_snmp” have a “older” version that the one I can see there

    https://www.monitoring-plugins.org/doc/man/check_http.html

    this is mine:

    check_snmp -h



    check_snmp v1.5 (nagios-plugins 1.5)



    Copyright (c) 1999-2007 Nagios Plugin Development Team



    So, based on this

    https://docs.icinga.com/icinga…ommand-passing-parameters

    I wrote this:

    (file under /etc/icinga2/conf.d/)

    Now I get this error:



     



    information/cli: Icinga application loader (version: r2.6.0-1)



    information/cli: Loading configuration file(s).



    information/ConfigItem: Committing config item(s).



    information/ApiListener: My API identity: 7bea7dc73572



    critical/config: Error: Validation failed for object '3-ext_800!fan' of type 'Service'; Attribute 'check_command': Object 'check_snmp' of type 'CheckCommand' does not exist.



    Location: in /etc/icinga2/conf.d/switch-ext-03.conf: 12:2-12:29



    /etc/icinga2/conf.d/switch-ext-03.conf(10): import "generic-service"



    /etc/icinga2/conf.d/switch-ext-03.conf(11):



    /etc/icinga2/conf.d/switch-ext-03.conf(12): check_command = "check_snmp"



    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^



    /etc/icinga2/conf.d/switch-ext-03.conf(13): vars.snmp_oid = ".1.3.6.1.2.1.1.2.0"



    /etc/icinga2/conf.d/switch-ext-03.conf(14): vars.snmp_community = "monitor"



     



    critical/config: 1 error

    Apparently I have to point to the object CheckCommand "snmp" {…} from the apply Service "fan" {…}

    Thanks.

  • Please use the code tags (</> icon) to properly format configs and log outputs.


    Look at the error - modify the "check_command" attribute to reference a real CheckCommand object name.

  • Nsup,


    In your first error, icinga2 tells you where's the problem:

    Location: in /etc/icinga2/conf.d/hosts.conf: 64:25-64:28

    So line 64 of /etc/icinga2/conf.d/hosts.conf

    You have put 2 lines in 1

    check_command = "snmp" vars.snmp_arguments = [ vars.snmp_community, vars.snmp_oid ]

    It should be:

    check_command = "snmp"

    vars.snmp_arguments = [ vars.snmp_community, vars.snmp_oid ]


    BUT i think you still need to pass the address in snmp_arguments:

    snmp_address - Optional. The host's address. Defaults to "$address$" if the host's address attribute is set, "$address6$" otherwise.

    vars.snmp_arguments = [ address, vars.snmp_community, vars.snmp_oid ]

    Is this right @dnsmichi?




    In the second error:

    critical/config: Error: Validation failed for object '3-ext_800!fan' of type 'Service'; Attribute 'check_command': Object 'check_snmp' of type 'CheckCommand' does not exist.


    It tells you there is no checkCommand with the name "check_snmp"


    What's the name of the checkCommand for snmp in /usr/share/icinga2/include/command-plugins.conf

    You say:

    I have an object CheckCommand "snmp" {…} in

    So the real name of the CheckCommand is snmp, right?


    I think this should work:



  • vars.snmp_arguments = [ address, vars.snmp_community, vars.snmp_oid ]

    Is this right @dnsmichi?

    That makes no sense to me. You should not use snmp_arguments as this is not defined anywhere. Rather specify the listed custom attributes for community, oid and so on.

  • Really?


    I thouth that if you have this CheckCommand definition:

    You can set up the Service passing snmp_arguments...

  • I don't see any reference to snmp_arguments in that CheckCommand. Are you sure that the command line you've built with just that illustrates your passed arguments?

  • Hello


    It works :thumbsup:

    Thanks a lot.


    See you soon for the next problem.