Troubleshooting your custom powershell script is out of scope for support as we do not have access to the server's / infrastructure you are trying to test.
The best person to contact would be the author of the plugin.
NSClient++ calling a Powershell script
Re: NSClient++ calling a Powershell script
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: NSClient++ calling a Powershell script
I am working with the script author but we can't figure out how or what we needs to happen so Nagios sees the output code as Critical, Warning, OK, Unknown. I thought it was by the exit code but I get an exit code 2 shown but Nagios is not interpreting that as critical. That is where I am stumped right now.
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: NSClient++ calling a Powershell script
@tgriep's comment about support not withstanding, can you show us a screenshot of what you see in XI? Do you have other powershell scrips that are working correctly? You might try formatting your script like those.
I doubt it matters, but I see your exit is wrapped in a function. Why not exit directly like the script below?
I doubt it matters, but I see your exit is wrapped in a function. Why not exit directly like the script below?
Code: Select all
# Test SMTP QUEUE ON EXCHANGE 2010
#
# This script will execute the "Get-queue" command and look for how much e-mail are in the queue
#
# Example:
# Identity DeliveryType Status MessageCount NextHopDomain
# -------- ------------ ------ ------------ -------------
# SERVER\173821 MapiDelivery Ready 0 db01
# SERVER\173832 MapiDelivery Ready 0 db04
# SERVER\173833 SmartHost... Ready 0 [192.17.70.131],[192.17.70.132]
# SERVER\173834 MapiDelivery Ready 0 db02
# SERVER\Submission Undefined Ready 0 Submission
# SERVER\Unreachable Unreachable Ready 5 Unreachable Domain
# SERVER\Shadow\173808 ShadowRed... Ready 1 EXTERNAL.domain.dom
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# Revision History
# 2014-08-07 Roberto C. [[email protected]] 1.0 code initial created
# Thanks to Bastian W. ([email protected]) for the plugin schema
#
#
# To execute from within NSClient++
# [/settings/external scripts]
# allow arguments = true
#
# [/settings/external scripts/wrapped scripts]
# alias_check_queue = NagiosMonitoring_Exchange-queue.ps1 $ARG1$ $ARG2$ $ARG3$
# On the check_nrpe command include the -t 60, since it takes some time to load
# the Exchange cmdlet's.
# Check command on Nagios machine
# /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 60 -c alias_check_queue -a $ARG1$ $ARG2$ $ARG3$
#Parameters that you have to set for the check
#$server is the fqdn of the CAS to check ($ARG1$)
#$critical is the threshold you think is critical ($ARG2$)
#$warning is the threshold you think is warning ($ARG3$)
param($server="",$critical="",$warning="")
#Check if the param are set
if($server -eq "" -or $critical -eq "" -or $warning -eq "")
{
Write-Output "WARNING"
Write-Output "You have to set the CAS-SERVER, the CRITICAL threshold, and WARNING threshold"
exit
}
#Check and load Exchange Management PowerShell
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
$NagiosStatus = "0"
$NagiosDescription = ""
ForEach ($Type in Get-Queue -Server $server )
{
if ($Type.MessageCount -gt "$critical")
{
# Look for threshold critical
if ($NagiosDescription -ne "")
{
# Format the output for Nagios
$NagiosDescription = $NagiosDescription + ", "
}
$NagiosDescription = $NagiosDescription + $Type.Identity + " = " + $Type.MessageCount
# Set the status to failed.
$NagiosStatus = "2"
}
if ($Type.MessageCount -gt "$warning")
{
# Look for threshold warning
if ($NagiosDescription -ne "")
{
# Format the output for Nagios
$NagiosDescription = $NagiosDescription + ", "
}
$NagiosDescription = $NagiosDescription + $Type.Identity + " = " + $Type.MessageCount
# Set the status to WARNING.
$NagiosStatus = "1"
}
}
# Output, which string should we write to Nagios?
if ($NagiosStatus -eq "2")
{
Write-Host "CRITICAL:"$NagiosDescription
}
elseif ($NagiosStatus -eq "1")
{
Write-Host "WARNING:"$NagiosDescription
}
else
{
Write-Host "OK: all e-mail are gone!"
}
exit $NagiosStatus
Re: NSClient++ calling a Powershell script
I am not getting a Critical or OK from Nagios and want to make sure Nagios send out a notification in the event this check hits critical.
You do not have the required permissions to view the files attached to this post.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: NSClient++ calling a Powershell script
Exited with a return code of 0 is an OK, but your script isn't echoing/printing any outputjkinning wrote:I am not getting a Critical or OK from Nagios and want to make sure Nagios send out a notification in the event this check hits critical.
Re: NSClient++ calling a Powershell script
Ok, this is all working now.
You can lock this thread up.
You can lock this thread up.
-
bolson
Re: NSClient++ calling a Powershell script
Closing topic as resolved.
Thank you for using the Nagios Support Forum.
Thank you for using the Nagios Support Forum.