公司有巨量的tomcat服务器,每台机器上面有好几个tomcat, 路径用后缀数字区别,
例如 /usr/local/dir_samba/apache-tomcat-7.0.64-0/webapps 表示8080端口的tomcat
每个tomtcat对应一个端口,每个tomcat都有若干的war包(应用)以下描述用zabbix自动去扫描发现每个tomcat上的war,并自动添加为监控的过程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
findtomcatwar()
{
printf
'{\n'
printf
'\t"data":[ '
for
war
in
0 1 2 3
do
for
i
in
`
ls
/usr/local/dir_samba/apache-tomcat-7
.0.64-${war}
/webapps
|
grep
-
v
'host-manager\|ROOT\|manager\|.war\|indexes\|examples\|doc'
`
do
printf
'\n\t\t{'
printf
"\"{#PORTWARS}\":\"8${war}80:${i}\"}"
printf
","
echo
$num
done
done
printf
'\n\t]\n'
printf
'}\n'
}
findtomcatwar| tac|
sed
'4s/.$//'
|tac
|
本文转自 superbigsea 51CTO博客,原文链接:http://blog.51cto.com/superbigsea/1745092