#!/bin/bash # awk 'END{print}' get the last row iplist=$(cat ~/fanr/shell/Weekly/ip.list) for _IP in $iplist do echo $_IP usage=$(ssh root@$_IP df --total|awk 'END{if(NR=FNR) print 100-int($5)}') cpu=$(ssh root@$_IP vmstat | awk 'END{print 100-int($15)}') mem=$(ssh root@$_IP free -om |awk '{if($1 == "Mem:") print int($3)}') disk=$(ssh root@$_IP iostat -dx| awk '{if(NR==4) print 100-int($12)}') echo "insert into PerformanceWeekly(alias,cpu,memory,diskfree,cpu2,ideldisk) values('$_IP',$cpu,$mem,$usage,$cpu, $disk)" > out.sql isql mydsn sa Tiansign2012 -w < out.sql done
配置:
对于使用isql需要配置,应用用sqlcmd会报错,找不到,
isql需要配置一下文件
/usr/local/etc/odbc.ini
[mydsn]
Driver= SQL ServerNativeClient11.0
Database= datbase
Server= xxx.xxx.xxx.xxx,port
/usr/local/etc
/odbcinst.ini
[SQL ServerNativeClient11.0]
Description=Microsoft SQL Server ODBC Driver V1.0forLinux
Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=1
参考: