公司有巨量的tomcat服务器,每台机器上面有好几个tomcat, 路径用后缀数字区别,
例如 /usr/local/dir_samba/apache-tomcat-7.0.64-0/webapps 表示8080端口的tomcat
每个tomtcat对应一个端口,每个tomcat都有若干的war包(应用)以下描述用zabbix自动去扫描发现每个tomcat上的war,并自动添加为监控的过程
#!/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
本文出自 “老安的博客” 博客,转载请与作者联系!
原文地址:http://superbigsea.blog.51cto.com/6862263/1745092