Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

windows shutdown/startup logging program

Posted on 2014-02-03
14
Medium Priority
?
584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
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…
Suggested Courses

636 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