Problem with own Check and vars

Hi,
I am noit really a Newby but I have a strange problem.
I will check with an external Perl Script the Snapshots on our Vcenter Server.
But the Variable I put in will not be used. Any idea whats wrong here?

log entry

warning/PluginCheckTask: Check command for object ‘servername!Snapshot Count’ (PID: 12428, arguments: ‘/usr/lib/nagios/plugins/check_vmware_snapshots.pl’ ‘–blacklist’ ‘host.vars.snapshot_blacklist’ ‘–critical’ ‘host.vars.snapshot_critical’ ‘–mode’ ‘host.vars.snapshot_mode’ ‘–server’ ‘host.vars.esxi_host’ ‘–warning’ ‘host.vars.snapshot_warning’) terminated with exit code 255, output: Value “host.vars.snapshot_critical” invalid for option critical (number expected)

commands.com

object CheckCommand "check_vmware_snapshot" {
import "plugin-check-command"
command = [ PluginDir + "/check_vmware_snapshots.pl" ]
arguments = {
"--server" = "$esxi_host$",
"--username" = "$esxi_user$",
"--password" = "$esxi_pw$",
"--mode" = "$mode$",
"--warning" = "$warning$",
"--critical" = "$critical$",
"--blacklist" = "$blacklist$"
 }
}

services.conf

apply Service "Snapshot Count" {
import "generic-service"

check_command = "check_vmware_snapshot"

vars.esxi_host = "host.vars.esxi_host"
vars.esxi_user = "$vcenteruser$"
vars.esxi_pw   = "$vcenterpasswd$"
vars.mode      = "host.vars.snapshot_mode"
vars.warning   = "host.vars.snapshot_warning"
vars.critical  = "host.vars.snapshot_critical"
vars.blacklist = "host.vars.snapshot_blacklist"

assign where host.vars.os == "vcenter"
}

Host.conf

object Host "servername" {

import "generic-host"

display_name       = "servername"
address            = "xxx.xxx.xxx.xxx"
vars.os            = "vcenter"

 vars.esxi_host            = "servername"
 vars.snapshot_mode        = "count"
 vars.snapshot_warning     = 2
 vars.snapshot_critical    = 4
 vars.snapshot_blacklist   = "vtest-.*"

....

 }
}

Hi,

you are declaring your vars as string (vars.mode = "host.vars.snapshot_mode").
Use vars.mode = host.vars.snapshot_mode and don’t forget to update the other variables.

Greetz

1 Like

:bowing_man: ups, looks like it was to late yesterday.
Thanks for the hint :v:
Now its OK