背景】:
公司需要对一批服务器的端口进行监控
【方法】:
1、利用zabbix API将服务器ip+端口导入到ZABBIX中进行监控。
2、利用shell ,维护好一个文本,将ip和端口放入ZABBIX中进行监控
3、python脚本等
【实施】:这里采用第二种
先决条件:安装好nc命令。关闭selinux,或者在selinux中放行ncat命令
如果要ping服务器,则需要安装fping命令
因公司保密,图片中打码较多,请见谅
先上代码: ping_and_port.sh
web_ip_discovery () {
WEB_IP=($(cat /etc/zabbix/scripts/ips.txt|grep -v "^#"))
printf '{\n'
printf '\t"data":[\n'
for((i=0;i<${
#WEB_IP[@]};++i))
{
num=$(echo $((${
#WEB_IP[@]}-1)))
if [ "