Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

more Win32::EventLog oddities

by Reverend Phil (Pilgrim)
on Sep 26, 2002 at 16:45 UTC ( [id://200954]=perlquestion: print w/replies, xml ) Need Help??

Reverend Phil has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks. It seems like there were a couple of old questions regarding Win32::Eventlog here, but I don't see mine. I'm polling a small slew of computers logs, and everything works fine.. well.. there are a few servers that I don't think I'm hitting, and I'm getting no error on it.
In my "process this server" code, I've got the following little snippet.
unless ( $log = Win32::EventLog->new("System",$computer) ) { log_data("Unable to open system log for $computer",4); next; }
log_data is merely a logging routine I have in there.. but the important thing is that (1) I never log that error message, and (2) I don't skip to the 'next' server if I *should* have failed my new() statement. I know this because I threw a computer named CRACKHEAD into the mix. I'm finding no events in the Crackhead eventlog, but I really expect to find no Crackhead, and to be informed accordingly.
Has anyone come across such a silliness before? I can't get my Win32::Eventlog::new to fail =(

-=rev=-

Replies are listed 'Best First'.
Re: more Win32::EventLog oddities
by BrowserUk (Patriarch) on Sep 26, 2002 at 17:13 UTC

    Just a thought, have you tried accessing the machines that your failing on using the event viewer whilst logged on as whatever userid the script runs on?

    The reason I ask is I once saw a similar problem with a script accessing stuff on a remote server. The script ran fine under the development account, but when run as a scheduled task on the production machine it would get so far and then hang and have to be killed.

    When we went to the actual server (stuck away under lock and key in a remote server room) and switched on the screen, having worked out which combination of switches connected the single screen and keyboard to the right one of 10 or 12 boxes in the room (closet), we discovered that there was a "Invalid logon, try again" dialog sitting on the screen.

    The one server (of a couple of hundred) where it kept hanging had a non-standard set of domain permissions.


    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
      Ahh, either I've miswritten or you've misread, but the problem is not so much that its failing on those computers... its not failing on those computers. It is treating 2-3 valid servers the same way its treating my invalid bogus server Crackhead.. that is.. it is successfully creating a Win32::Eventlog object. My problem is that if it fails to make a connection, I don't know how to determine that.. the object seems to be successfully generated.

      Thanks though,
      -=rev=-

        Your right, I did mis-read. I took

        2) I don't skip to the 'next' server

        To mean that you were hanging at that point. Sorry, my mistake.

        Thinking about this further, I have, what is no more than a speculation, that the new() call doesn't actually establish communications with the remote server, but simply readies the object for that communication. If this is true, then the way to determine if the server is actually there would be to check the return code from one of the calls that would force it to actually attempt the communication. Eg.

        $handle->GetOldest($base) or die "Can't get number of oldest EventLog record\n";
        .

        Like I say, this is speculation, but worth a try.


        Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://200954]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found