首页 > 代码库 > 远程批量获取Linux和Windos操作系统版本(内核)
远程批量获取Linux和Windos操作系统版本(内核)
在不登录远程主机的情况下,可以查看远程主机的服务器操作系统版本(内核)。
脚本执行前提:
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 "---------"
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。