I've made a Powershell script to get the folder size of a DFS directory. As this directory is on a storage appliance we can't monitor for now, I made a Powershell script to do this, but I have some issues passing arguments to Powershell from Nagios.
This is the script:
Code: Select all
Param(
[Parameter(Mandatory=$true)][string]$dfspad,
[int]$warning=20
#[int]$errorlevel
)
$status = 0
echo "level: $warning"
$folderlist = (Get-ChildItem $dfspad -Recurse | Measure-Object -property length -sum)
$sumMB = "{0:N2}" -f ($colItems.sum / 1MB) + " MB"
if (($folderlist.sum / 1MB) -ge $warning) {
$status = 2
}
if ($status -eq 0) {
echo "$dfspad is op dit moment $sumMB"
}
else {
echo "$dfspad heeft zijn quota overschreden: $sumMB / $warning"
}
exit $status
I made a command check_dfsfoldersize => $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -t 120 -c check_dfs_foldersize -a "$ARG1$" "$ARG2$"
In Nsclient, I configured the external script like this:
check_dfs_foldersize=cmd /c echo scripts\check_dfs_foldersize.ps1 $ARG1$ $ARG2$; exit $LastExitCode | powershell.exe -command -
Allow arguments and allow external commands is on.
When I test, trying to give the DFS path as $ARG1$ and the quota soft limit as $ARG2$, I get no result. Any help is welcome