在不登录远程主机的情况下,可以查看远程主机的服务器操作系统版本(内核)。
脚本执行前提:
1.拷贝check_snmp到脚本执行的主机中或在此主机中安装nagios;
2.保持list.txt中只有一个IP列
1 #!/bin/bash
2 #echo "">list_os.txt
3 \cp list.txt list_1.txt
4 awk {‘print $1‘} list.txt |while read line
5 do
6 echo $line
7 info=`/usr/local/nagios/libexec/check_snmp -H $line -C jd -o sysDescr.0`
8 centos63=`echo $info | grep 2.6.32-279`
9 centos62=`echo $info | grep 2.6.32-220`
10 centos56=`echo $info | grep 2.6.18-238`
11 if [ -n "$centos63" ];then
12 echo "centos63"
13 sed -i "s/^$line$/$line\tCentOS6.3/g" list_1.txt
14 fi
15 if [ -n "$centos62" ];then
16 echo "centos62"
17 sed -i "s/^$line$/$line\tCentOS6.2/g" list_1.txt
18 fi
19 if [ -n "$centos56" ];then
20 echo "centos56"
21 sed -i "s/^$line$/$line\tCentOS5.6/g" list_1.txt
22 fi
23
24 echo "---------"
25 done
nagios脚本下载地址:http://download.csdn.net/detail/drew27/7456955
远程批量获取Linux和Windos操作系统版本(内核)