Page 1 of 1

Check_wmi Hostname Computer

Posted: Thu Mar 22, 2018 4:54 am
by rambertnala
Hi friends.

I need to know if it is possible to check remote hostname via Nrpe

I can get hostname with command

check_nrpe -H $HOSTADDRESS$ -c check_wmi -a "query=Select Name from win32_ComputerSystem"

And I would like to get CriticalStatus if Value i get with command above is different from $HOSTNAME$

I will try to explain

check_nrpe -H $HOSTADDRESS$ -c check_wmi -a "query=Select Name from win32_ComputerSystem" "crit=Name not like $HOSTNAME$"

Both $HOSTADDRESS$ and $HOSTNAME$ are values from Nagios variables.

Regards.

Re: Check_wmi Hostname Computer

Posted: Thu Mar 22, 2018 3:36 pm
by lmiltchev
I don't see why the command below wouldn't work:

Code: Select all

check_nrpe -H $HOSTADDRESS$ -c check_wmi -a "query=Select Name from win32_ComputerSystem" "crit=Name not like $HOSTNAME$"
I tried it and it worked for me just fine. Keep in mind that you can't test it from the command line as the $HOSTNAME$ macro wouldn't resolve.

Here's an example of a service definition:

Code: Select all

define service {
	host_name			My-PC
	service_description		Check Host Name
	use				generic-host
	check_command			check_nrpe!check_wmi!-a "query=Select Name from win32_ComputerSystem" "crit=Name not like '$HOSTNAME$'"
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			24x7
	notification_interval		60
	notification_period		24x7
	notifications_enabled		1
	contacts			nagiosadmin	
	register			1
	}

Re: Check_wmi Hostname Computer

Posted: Fri Mar 23, 2018 8:09 am
by rambertnala
Hi now is good..

Thanks a lot

Re: Check_wmi Hostname Computer

Posted: Fri Mar 23, 2018 9:35 am
by tmcdonald
Glad to hear it! I'll be closing this up now, but feel free to open another thread if you need anything in the future!