Does this look right... I am trying to take this script and turn it into a service using perlsvc....
== begin === use Win32::ChangeNotify; use Mail::Sendmail; #use Net::SNPP; (future use) use strict; package PerlSvc; our %Config; sub Startup { # here's where your startup code will go while (ContinueRun(60)) { # do some work here } } sub Pause { # your service is about to be suspended } sub Continue { # your service will resume execution now } sub Interactive { # this callback is invoked when your service is not running as # a service and has been called without any of the --help, # --install or --remove options. } sub Install { $Config{ServiceName} = 'DRW'; $Config{DisplayName} = 'DRWatson Monitor'; # add your additional install messages or functions here print "\nAdditional install notes\n"; } sub Remove { $Config{ServiceName} = 'TestSvc'; # add your additional remove messages or functions here print "\nAdditional remove notes\n"; } sub Help { # add your additional help messages or functions here print "\nAdditional help notes\n"; } package main; my (@stat, $beginsize, $notify, $endsize, %mail, $to, $from, $directory, $file, $machine, $snpp, $pagerhost, $pager, @drwatson, $drw, $pid, $app, ); my $VERSION = 0.51; $machine = 'machine'; $to = '[EMAIL PROTECTED]'; $from = "[EMAIL PROTECTED]"; $directory = 'c:/winnt'; $file = 'c:/winnt/drwtsn32.log'; #$pagerhost = 'pagerhost.server.com'; (future use) #$pager = 'pagerID'; (future use) print "Monitoring Dr Watson on $machine ...\n"; while (1) { @stat = stat("$file"); $beginsize=$stat[7]; $notify = Win32::ChangeNotify->new($directory,0,'SIZE') or die "$^E"; $notify->wait or warn "Something failed: $!\n"; # There has been a change. @stat = stat($file); $endsize=$stat[7]; # Did the Dr Watson log change? if ($beginsize != $endsize) { print "Crash ...\n"; open (DRW, $file); undef $/; $drw=<DRW>; close DRW; $drw =~ m/.*exception occurred:.*?pid=(\d+).*?\s+\1\s(.*?)\n/s; $pid = $1; $app = $2; print "The crash was in $app (PID $pid)\n"; # Send notification %mail = (To => $to, From => $from, Subject => "Crash on $machine", Message => "$machine crash: $app." ); sendmail(%mail) or die $Mail::Sendmail::error; print "Notification sent\n", $Mail::Sendmail::log; # Or, send a page #$snpp = Net::SNPP->new($pagerhost); # #$snpp->send (Pager => $pager, # # Message => "$machine crash: $app" # # ); # print "Page sent to $pager.\n"; # } # End if } # Wend =head1 NAME drw_monitor - Report when an NT box crashes by watching the size of the Dr Watson log. =head1 DESCRIPTION It is rather difficult to tell, sometimes, when an application has crashed on an NT machine without actually looking at the screen. You can try to ping, or even establish socket connections, but these can produce misleading results. If you have Dr Watson installed, you can use this script to monitor the size of the Dr Watson log, and send you email when there is a crash, or send an alpha page. =head1 README Monitors your Dr. Watson log, for the purpose of detecting crashes. It will send out email and/or alpha page notification of these crashed. Can be run as an NT service. =head1 PREREQUISITES This script C<use>s C<Win32::ChangeNotify>, C<Mail::Sendmail>, and C<Net::SNPP>. And, obviously, since it monitors the Dr Watson log, it would help to have Dr Watson (or similar) installed. =head1 Comments If you don't have a pager server handy, and just want to use the email portions of this, just comment out the lines that refer to the pager stuff. I've indicated these lines by putting a # at the end of them. =pod OSNAMES MSWin32 =pod SCRIPT CATEGORIES Win32 =cut ==== end script === === Mike Singleton Network Analyst (253) 272-1916 x1259 (253) 405-1968 (cellular) [EMAIL PROTECTED] DaVita Inc. _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs