NagiosXi - Alert display

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Bala.Mutyam
Posts: 97
Joined: Wed Apr 29, 2020 12:18 pm

NagiosXi - Alert display

Post 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.
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: NagiosXi - Alert display

Post by scottwilkerson »

Everything after the | is the performance data, if you click into the service this is displayed on the advanced tab
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Bala.Mutyam
Posts: 97
Joined: Wed Apr 29, 2020 12:18 pm

Re: NagiosXi - Alert display

Post by Bala.Mutyam »

@ scottwilkerson: Hi - thanks for the update. if that's NagiosXi behaviour, happy to close this thread.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NagiosXi - Alert display

Post by scottwilkerson »

Bala.Mutyam wrote:@ scottwilkerson: Hi - thanks for the update. if that's NagiosXi behaviour, happy to close this thread.
Great!

Closing thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked