vmware-esx-soap-host-xxxxx checks for group of esx hosts? is it possible?

  • Not sure if this belongs here or in the modules section since it involved the VMware PERL SDK?


    Nevertheless, I have this running flawlessly in my nagios environment (It just 1 check definition that runs against a hostgroup (list of esxi hosts)).

    In Icinga2, the 1 piece that is tripping me up is the "required" var (vars.vmware_host), where it wants an individual hostname for the ESXi server vs being able to use a hostgroup like I do in nagios.


    I feel like I may be overthinking this or missing a crucial piece?

    Any help is much appreciated:


    This is an example, which would apply to pretty much every vmware-esx-soap-host-xxxxx check-command

  • UPDATE: For those running into this issue...


    Edited /usr/share/icinga2/include/plugins-contrib.d/vmware.conf

    About line #274


    Change:

    required = true

    tobe

    required = false


    Notice the settings vars.vmware_host = "$address$

    This is "supposed" to be the "default" setting. If vmware_host is not set then the IP Address the host is to be read in to the config. Once I changed to "False"... everything started working as expected.

    I also did a `tail -f /var/log/hostd.log` on my esxi servers to make sure the check did in fact log in using the info in the provided vmware_authfile.


    I already had to edit this file for the location of my check_vmware_esx.pl file when configuring the Perl SDK... And made a backup/copy of the edited version for future updates.


    PS, Make sure if you edit this file and are running HA mode to change it on both HA masters.


  • You will loose these changes with each update.

    I suggest that you provide a pull request at github if you are really satisfied with your solution so that it goes into the sources.

  • I believe this is what you are asking for dnsmichi

    Here's an example:


    NAGIOS Config (uses the hostgroup to use service)

    Code
    1. define service {
    2. #NAGIOSQL_CONFIG_NAME           vmware_ESXi_Runtime
    3. hostgroup_name                 all-esxi-hosts
    4. service_description             ESXi Runtime Status
    5. use                             _service_vmware
    6. check_command                   check_vmware_esx!vmware_authfile_nagios!runtime!status!0!1
    7. contacts                       sms-fireheadman
    8. register                       1
    9. }

    VS


    ICINGA Config

    Code
    1. apply Service "VMware ESX Runtime - Status" {
    2.     import "generic-service"
    3.     check_command = "vmware-esx-soap-host-runtime-status"
    4.     assign where host.vars.os == "vmware"
    5.     ignore where host.name == "vcenter"
    6.     vars.vmware_authfile = "/etc/icinga2/vmware_authfile_nagios"
    7. }
  • No, not the plugin itself, but the command definition.


    Code
    1. check_command check_vmware_esx!vmware_authfile_nagios!runtime!status!0!1


    references a command called "check_vmware_esx". I was wondering how it looks like as Nagios/Icinga1 don't have an ITL where check commands come predefined.

  • ahhh... here ya go:


    NAGIOS: (calling the perl script via cli to perform the check)

    check_vmware_esx -->

    Code
    1. $USER1$/check_vmware_esx.pl -H $HOSTADDRESS$ -f /usr/local/nagios/libexec/$ARG1$ -S $ARG2$ -s $ARG3$ -w $ARG4$ -c $ARG5$

    So its not calling out a routine within the perl script as it is doing in icinga2 (vmware-esx-soap-host-runtime-status)

  • Ok thanks, all clear. The command line still uses the $HOSTADDRESS$ macro, which is bascially the same as the default `vars.vmware_host = "$address$"` inside the ITL CheckCommand definition.


    The only difference here which seems to run into a misunderstanding: The Nagios configuration uses the object tricks to assign a service to a hostgroup.


    Inside Icinga 2 you can do the same via `assign where` expression inside the service apply rule. You don't need to set `vars.vmware_host` explicitly, just ensure that all your hosts have the correct `address` attribute set.


    Code
    1. apply Service "vmware..." {
    2. ...
    3. //vars.host_name is not needed here
    4. assign where "all-esxi-hosts" in host.groups
    5. }



    In case you need to override `$address$`, you can also do that on the service level by specifying the custom attribute `vars.address = ...` (look into the docs on runtime macro evaluation order, as sru suggested).

  • like that.....


    Code
    1. assign where "all-esxi-hosts" in host.group


    I'll use these to play around some more my config.

    Appreciate you guys jumping in on the thread.