Check_wmi Hostname Computer

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Check_wmi Hostname Computer

Post 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.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check_wmi Hostname Computer

Post 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
	}
Be sure to check out our Knowledgebase for helpful articles and solutions!
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Re: Check_wmi Hostname Computer

Post by rambertnala »

Hi now is good..

Thanks a lot
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Check_wmi Hostname Computer

Post 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!
Former Nagios employee
Locked