公司有巨量的tomcat服务器,每台机器上面有好几个tomcat, 路径用后缀数字区别,
例如 /usr/local/dir_samba/apache-tomcat-7.0.64-0/webapps 表示8080端口的tomcat
每个tomtcat对应一个端口,每个tomcat都有若干的war包(应用)以下描述用zabbix自动去扫描发现每个tomcat上的war,并自动添加为监控的过程
#!/bin/bashfindtomcatwar(){printf '{\n'printf '\t"data":[ 'for war in 0 1 2 3do 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 donedoneprintf '\n\t]\n'printf '}\n'}findtomcatwar| tac|sed '4s/.$//'|tac