2

I currently have the following script on a Windows Server:

@echo off set path=%PATH%;C:\UnxUtils\usr\local\wbin cd /D Z:\videos forfiles /M *_1.mkv /D +%date% > C:\mkv.txt >NUL 2>&1 FOR /F "tokens=*" %%B IN ('grep -c _1.mkv c:\mkv.txt') DO SET VIDEOS=%%B if %VIDEOS% GEQ 1 ( echo "BAD VIDEOS!" exit /B 0 ) else ( echo "Videos OK" exit /B 1 ) 

I need Nagios to check if the scripts exit code is 0 or 1 to diplay a critical alert or a ok. Is this possible?

1 Answer 1

1

Actually, that's what Nagios does. You need to return the correct return codes, though. You'll probably have to change your script like this:

if %VIDEOS% GEQ 1 ( echo "BAD VIDEOS!" exit /B 2 ) else ( echo "Videos OK" exit /B 0 ) 
1
  • Thanks. I also had a problem on this " >NUL 2>&1 ". So the mkv.txt file what never filled. Now it is working. Commented Sep 4, 2012 at 13:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.