Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How zabbix monitors the automatic screenshot of the page

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how zabbix monitors automatic screenshots of pages. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.

#coding: utf-8 import os,sys,timeimport xlsxwriterfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keys#defining workdir ='E:\\'#defining current time current_time = time.strftime("%Y%m%d",time.localtime(time.time()))#defining screenshot function CUTPAGEdef CUTPAGE(*args,**kwargs): try: #Google Chrome restricts certain ports, such as 6666. Add--explicitly-allowed-ports=6666 startup parameter when starting browser to solve ERR_UNSAFE_PORT problem options = webdriver.ChromeOptions() options.add_argument('--explicitly-allowed-ports=6666') #executable_path is where the browser driver is located driver = webdriver.Chrome(executable_path='C:\Users\Administrator4\AppData\Local\Google\Chrome\Application\chromedriver.exe',options=options) driver.get(url) Maximize the window driver.maximize_window() #Locate page elements by name username = driver.find_element_by_name('name') password = driver.find_element_by_name('password') login_button = driver.find_element_by_name('enter') #Enter your account password and click the login button username.send_keys(account) password.send_keys(passwd) login_button.click() #js = "window.scrollTo(0,document.body.scrollHeight);" #driver.execute_script(js) #pause for 5 seconds, watch zabbix home page time.sleep(5) #Screenshots driver.save_screenshot(workdir+'zabbixpage'+current_time+'.png') except: print "Fail to capture a screenshot.Please confirm if the username and the password is true! " sys.exit(1) finally: #Close browser driver.close()#define insert picture function def SAVETOEXCEL(): try: #define excel workbook workbook = xlsxwriter.Workbook(workdir+u'XXXX-Daily Monitoring_'+current_time+'. xlsx') #Add workbook sheet page worksheet = workbook.add_worksheet() #Determine if the picture exists flag = os.path.exists(workdir+'zabbixpage'+current_time+'.png') if flag: #Insert pictures and zoom them worksheet.insert_image('A1',workdir+'zabbixpage'+current_time+'.png',{'x_scale':0.9,'y_scale':1.15}) except: print "Fail to insert image into excel" sys.exit(2) finally: workbook.close()if __name__ == '__main__': url = 'http://XXX.XXX.XXX.XXX:XXXX/index.php' account = raw_input(u"Please enter the user name to log in zabbix: ".encode ('gbk ')) passwd = raw_input(u"Please enter the password to login zabbix: ".encode ('gbk ')) CUTPAGE(url=url,account=account,passwd=passwd) SAVETOEXCEL() flag = os.path.exists(workdir+'zabbixpage'+current_time+'.png') if flag: #Delete pictures os.remove(workdir+'zabbixpage'+ current_time+'.png') About "zabbix how to monitor automatic screenshots of pages" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 259

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report