unix自动登录Telnet,实现查看多台服务器硬盘及数据表空间使用情况
2008-12-01 20:39
826 查看
以下代码在Sun Solaris 10 系统上运行成功。
#######################Auto Login Telnet###########################
# 在网上找到了一些自动登录的例子,现在用于更实用的例子。 #
# #
# 下面代码主要用于,简单的实现了,在一台服务上运行一个脚本, #
# 就可以查看其它服务器上的硬盘及数据表空间使用情况, #
# 想必还有一些更好的办法,或更安全的方法来实现。 #
###################################################################
#!/bin/bash
ipAddressList="192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.5" #IP地址列表;
rm LookResult.log #删除原来的日志。这里如何能做个判断会再好点。
tmptty=`tty` ;echo 1:$tmptty
tmptty=`basename $tmptty` ;echo 2:$tmptty
tmpname=`whoami` ;echo 3:$tmpname
inp1="telnetUserName" ;echo 4:$inp1 #telnet 登录时用户名
inp2="telnetPassword" ;echo 5:$inp2 #telnet 登录时用户密码
inp3="df -h" ;echo 6:$inp3 #查看磁盘空间使用情况。
inp4="sqlplus userName/password<<!" #登录数据。
inp5=" select t1.tablespace_name ""表空间""," #表空间使用情况
inp51=" t1.r ""可用空间"","
inp52=" t2.a ""总大小"" from "
inp53=" (select tablespace_name ,sum(bytes)/1024/1024 as r from dba_free_space t1 group by tablespace_name)t1,"
inp54=" (select tablespace_name , sum(bytes)/1024/1024 as a from dba_data_files group by tablespace_name) t2 "
inp55=" where t1.tablespace_name=t2.tablespace_name;"
inp6="!"
echo 8:$inp4
echo $inp5 $inp51 $inp52 $inp53 $inp54 $inp55
echo $inp6
inputfile=in
outputfile=out.log
for ipAddress in $ipAddressList #循环IP得址列表
do
echo "******************************$ipAddress Looking Beging **********************" >>LookResult.log
echo "******************************$ipAddress Looking Beging **********************"
rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile
exec 7<>$outputfile
exec 8<>$inputfile
telnet $ipAddress <&8 >&7 & #开始Telent 登录
sleep 1; echo $inp1 >> $inputfile #用户名
sleep 1; echo $inp2 >> $inputfile #密码
sleep 1; echo $inp3 >> $inputfile #查看磁盘空间使用情况命令。
sleep 1; echo $inp4 >> $inputfile #登录Sqlplus
sleep 1; echo $inp5$inp51$inp52$inp53$inp54$inp55 >> $inputfile #查看表空间使用情况语句
sleep 1; echo $inp6 >> $inputfile #语句结束退出Sqlplus
sleep 1; echo exit >> $inputfile #退出Telnet登录
ps -ef | grep telnet | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh #结束相关进程
ps -ef | grep tail | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh #结束相关进程
cat $outputfile
more $outputfile >> LookResult.log
echo "******************************$ipAddress Looking over ************************" >> LookResult.log
echo "******************************$ipAddress Looking over ************************"
done
exit #退出.sh
#######################Auto Login Telnet###########################
# 在网上找到了一些自动登录的例子,现在用于更实用的例子。 #
# #
# 下面代码主要用于,简单的实现了,在一台服务上运行一个脚本, #
# 就可以查看其它服务器上的硬盘及数据表空间使用情况, #
# 想必还有一些更好的办法,或更安全的方法来实现。 #
###################################################################
#!/bin/bash
ipAddressList="192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.5" #IP地址列表;
rm LookResult.log #删除原来的日志。这里如何能做个判断会再好点。
tmptty=`tty` ;echo 1:$tmptty
tmptty=`basename $tmptty` ;echo 2:$tmptty
tmpname=`whoami` ;echo 3:$tmpname
inp1="telnetUserName" ;echo 4:$inp1 #telnet 登录时用户名
inp2="telnetPassword" ;echo 5:$inp2 #telnet 登录时用户密码
inp3="df -h" ;echo 6:$inp3 #查看磁盘空间使用情况。
inp4="sqlplus userName/password<<!" #登录数据。
inp5=" select t1.tablespace_name ""表空间""," #表空间使用情况
inp51=" t1.r ""可用空间"","
inp52=" t2.a ""总大小"" from "
inp53=" (select tablespace_name ,sum(bytes)/1024/1024 as r from dba_free_space t1 group by tablespace_name)t1,"
inp54=" (select tablespace_name , sum(bytes)/1024/1024 as a from dba_data_files group by tablespace_name) t2 "
inp55=" where t1.tablespace_name=t2.tablespace_name;"
inp6="!"
echo 8:$inp4
echo $inp5 $inp51 $inp52 $inp53 $inp54 $inp55
echo $inp6
inputfile=in
outputfile=out.log
for ipAddress in $ipAddressList #循环IP得址列表
do
echo "******************************$ipAddress Looking Beging **********************" >>LookResult.log
echo "******************************$ipAddress Looking Beging **********************"
rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile
exec 7<>$outputfile
exec 8<>$inputfile
telnet $ipAddress <&8 >&7 & #开始Telent 登录
sleep 1; echo $inp1 >> $inputfile #用户名
sleep 1; echo $inp2 >> $inputfile #密码
sleep 1; echo $inp3 >> $inputfile #查看磁盘空间使用情况命令。
sleep 1; echo $inp4 >> $inputfile #登录Sqlplus
sleep 1; echo $inp5$inp51$inp52$inp53$inp54$inp55 >> $inputfile #查看表空间使用情况语句
sleep 1; echo $inp6 >> $inputfile #语句结束退出Sqlplus
sleep 1; echo exit >> $inputfile #退出Telnet登录
ps -ef | grep telnet | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh #结束相关进程
ps -ef | grep tail | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh #结束相关进程
cat $outputfile
more $outputfile >> LookResult.log
echo "******************************$ipAddress Looking over ************************" >> LookResult.log
echo "******************************$ipAddress Looking over ************************"
done
exit #退出.sh
相关文章推荐
- unix自动登录Telnet,实现查看多台服务器硬盘及数据表空间使用情况
- 使用vs2010的Coded UI Test实现数据驱动的用户自动登录测试
- Shell脚本实现监控swap空间使用情况和查看占用swap的进程
- bdf和df查看linus/unix系统空间使用情况
- Sql Server中查看数据表空间使用情况
- Oracle 查看表空间的大小及使用情况sql语句和oracle增加表空间大小两种实现方法
- 4种 查看数据空间使用情况 的方法
- 查看数据空间使用情况
- geotrellis使用(二十六)实现海量空间数据的搜索处理查看
- 创建表空间以及用户,授予权限,查看表空间名称及大小,物理文件的名称及大小,数据库的创建日期和归档方式,数据库的版本,数据库库对象,表空间的使用情况,表空间读写
- 使用事务实现--转账问题:从0001账户转1000块到0002账户。打开"隐式事务":设置为开,删除表中数据,回滚!(默认情况为关,如果打开了则不自动提交,学要手动提交)
- 使用vs2010的Coded UI Test实现数据驱动的用户自动登录测试
- 使用vs2010的Coded UI Test实现数据驱动的用户自动登录测试
- Oracle查看所有表空间的数据使用情况
- Shell脚本实现监控swap空间使用情况和查看占用swap的进程
- 脚本实现查看表空间使用情况
- orcle查看表空间数据文件使用情况
- Oracle 查看表空间、数据文件的大小及使用情况
- oracle查看表空间数据文件使用情况
- Oracle 查看表空间的大小及使用情况sql语句