Add arguments
Posted: Fri Nov 25, 2016 3:12 pm
I have created a script for nagios but now i want to change the $folder and $file $MaxAgeMinutes into $args[0] - $args[1] - $args[2].
So i can pass arguments in my nsclient.ini
test = cmd /c echo scripts\test.ps1 "$ARG1$" "$ARG2$" "$ARG3$"; exit($lastexitcode) | powershell.exe -command -
So i can pass arguments in my nsclient.ini
test = cmd /c echo scripts\test.ps1 "$ARG1$" "$ARG2$" "$ARG3$"; exit($lastexitcode) | powershell.exe -command -
Code: Select all
$folder = 'c:\temp\'
$file = 'CGO.csv'
$MaxAgeMinutes = 1440
# Process Limit
$Limit = (Get-Date).AddMinutes((-1 * $MaxAgeMinutes))
$path = "$folder\$file"
if (Test-Path $path)
{
if ((Get-Item $Path).LastWriteTime -lt $limit)
{
echo "WARNING status - $file is older than 24 hours."
exit 1 #returns warning status
}
else
{
echo "OK status – file is OK"
exit 0 #Return OK status
}
}
else
{
echo "CRITICAL status – file $file doesn’t exist"
exit 2 #returns critical status
}