Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Perl Script to parse Windows Event Logs

by kar_thik82 (Novice)
on Dec 07, 2012 at 09:43 UTC ( #1007701=perlquestion: print w/replies, xml ) Need Help??
kar_thik82 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am developing a log parsing agent in perl to send windows Event logs to Zenoss Monitoring tool. Using Win32::EventLog i can able to get the Event messages but only one Eventype eg Application or System could able to parse at a time. Can you please help to how to open mutiple eventlogs at a time I need to get the total number of events combining all these event types. Below is my code which i tried

my @log_type =("Application", "Security", "Setup", "System", "Forwarde +d Events"); foreach $logs_type (@log_type){ #print "$logs_type\n"; Win32::EventLog::Open($EventLog, $logs_type,'') or die "Could not open System log:$^E\n"; $EventLog->Win32::EventLog::GetNumber($numevents); print "$EventLog->Win32::EventLog::GetNumber($numevents)\n" +; }

Replies are listed 'Best First'.
Re: Perl Script to parse Windows Event Logs
by brap (Pilgrim) on Dec 07, 2012 at 14:19 UTC

    Hi kar_thik82,

    What about keeping a running count of each event log, and then printing the total?

    my @log_type =("Application", "Security", "Setup", "System", "Forwarde +d Events"); my $total_events = 0; foreach $logs_type (@log_type) { #print "$logs_type\n"; Win32::EventLog::Open($EventLog, $logs_type,'') or die "Could not open System log:$^E\n"; $EventLog->Win32::EventLog::GetNumber($numevents); $total_events += $numevents; # print "$EventLog->Win32::EventLog::GetNumber($numevents)\n"; } print "Total number of events: $total_events\n";

    Not exactly tested, but hopefully enough to illustrate the point.

      Thanks Brap It works for me.

Re: Perl Script to parse Windows Event Logs
by Anonymous Monk on Dec 08, 2012 at 03:38 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1007701]
Approved by kcott
help
Chatterbox?
[1nickt]: Tux is cbstream working for you?
[Tux]: I have no idea! Read this article
[choroba]: yes, if the formula contains just +, -, *, /, and digits, calculate it, otherwise fail, or something like that.
[choroba]: or detection of malicious strings like | cmd or what was the security issue about.
[choroba]: re slow PM, yesterday half of my clicks in RATS ended in request timeout.
[Tux]: 1nickt - yes, it works oké
[Tux]: choroba as many formula's have references to other cells, that would only be possible on constants. CSV_XS has no knowledge of the contents of the rest of the document
[Tux]: But it could be an option for Spreadsheet::Read (but I am not tempted to do that. patches welcome?)
[choroba]: makes sense
[1nickt]: Tux Wow, interesting! He seems to say that there is no real protection in Excel other than common sense. Nice story about the Dutch police using the exploit to bring down criminal networks on the Dark Web!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-10-18 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (244 votes). Check out past polls.

    Notices?