-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweb_monitor.sh
More file actions
39 lines (37 loc) · 1.17 KB
/
web_monitor.sh
File metadata and controls
39 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# function:monitor tcp connect status from zabbix
# usage:
# UserParameter=web.site.discovery,/etc/zabbix/scripts/web_site_code_status web_site_discovery
# UserParameter=web.site.code[*],/etc/zabbix/scripts/web_site_code_status web_site_code $1
source /etc/bashrc >/dev/null 2>&1
source /etc/profile >/dev/null 2>&1
#/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/
WEB_SITE_discovery () {
WEB_SITE=($(cat WEB1.txt|grep -v "^#"))
printf '{\n'
printf '\t"data":[\n'
for((i=0;i<${#WEB_SITE[@]};++i)) {
num=$(echo $((${#WEB_SITE[@]}-1)))
if [ "$i" != ${num} ]; then
printf "\t\t{ \n"
printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$i]}\"},\n"
else
printf "\t\t{ \n"
printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$num]}\"}]}\n"
fi
}
}
web_site_code () {
/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1
}
case "$1" in
web_site_discovery)
WEB_SITE_discovery
;;
web_site_code)
web_site_code $2
;;
*)
echo "Usage:$0 {web_site_discovery|web_site_code [URL]}"
;;
esac