禁用 zabbix_agentd
[@bjsjs_115_94 alertscripts]# cat zabbix_disable.sh
#!/bin/bash
Local_IP=$(ifconfig eth0|grep "\binet\b"|awk -F'[ :]+' '{print $(NF-4)}')
ZABBIX_API="http://10.134.115.94/api_jsonrpc.php"
CURL_REQ="curl -s -i -X POST -H 'Content-type:application/json' -d"
#Must be the root user
if [ $(echo $(id -u)) -ne 0 ];then
echo -e "\033[34mMust be carried out using the root user, current user is $(whoami)\033[0m"
exit 1
fi
#Zabbix template variables
hostname="$1"
if [ -z "$1" ];then
echo -e "\033[31mDid not find the IP list,Please enter the IP list\033[0m"
exit 1
fi
HOST_ID='{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"filter": {
"host": [
"'$hostname'"
]
}
},
"auth": "00000000000000000000000000000000",
"id": 1
}'
H_ID=$(curl -s -i -X POST -H 'Content-type:application/json' -d "$HOST_ID" "$ZABBIX_API"|sed -rn '/"hostid"/s/.*:"(.*)","proxy_.*/\1/gp')
echo $H_ID
HOST_DIS='{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid":"'$H_ID'",
"groups": [
{
"groupid": "134"
}
],
"status":1
},
"auth": "00000000000000000000000000000000",
"id": 1
}'
if [ "x$H_ID" != "x" ];then
curl -s -i -X POST -H 'Content-type:application/json' -d "$HOST_DIS" "$ZABBIX_API"
fi