• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 596
  • Last Modified:

windows shutdown/startup logging program

What good tool have you used to accurately log windows abrupt shutdowns/downtime?  I find the event viewer isn't exactly what I'm looking for.  Basically I need proof that the machine was up or down at a period of time.  This is for an HMI unit running WinXP that is constantly logging data and when it isn't logging data I need to proof that they didn't have the machine turned on.  Thanks
0
cqr213
Asked:
cqr213
  • 7
  • 7
1 Solution
 
pony10usCommented:
Have you looked at using Nagios by Sourceforge?  

http://nagios.sourceforge.net/docs/3_0/hostchecks.html
0
 
cqr213Author Commented:
This is a WinXP machine and there is no install for this in Windows....also, I forgot to mention FREE is good :)
0
 
pony10usCommented:
Take a look at NagWin and see if it will work.  http://www.nagios.org/news/77-news-announcements/273-introducing-nagwin-nagios-for-windows  We have a linux box so I can't offer any comments on it.

Nagios is open source.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
cqr213Author Commented:
Looks ok but I can't find the download for it, 'page doesn't exist.  Any others?
0
 
pony10usCommented:
having not used it I had to do some research.  You can find the free edition (limited) as well as the paid here:

https://www.itefix.no/i2/nagwin
0
 
cqr213Author Commented:
i'm not a Linux person and this is pretty difficult for me to setup.  I'd like to find a Windows program for simple monitoring.  thanks tho but this is too hard to configure for the simple task I need it to do.  simply tell me when a system is powered on and running or not..
0
 
pony10usCommented:
You could try something like this:

ping -n 1 <ip_address> || echo 'server is down' %date% %time% > test.txt 

Open in new window


Schedule it to run as often as you want to check. This will log everytime the server is unreachable to test.txt but if it reaches it it won't log anything.
0
 
cqr213Author Commented:
cool, only this is a standalone machine so this would need to run on the machine in question and I can only check this log when I physically have the machine...how would this script be written if it were to log when pinging localhost is good then I could check the gaps in time afterwards..?  does that make sense?
0
 
pony10usCommented:
Okay, let's see if I understand.

XP machine - not connected to a network. You want it to log when it is powered on/off by checking itself.

How often do/will you be checking this log? The log could get rather large if not monitored.

@setlocal enableextensions enabledelayedexpansion
@echo off

REM *************************************************************************
REM * Program will monitor loopback address (127.0.0.1) to see if everything is working  *
REM * as intended. A gap in the log will indicate that the system was down. It will NOT        *
REM * indicate a loss of network connectivity.                                                                                    *
REM *************************************************************************

set ipaddr=127.0.0.1
set oldstate=neither
:loop
set state=up
ping -n 1 !ipaddr! >nul: 2>nul:
if !errorlevel!==0 set state=up
rem if not !state!==!oldstate! (
    echo.This machine was !state! at %time% on %date% >> c:\logs\uplog.txt
rem     set oldstate=!state!
)
ping -n 10 127.0.0.1 >nul: 2>nul:
goto :loop
endlocal

Open in new window


You need to have a folder c:\logs and the program will create the file uplog.txt in that folder if it doesn't exist. The log will grow quickly so it needs to be deleted periodically. Something could probably be added to the program to delete it every so often if desired.

The program will always be checking but only put an entry in the log approximately every 10 seconds based on line 20. If you want to increase the span between entries simply increase the "10" on this line.

You should be able to install this as a service so that it is always running by follwoing Microsoft's KB:  http://support.microsoft.com/kb/137890

Again, please be sure to monitor the size of the uplog.txt file and plan accordingly for it's size.
0
 
cqr213Author Commented:
ok let me dig in to this, and yes I could get away with pinging once every 5 mins. or so because I would never need to check this unless something happens.  while I begin trying this on a test machine what scripting could I use to maybe delete after 30, 60, 90 days or even by file size?  thanks for all this
0
 
cqr213Author Commented:
yes this is exactly what i'm looking for!  i'll test for a few days maybe monitoring at a 5 min. interval to see how big the log gets but a simple .txt shouldn't get too big right?  something to maybe delete after a set amount of days may be a good idea though.
0
 
pony10usCommented:
Try adding this above the set ipaddress=127.0.0.1 line and put in the number of days you want.

forfiles -p "C:\logs" -s -m *.txt -d <number of days> -c "cmd /c del @path"

You can leave the -s out as that just tells it to search recursively if you don't need it.
0
 
cqr213Author Commented:
ok, I get 'forfiles' is not a recognized command
0
 
pony10usCommented:
Some XP don't have forfiles installed. If you don't have forfiles installed on your machine, copy it from any Windows 2000 or 2003 Server to your Windows XP machine at %WinDir%\system32\ This is possible since the EXE is fully compatible. If you use the 2003 version we may need to alter the command as the switches were modified.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now