1.

Solve : Batch - UPS Load Test Logger?

Answer»

I have a stack of UPSS that the company wants to test the health of and instead of having to baby SIT them and pay attention to when they drop out to calculate amp hour draw to figure out the battery health under a 100 watt light bulb draw, I came up with this batch file to record the pings to a low draw network device that is also powered through the UPS.

This batch is started when the power strip is shut off and the UPS is using its battery to maintain the 100 watt dummy load light bulb.

The batch currently just keeps logging until it is stopped manually, however I was wondering if there was a way for this batch to be given the smarts of testing the logged echo from the ping to test for "Request timed out." or even"Request" which is not part of a successful ping to WRITE then the date/time and exit the batch.

Currently I have a batch that works, but its dumb, and makes for larger than needed log Text file to search for the start and stop time.

Also if anyone has any better ways to go about this test with a batch or a vb script I am open to alternative solutions.

This is also a tool that would be used on and on from now on to continue to test UPSs that come and go from our IT Service Department. So that is why I am looking for a better way of going about this testing and logging it.

* Was thinking that since you cant read the echo directly from PING, that maybe the batch can be a 2 part functionality where the first part writes 10 pings, and the second part reads in the UPSTest.txt file and searches for "Request timed out." and IF not found then loop back to step 1 to record another 10 pings, then test again in step 2. If step 2 tests and finds "Request timed out." then write the date and time with %date% and %time% to the UPSTest.txt file and exit the batch.


Code: [Select]@echo. UPS Test Started on %date% at %time%>>UPSTest.txt
:loop
@echo...........>>UPSTest.txt
@echo...........>>UPSTest.txt
@echo. 10 Ping Interval Marker %date% at %time%>>UPSTest.txt
@echo...........>>UPSTest.txt
@echo...........>>UPSTest.txt
ping 192.168.2.231 -n 10 >>UPSTest.txt
goto loop1. What are all those @echo............ lines for? I don't see what purpose they serve, apart from bulking up the log file.

2. You can use the && operator to see if the ping WORKED or not

Code: [Select]ping 192.168.2.231 -n 10 >>UPSTest.txt && goto loop
echo Ping failed on %date% at %time% >>UPSTest.txt
3. Why don't you just do @echo off at the beginning then youn wouldn't have to start every echo line with a @?
Thanks Dias!

My batch tends to be sloppy at times from debugging without clean up or forgetting to use easier methods...Thanks for pointing out this better clean coded solution



Discussion

No Comment Found