The company needs to monitor the status of an app server. Developers require the use of post (JSON format parameters) to view the server return status. To determine if the server is healthy. It is not possible to use Get mode.
I use Python to write a script to monitor. The process is as follows:
Create key:
[email protected] zabbix_agentd.conf.d]# cat httppost.conf
userparameter=http.post,/usr/bin/python/etc/zabbix/scripts/httppost.py
Test key:
[email protected] zabbix_agentd.conf.d]# zabbix_get-s 127.0.0.1-k http.post
200
Script Content
[email protected] scripts]# cat httppost.py
#!/usr/bin/python
Import Requests,json
Url= "Http://app.xxxxx.com/P2MLinkCenter/setting/upgrade"
header={' content-type ': ' Application/json '}
Data=json.dumps ({"Type": "apk", "Versioncode": "1.0.0"})
Req=requests.post (Url=url,data=data,headers=header)
Print Req.status_code
Select a server to create the item:
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/80/1F/wKioL1c5Fs-BdF0BAADCzmdtRpo169.jpg "title=" 1.jpg " alt= "Wkiol1c5fs-bdf0baadczmdtrpo169.jpg"/>
Create graph:
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/80/1F/wKioL1c5FuOhZQDOAACI5gMrl7A036.jpg "title=" 2.jpg " alt= "Wkiol1c5fuohzqdoaaci5gmrl7a036.jpg"/>
View Graph:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/22/wKiom1c5FlXxFGa3AABH_iltCbE865.png "title=" 3.PNG " alt= "Wkiom1c5flxxfga3aabh_iltcbe865.png"/>
As you can see, the status code returned by the server is 200, indicating OK.
Use a Python script to call post to monitor server status