In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Today, due to work requirements, it is necessary to check the network availability connected with the hands-on on the offer machine (windows system). Using the function of zabbix itself can not solve this problem. So at the beginning, consider using the ping command of the python script tuning system to detect
Then use zabbix to monitor and complete the task.
After looking it up on the Internet, I found that the test can be completed by using subprocess and shlex, so I referred to the whole small script.
#! / usr/bin/env python#-*-coding: utf-8-*-# author:qingmiaoimport subprocessimport shlexcmd = "ping-n 1 127.0.0.1" args = shlex.split (cmd) try: subprocess.check_call (args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) print "1" except subprocess.CalledProcessError: print "0"
After execution, as shown in the following figure, 1 is returned after successful detection, otherwise 0 is returned.
Later, it was found that this method was not documented on the ground and was not easy to track. Tried a lot of methods, and finally found that the use of windows's own bat script can be easily achieved, amazed!
Redirect the execution results to a file named after a timestamp, which is time-divided to facilitate tracking of the results.
@ echo offset THISDATE=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%set IP=127.0.0.1echo% TIME:~0,8% > > D:\ test\ ping_result_%THISDATE%.txt (ping% IP%-n 1 | find "TTL" > > D:\ test\ ping_result_%THISDATE%.txt) & & echo 1 | | echo 0
The execution result is as follows, and you can also use zabbix to call this script
BINGO
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: 0
*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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.