Page 1 of 1

NagiosXi - Alert display

Posted: Thu Sep 10, 2020 9:53 am
by Bala.Mutyam
Hi,

We are monitoring our windows server all drives using below script but on NagiosXi it's only displaying part of the output. Is it possible to display all the output of the script?

script:

Code: Select all

# To check All Disks Usage

param([String] $Server = "$env:ComputerName")

$alertcrit = 0
$alertwarn = 0
$warn = 20
$crit =  10

$error.clear()
$disks = Get-WmiObject -ComputerName $Server -Class Win32_LogicalDisk -Filter "DriveType = 3";
foreach($disk in $disks)
{
	$deviceID = $disk.DeviceID;
	[float]$size = $disk.Size;
	[float]$freespace = $disk.FreeSpace;

	$percentFree = [Math]::Round(($freespace / $size) * 100, 2);
	$sizeGB = [Math]::Round($size / 1073741824, 2);
	$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);
	if($percentFree -lt $crit )
	{
		Write-Host -NoNewLine "Critical $deviceID = $percentFree % Free | $deviceID=$percentFree%;;;0;"; –NoNewline
		$alertcrit = 2
	}
	elseif($percentFree -lt $warn)
	{
    Write-Host -NoNewLine "Warning $deviceID = $percentFree % Free | $deviceID=$percentFree%;;;0;"; –NoNewline
    $alertcrit = 1
	}
	Else
	{
		Write-Host -NoNewLine "OK $deviceID=$percentFree% Free| $deviceID=$percentFree% ;;;0;"; –NoNewline
	}
}
if ($alertcrit -gt 0) 
{
exit 2
}
elseif ($alertwarn -gt 0)
{
exit 1
}
elseif ($error.Count -gt 0)
{
Write-Output $_;
  $_="";
  exit 3;
}
else 
{
exit 0
}
Script output on the agent:

Code: Select all

PS C:\Program Files (x86)\Nagios\NCPA\plugins> C:\Program Files (x86)\Nagios\NCPA\plugins\check_disks.ps1
OK C:=23.34% Free| C:=23.34%;;;0;OK E:=88.53% Free| E:=88.53%;;;0;Critical G: = 2.47 % Free | G:=2.47%;;;0;OK K:=99.32% Free| K:=99.32%;;;0;
Attached NagiosXi display below.

Re: NagiosXi - Alert display

Posted: Thu Sep 10, 2020 10:25 am
by scottwilkerson
Everything after the | is the performance data, if you click into the service this is displayed on the advanced tab

Re: NagiosXi - Alert display

Posted: Thu Sep 10, 2020 10:47 am
by Bala.Mutyam
@ scottwilkerson: Hi - thanks for the update. if that's NagiosXi behaviour, happy to close this thread.

Re: NagiosXi - Alert display

Posted: Thu Sep 10, 2020 10:57 am
by scottwilkerson
Bala.Mutyam wrote:@ scottwilkerson: Hi - thanks for the update. if that's NagiosXi behaviour, happy to close this thread.
Great!

Closing thread