I think you don't include \\ inyour hostname.
Try with only "Web1","data1",....
 
let me know if it's ok.
 
Yves

-----Original Message-----
From: pineau [mailto:[EMAIL PROTECTED]
Sent: Monday, August 18, 2003 2:33 PM
To: [EMAIL PROTECTED]
Subject: win32::eventlog



Hi all. 

Here is a script that should get eventlog records on remote machine, but the
getNumber() and getOldest() functions don't work so that I can't read remote
eventlog records... I'm connected as network administrator with all rights
that can exist in the world.

Does anyone have any idea of what happens ?? Thanks a lot...

 

$time = time;

#$host = "Seiya";

@hosts = ("\\\\web1", "\\\\data1", "\\\\smtp", "\\\\dns2", "\\\\dns1",
"\\\\rentabiliweb", "\\\\data0", "\\\\debussac", "\\\\web2", "\\\\ged");

open(FILE, ">c:/resultats_msg_err.txt");

$date = ctime(stat("c:/resultats_msg_err.txt")->mtime);

print FILE "r�sultats du contr�le des messages d'erreur du $date\n\n\n";

 

foreach $host (@hosts) {

 

print FILE "Message d'erreur de $host\n\n\n";

 

foreach $eventLog ("Application", "System", "Security") {

 

            $handle=Win32::EventLog->new($eventLog, $host)

        or die "Can't open $eventLog EventLog on $host\n"; 

            if ($eventLog eq "Application") {

                        print FILE "Message d'erreur des applications:\n";

            } elsif ($eventLog eq "System") {

                        print FILE "Message d'erreur du syst�me:\n";

            } else {print FILE "Message d'erreur de s�curit�:\n";}

            

            $handle->GetNumber($recs)

        or die "Can't get number of EventLog records on $host\n";

            $handle->GetOldest($base)

        or die "Can't get number of oldest EventLog record on $host\n"; 

            $x = $recs + $base;

            $count = 0;

                        

            while ($x - 1 > $base) {

 
$handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,

                                  $x - 1,

                                  $hashRef)

                                   or die "Can't read EventLog entry #$x\n";

        

                        if (($hashRef->{TimeGenerated} >= $time - 86400) &&
($hashRef->{EventType} eq EVENTLOG_ERROR_TYPE || $hashRef->{EventType} eq
EVENTLOG_WARNING_TYPE)) {

                Win32::EventLog::GetMessageText($hashRef);

                print FILE "Entry $x: $hashRef->{Message}\n";

                                               $count++;

                        }

        $x++;

             }

 

}

 

}

 

close FILE;

 

----------------------------------

Jean-Christophe PINEAU

Ing�nieur r�seaux

[EMAIL PROTECTED] 

 


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to