Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 8th, 2012, 06:43 AM
oviperl oviperl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 16 oviperl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 20 m 25 sec
Reputation Power: 0
WMI Eventlog:Unable to get specific EventLogs (Application logs)

Hi,
I am trying to get specific eventlogs using WMI. These are Application related logs and I'd like to get it based on "EventCode". The code below does that but it doesn't fetch all the Application logs. e.g. I would like to get all the eventlogs with Eventcode "103" but it's not able to fetch that. It gets eventlogs with Eventcode "102" and some other Eventcodes. Can someone help in understanding what might be going wrong?

[ code ]

use Win32::OLE qw (in);
$Computer = 'servername';
$Win32_Class ='Win32_NTLogEvent';
$Class = "WinMgmts://$Computer";
$Wmi = Win32::OLE->GetObject ($Class);
if ($Events = $Wmi->ExecQuery("SELECT * FROM $Win32_Class WHERE LogFile='Application' AND EventCode=103")) {

print "$Events\n"; # prints Win32::OLE=HASH(0x3c88a00)

}

foreach $Event (in($Events)) { # Failing here.

print "$Event{TimeGenerated}\n";
print "$Event{Message}\n";

}
exit;

[ /code ]

If I use "EventCode=102", I am able to get the output but it's not working for "EventCode=103" and some other required codes. Please let me know what need to be done in order to get specific eventlogs.

Thanks

Reply With Quote
  #2  
Old August 8th, 2012, 06:47 AM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,874 Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)  Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 1 Day 20 h 28 m 56 sec
Reputation Power: 6421
Send a message via Google Talk to Axweildr
Orkut
if 102's are coming up, and 103's aren't - are we sure there are 103 events, under Application?
__________________
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
-- Jamie Zawinski
Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE

Reply With Quote
  #3  
Old August 8th, 2012, 06:51 AM
oviperl oviperl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 16 oviperl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 20 m 25 sec
Reputation Power: 0
Quote:
Originally Posted by Axweildr
if 102's are coming up, and 103's aren't - are we sure there are 103 events, under Application?


Hi,
Thanks for the reply. I am sure that 103 eventcodes are present under "Application" only. But somehow it's not working. Not sure what's that issue. I am able to get only few eventcodes like 102, 1704, etc. But the one's which are really required are not coming out.

Thanks.

Reply With Quote
  #4  
Old August 9th, 2012, 02:42 AM
oviperl oviperl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 16 oviperl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 20 m 25 sec
Reputation Power: 0
Quote:
Originally Posted by oviperl
Hi,
Thanks for the reply. I am sure that 103 eventcodes are present under "Application" only. But somehow it's not working. Not sure what's that issue. I am able to get only few eventcodes like 102, 1704, etc. But the one's which are really required are not coming out.

Thanks.


Has anyone faced the similar issue? Or am I missing something in the code to get specific WMI eventcode?

Appreciate your help.
Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > WMI Eventlog:Unable to get specific EventLogs (Application logs)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap