Monitor Cluster shared volumes

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
partnernet
Posts: 13
Joined: Fri Apr 22, 2016 2:13 am

Monitor Cluster shared volumes

Post by partnernet »

Hello,

I have an already set-up Nagios Core that uses this script in order to monitor some Hyper-v Cluster shared volumes
https://exchange.nagios.org/directory/P ... 1442825460

I noticed though that the code is a little bit changed and the warning and critical values are static inside the code and not passing through as an argument:

Code: Select all

Param(
    [parameter(Mandatory=$true)]
    [alias("n")]
    $csvname)  
    #[parameter(Mandatory=$true)]
    #[alias("w")]
    #$warnlevel,
    #[parameter(Mandatory=$true)]
    #[alias("c")]
    #$critlevel)

#$csvname="Cluster Storage 4"
$warnlevel=80
$critlevel=90
So I tried to change that and uncomented the above lines in order to pass them through from my nagios service definition.

Here is my service definition:

Code: Select all

define service
{use generic-service,graphed-service
service_description Cluster: Volume 3 free disk space
check_command check_hyperv_csv_freespaceTest!Cluster Storage 4!90!95}
Command Definition:

Code: Select all

define command { 
command_name check_hyperv_csv_freespaceTest 
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c check_hyperv_csv_freespace -a "$ARG1$" "$ARG2$" "$ARG3$"
} 
and nscient.ini

Code: Select all

check_hyperv_csv_freespace=cmd /c echo scripts\mine.ps1 -n "$ARG1$" -w "$ARG2$" -c "$ARG3$"; exit($lastexitcode) | powershell.exe -command -
and Nagios returns this:

Code: Select all

Status Information:	scriptsmine.ps1 -n ARG1$ -w "90 -c "95": exit($lastexitcode)
Performance Data:	'powershell.exe'=0 '-command'=0 '-'=0
I have tried many different ways to pass my arguments (with and without quotes, with and without spaces...)and all result in some kind of Argument passing error.
Any help would be greatly apreciated.
Thanks
Anna
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor Cluster shared volumes

Post by lmiltchev »

Does it help if you remove the double quotes around your args?

Code: Select all

define command {
command_name check_hyperv_csv_freespaceTest
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c check_hyperv_csv_freespace -a $ARG1$ $ARG2$ $ARG3$
} 
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Monitor Cluster shared volumes

Post by Box293 »

partnernet wrote:I have tried many different ways to pass my arguments (with and without quotes, with and without spaces...)and all result in some kind of Argument passing error.
Can you show us the command you execute at the CLI along with the output produced.

I want to see it working first, it'll help make sure we create the correct configs.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
partnernet
Posts: 13
Joined: Fri Apr 22, 2016 2:13 am

Re: Monitor Cluster shared volumes

Post by partnernet »

So I figured out one of the problems.
My Volume name had spaces in it so this could not pass as an argument, so I modified my script like this:

Code: Select all

$csvname = $csvname.replace('+' , ' ')
and I am running the below from the CLI:

Code: Select all

.\mine.ps1 -n Cluster+Storage+4 -w 90 -c 95
and correctly I get:

Code: Select all

OK - Cluster Storage 4 total: $1092GB, used: $886GB (81%), free: 206GB (18%) | 'Cluster Storage 4 used_space'=886Gb;982;1037;0;1092
When I try to run it from nagios I get the following:

Code: Select all

Status Information:	scriptsmine.ps1 -n ARG1$ -w "$ARG2$ -c "$ARG3$": exit($lastexitcode)
Performance Data:	'powershell.exe'=0 '-command'=0 '-'=0
I can't figure out this weird output, its like some quotes are not being recognized. I tried typing the lines about arguments all over again in case it was some character issue, but no luck.
I have restarted both nagios and nsclient service.

Removing the quotes doesn't have a difference(which I guess is weird).

Thanks.
Anna
partnernet
Posts: 13
Joined: Fri Apr 22, 2016 2:13 am

Re: Monitor Cluster shared volumes

Post by partnernet »

Hooray!!

I figured it out at last...

So this is how it worked for me:

Command definition:

Code: Select all

define command { 
command_name check_hyperv_csv_freespace 
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c check_hyperv_csv_freespace -a $ARG1$
} 
I am not sure why the double quotes are wrong, all my other command definition are using quotes :?

Service definition:

Code: Select all

define service{
use generic-service,graphed-service
hostgroup_name  host2012
service_description Cluster: Volume 3 free disk space
check_command check_hyperv_csv_freespace!Cluster+Storage+4 90 95
}
Pass the Volume name with + instead of spaces and replace it back again in the script

nsclient.ini

Code: Select all

check_hyperv_csv_freespace=cmd /c echo scripts\mine.ps1 -n $ARG1$ -w $ARG2$ -c $ARG3$; exit($lastexitcode) | powershell.exe -command -
without quotes again...

Thanks guys for your assistance!
Anna
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitor Cluster shared volumes

Post by mcapra »

Glad you were able to find a solution! Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
Locked