[mrtg] Problem with external script

Paul E. Bauer Jr. paul.bauer at rimrockgroup.com
Thu Mar 25 23:54:39 MET 2004


I recently read an article demonstrating how to monitor things such as
iis log files using mrtg. This seemed like a worthwhile endevor. Using
the example in the article I proceeded to set up mrtg to monitor some
iis logs. This is done using a logparser tool from Microsoft. The call
from the mrtg config file is made to a cmd file. This cmd file appears
to return the correct data when run from a command prompt. When I run
the cmd file I get four lines of data similar to the following.
5
5
UNKNOWN
w3svc1

When mrtg calls the cmd file I do not get the correct data in the mrtg
log file. If I create a cmd file and just echo the following 4 lines

5
5
UNKNOWN
W3svc1

this data is reflected correctly in the mrtg log file. The only
difference between the two cmd files is that the one cmd file that does
not work has some condition testing statements. See the following text.

@for /f "tokens=1,2,3,4* delims=/ " %%i in ('date /t') do @set
year=%%l&& @set month=%%j&& @set day=%%k

@set
logfile=l:\windows\system32\LogFiles\%1\ex%YEAR:~2,2%%month%%day%.log
@If Exist %logfile% (
	@logparser "SELECT COUNT(*) FROM %logfile% WHERE (sc-status>=400
AND sc-status<500) AND (TO_TIMESTAMP(date, time) >
SUB(SYSTEM_TIMESTAMP(), TO_TIMESTAMP('5','m')))" -q
	@logparser "SELECT COUNT(*) FROM %logfile% WHERE (sc-status>=500
AND sc-status<600) AND (TO_TIMESTAMP(date, time) >
SUB(SYSTEM_TIMESTAMP(), TO_TIMESTAMP('5','m')))" -q

) ELSE (
	@Echo %logfile%
	@Echo 0
)
@Echo UNKNOWN
@Echo %1

This is the exact code in my cmd file. All I have to pass in is the
instance of the iis web server such as w3svc1.  If I use the following
code in my cmd file the output is the same, but this output makes it
into the mrtg log file.

@echo 5
@echo 5
@echo unknown
@echo w3svc1

Has anyone experienced this behavior before? Is there a way to get
around it? 

Cheers.

Paul Bauer

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list