[python-win32] Monitoring the Event Log

Jan Van Uytven (Wyvern) wyvernlist at crm3.com
Wed Nov 17 21:49:55 CET 2004


I found out I can capture the events as they're being generated using
wmi:

c = wmi.WMI()
event_watcher=c.watch_for
(notification_type="Creation",wmi_class="Win32_NTLogEvent",delay_secs=1)

<while service is running>
evt=event_watcher()
<code to examine event, raise flag if detect RAID event>


I can see a problem with this approach - Windows generates events
frequently, and I wouldn't want to miss a relevant event while the
service is busy sending an e-mail. I think threading might be useful
here - do the e-mailing in a separate thread while continuing to examine
events. 

Jan


On Wed, 2004-11-17 at 11:25 -0800, Jan Van Uytven (Wyvern) wrote:
> Hi,
> 
> I have a RAID array on a server whose driver posts an event to the
> System Event Log when there's a change in the status of the array. I
> could just buy an event log monitor that will send me e-mail when that
> happens but I was wondering: Could I write a Python service to monitor
> the event log? 
> 
> I have Mark Hammond's excellent book, and with it's help the service  &
> e-mailing itself shouldn't be a problem, but I'd appreciate advice on
> the best way to monitor the log. Is there any way for the service to
> register itself somehow so it gets notified whenever an event gets
> posted to the log? Failing that, can the service use the windows
> scheduler to search the log every hour on the hour? Or is there a much
> easier way I'm not seeing?
> 
> Thanks,
> 
> Jan
> ---
> Jan Van Uytven
> Computer Systems & Network Engineer
> Convergent Media Network
> wyvern at crm3.com
> 
> Randomly selected from my quote-file:
> 
> "Without warning came those deep, cracked,
>  raucous vocal sounds which will never leave the
>  memory of the stricken group who heard them.
>  Not from any human throat were they born, for
>  the organs of Man can yield no such acoustic
>  perversions..."
> 	-"The Call of Cthulhu"
> 
> 
> >>> LEGAL STUFF <<< 
> This electronic message transmission, including any attached files, 
> contains information which may be confidential and/or privileged.
> The information is intended to be for the SOLE use of the individual or 
> entity named above. If you are not the intended recipient, be aware 
> that any review, disclosure, copying, distribution or use of the 
> contents of this information is prohibited. This message is not to be 
> forwarded for any reason without prior consent of the sender. 
> 
> If you have received this electronic transmission in error, please 
> notify the sender immediately by telephone (250) 386-4266 or by a 
> 'reply to sender only' message and destroy all electronic and hard 
> copies of the communication, including attachments, without reading 
> or saving in any manner.
> 
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
---
Jan Van Uytven
Computer Systems & Network Engineer
Convergent Media Network
wyvern at crm3.com

Randomly selected from my quote-file:

"There was a moment last night, when she was sandwiched between the
two finnish dwarves and the maori tribesman, when I thought 'I could spend the
rest of my life with this woman'"
	--- Zoolander


>>> LEGAL STUFF <<< 
This electronic message transmission, including any attached files, 
contains information which may be confidential and/or privileged.
The information is intended to be for the SOLE use of the individual or 
entity named above. If you are not the intended recipient, be aware 
that any review, disclosure, copying, distribution or use of the 
contents of this information is prohibited. This message is not to be 
forwarded for any reason without prior consent of the sender. 

If you have received this electronic transmission in error, please 
notify the sender immediately by telephone (250) 386-4266 or by a 
'reply to sender only' message and destroy all electronic and hard 
copies of the communication, including attachments, without reading 
or saving in any manner.



More information about the Python-win32 mailing list