Solved

windows shutdown/startup logging program

Posted on 2014-02-03
14
550 Views
Last Modified: 2014-02-03
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
Comment
Question by:cqr213
  • 7
  • 7
14 Comments
 
LVL 26

Expert Comment

by:pony10us
ID: 39829902
Have you looked at using Nagios by Sourceforge?  

http://nagios.sourceforge.net/docs/3_0/hostchecks.html
0
 

Author Comment

by:cqr213
ID: 39829936
This is a WinXP machine and there is no install for this in Windows....also, I forgot to mention FREE is good :)
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39830060
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:cqr213
ID: 39830477
Looks ok but I can't find the download for it, 'page doesn't exist.  Any others?
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39830578
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
 

Author Comment

by:cqr213
ID: 39830702
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
 
LVL 26

Expert Comment

by:pony10us
ID: 39830783
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
 

Author Comment

by:cqr213
ID: 39830845
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
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
ID: 39830964
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
 

Author Comment

by:cqr213
ID: 39830979
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
 

Author Comment

by:cqr213
ID: 39831008
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
 
LVL 26

Expert Comment

by:pony10us
ID: 39831016
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
 

Author Comment

by:cqr213
ID: 39831056
ok, I get 'forfiles' is not a recognized command
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39831067
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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question