Zabbix automatic plot script and zabbix graph script
#! /Bin/bash # do not configure the character set, the script in the crontab issued by the Chinese E-MAIL garbled export LANG = en_US.UTF-8 # a little obsessive, what do you like to do? __^ cd/home/zabbix/graph1_keep cookiefile name cookie1_zbx_cookie.txt> $ COOKIE # I am opening a group on zbx and getting a read-only account, put the host you want to plot in. NAME = "reader" PASSWD = "123456789" # it's nice to say that there are several e-mail messages that can be written side by side. E-mail = "haha@abc.com hehe@abc.com lala@123.com" # Need to extract data IP address, in fact, this IP address is mainly used to name the image. En IPADDR = (192.168.1.1 192.168.1.2) # This place is troublesome. Because itemid is unique, you need to scan it with your own eyes. # Here is an example of memory and cpu. Grace.
CPU_ITEMID = (12345 67890) MEM_ITEMID = (98765 65432) # zbx Address URL = "http: // 127.0.0.1 "# log on to save cookiecurl-s-c $ COOKIE-B $ COOKIE-d" request = & name =$ {NAME} & password =$ {PASSWD} & autologin = 1 & enter = Sign + in "$ URL # Or obsessive-compulsive disorder, wooden way. [[-D cpu_png] | mkdir cpu_png [[-d mem_png] | mkdir mem_png # PERIOD in which the PERIOD configuration obtains data, expressed in seconds. # Ld needs to be within 7 days. 604800, everyone knows. # Here is an example of 3600 I wrote. PERIOD = 3600 # This is our start time, that is, the current time, STIME = $ (date + % Y % m % d % H % M % S) # Image Width WHIDTH = 1200 # I create images cyclically for the itemid group. This is what I write for the sake of display.
# Do not write it too long ~! You know. Let's start urlfor I in $ (seq 0 $ [$ {# CPU_ITEMID [@]}-1]); do curl-s-B $ COOKIE \-F "itemid =$ {CPU_ITEMID [I]}" \-F "period = $ PERIOD" \-F "curtime = $ STIME" \-F "width = $ WHIDTH" \ "$ URL/chart. php "> cpu_png/cpu1_ipaddr1_i1_1__cpu.png donefor I in $ (seq 0 $ [$ {# MEM_ITEMID [@]}-1]); do curl-s-B $ COOKIE \-F "itemid =$ {MEM_ITEMID [I]}" \-F "period = $ PERIOD" \-F "curtime = $ STIME" \-F "width = $ WHIDTH" \ "$ URL/chart. php "> mem_png/${ipaddr[i1_1__mem.png done
# I started to get a little lazy. Anyway, the pictures all come out. I tried it manually. CPU_PNG = "-a cpu_png/192.168.1.20.cpu.png-a cpu_png/others" MEM_PNG = "-a mem_png/192.168.1.20.mem.png-a mem_png/192.168.1.2_mem.png" # E-MAIL TITLE, all understand. No. CPU_TITLE = "$ (date + % Y % m % d) Cpu idle curve" MEM_TITLE = "$ (date + % Y % m % d) memory realused curve chart "# kakaka started to bomb the ld by email, so there is no need to write an endless loop. : P echo "the attachment shows the cpu idle curve of the spot check server" | mail-s "$ CPU_TITLE" $ CPU_PNG $ EMAILecho "the attachment shows the memory realused curve of the spot check server" | mail-s "$ MEM_TITLE" $ MEM_PNG $ EMAIL # clean your work, remember to clean your mouth after dinner. [[-D cpu_png] & rm-rf cpu_png [[-d mem_png] & rm-rf mem_pngexit 0
In fact, it is based on this url.
The final display is like this.
Click the image automatically when the image is displayed by clicking the button. After the image disappears, you can find the image and click it again. How to write such a cyclic script?
Do
FindPic 0, 0, 1024,768, "Attachment: \ shenzhen.bmp", 0.9, intX, intY
If intX> 0 And intY> 0 Then
MoveTo intX + 5, intY + 5
LeftClick 1
End If
Delay1000
Loop
How can I set monitoring metrics if the execution time of zabbix custom scripts is too long?
Good Way! I have previously thought about letting zabbixagent call the BAT file. First, use the BAT start function to run VBS next to it and read the last execution result of VBS. Unfortunately, zabbixagent seems to end the sub-process that will start after BAT is executed, and cannot achieve the desired effect. However, I did not really think about using the windows task plan to execute VBS and put the result there before obtaining it. Thank you for reminding me! View Original post>