Zabbix Monitoring Windows log Scripts

Source: Internet
Author: User

Zabbix Monitoring Windows log Scripts


The script is used to monitor the logs on the Windows Server, view the log file at the end of n rows, and if n rows contain a field, output 0, otherwise output 1, and then zabbix the profile empty definition Kye, for monitoring.


Text file line break is "\ n"

Edit Script log.py

Import sysimport redef last_lines (filename, lines = 1):     Lines = int (lines)     block_size = 1024    block  =  '     nl_count = 0    start = 0     fsock = file (filename,  ' RU ')     try:         # seek to end         Fsock.seek (0, 2)         # get seek position         curpos = fsock.tell ()          while (curpos > 0):  #while  not EOF             # seek ahead block_size+the length of last  read block            curpos -=  (block_size +  len (block));            if curpos  < 0:                  curpos = 0            fsock.seek ( CurPos)             # read to end             block = fsock.read ()              nl_count = block.count (' \ n ')              # if read enough (more)              if nl_count >= lines:                 break         # get the exact start position         for n in range (nl_count - lines + 1):             start = block.find (' \ n ',  start)  + 1     finally:        fsock.close ()      return block[start:]list = last_lines (sys.argv[1], sys.argv[2]) If re.search (" AAA ",  list):       #查看是否包含" AAA "print 0else:print 1


Here's how it works: Python log.py log.txt #最后10行


This article from "Three O elder brother" blog, declined reprint!

Zabbix Monitoring Windows log Scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.