|
这是获取数据并生成csv文件的脚本
getdata
#!/bin/sh
cd /getdata
filename="/getdata/ip.txt"
filename2="/getdata/type.txt"
while read line
do
ip="$line"
while read line2
do
graph=$line2
/usr/bin/ovpmbatch graphtemplate=Agents graph="$graph" SYSTEMNAME=$ip GRAPHTYPE=CSV >$ip,$graph.csv
done <$filename2
done <$filename
/getdata/procCPU.sh //执行procCPU.sh
procCPU.sh
#!/bin/sh
for i in *.csv
do
ip=$(echo $i|cut -d, -f 1)
temp=$(echo $i|cut -d, -f 2)
type=$(echo $temp|cut -d. -f 1)
if [ "$type" = "CPU Utilization Baseline" ]
then
lastline=$(tail -1 "$i")
date=$(echo $lastline|cut -d, -f 1)
time=$(echo $lastline|cut -d, -f 2)
cpu_ut=$(echo $lastline|cut -d, -f 3)
export ORACLE_BASE=/oracle/app
export ORACLE_SID=hpov
export ORACLE_HOME=/oracle/app/10.0.1
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -c <<EOF
sqlplus /nolog
connect sim/hpsim@ov_net]sim/hpsim@ov_net
set feedback off;
set pagesize 0;
insert into permon (ip,permondate,cpuper) values ($ip,$date$time,$cpu_ut);
commit;
EOF
fi
done
/getdata/procglobal.sh
procglobal.sh
#!/bin/sh
for i in *.csv
do
ip=$(echo $i|cut -d, -f 1)
temp=$(echo $i|cut -d, -f 2)
type=$(echo $temp|cut -d. -f 1)
if [ "$type" = "Global Details" ]
then
lastline=$(tail -1 "$i")
date=$(echo $lastline|cut -d, -f 1)
time=$(echo $lastline|cut -d, -f 2)
cpu_per=$(echo $lastline|cut -d, -f 3)
run_queue=$(echo $lastline|cut -d, -f 4)
physical_disk=$(echo $lastline|cut -d, -f 5)
disk_io_rate=$(echo $lastline|cut -d, -f 6)
physical_disk_rate=$(echo $lastline|cut -d, -f 7)
memory_pageout_rate=$(echo $lastline|cut -d, -f 8)
memory_utilization=$(echo $lastline|cut -d, -f 9)
swap_utilization=$(echo $lastline|cut -d, -f 10)
peak_filesystem=$(echo $lastline|cut -d, -f 11)
network_in=$(echo $lastline|cut -d, -f 12)
network_out=$(echo $lastline|cut -d, -f 13)
system_call_rate=$(echo $lastline|cut -d, -f 14)
system_mode_cpu=$(echo $lastline|cut -d, -f 15)
user_mode_cpu=$(echo $lastline|cut -d, -f 16)
number_of_users=$(echo $lastline|cut -d, -f 17)
process_creation_rate=$(echo $lastline|cut -d, -f 18)
export ORACLE_BASE=/oracle/app
export ORACLE_SID=hpov
export ORACLE_HOME=/oracle/app/10.0.1
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -c <<EOF
sqlplus /nolog
connect sim/hpsim@ov_net]sim/hpsim@ov_net
set feedback off;
set pagesize 0;
update permon set
swapper=$swap_utilization,diskper=$physical_disk_rate,diskioper=$disk_io_rate,sparefile=$peak_filesystem,usercpuper=$user_mode_cpu,syscpuper=$system_mode_cpu,memper=$memory_utilization,memcache=$memory_pageout_rate,netrecper=$network_in,netsenper=$network_out,userconnect=$number_of_users where permondate=$date$time and ip=$ip;
fi
done
/getdata/procnetwor.sh
procnetwor.sh
#!/bin/sh
for i in *.csv
do
ip=$(echo $i|cut -d, -f 1)
temp=$(echo $i|cut -d, -f 2)
type=$(echo $temp|cut -d. -f 1)
if [ "$type" = "Network Summary" ]
then
lastline=$(tail -1 "$i")
date=$(echo $lastline|cut -d, -f 1)
time=$(echo $lastline|cut -d, -f 2)
packet_out_rate=$(echo $lastline|cut -d, -f 3)
packet_in_rate=$(echo $lastline|cut -d, -f 4)
network_error_rate=$(echo $lastline|cut -d, -f 5)
export ORACLE_BASE=/oracle/app
export ORACLE_SID=hpov
export ORACLE_HOME=/oracle/app/10.0.1
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -c <<EOF
sqlplus /nolog
connect sim/hpsim@ov_net]sim/hpsim@ov_net
set feedback off;
set pagesize 0;
update permon set errorbagper=$network_error_rate where permondate=$date$time and ip=$ip;
fi
done
/getdata/procsystem.sh
procsystem.sh
#!/bin/sh
for i in *.csv
do
ip=$(echo $i|cut -d, -f 1)
temp=$(echo $i|cut -d, -f 2)
type=$(echo $temp|cut -d. -f 1)
if [ "$type" = "System Configuration" ]
then
lastline=$(tail -1 "$i")
date=$(echo $lastline|cut -d, -f 1)
time=$(echo $lastline|cut -d, -f 2)
system_id=$(echo $lastline|cut -d, -f 3)
machine=$(echo $lastline|cut -d, -f 4)
machine_model=$(echo $lastline|cut -d, -f 5)
cpu_clock_speed=$(echo $lastline|cut -d, -f 6)
os_name=$(echo $lastline|cut -d, -f 7)
os_version=$(echo $lastline|cut -d, -f 8)
os_release=$(echo $lastline|cut -d, -f 9)
memory_size=$(echo $lastline|cut -d, -f 10)
active_cpus=$(echo $lastline|cut -d, -f 11)
number_of_cpu=$(echo $lastline|cut -d, -f 12)
average_number_of_disk=$(echo $lastline|cut -d, -f 13)
average_number_of_network=$(echo $lastline|cut -d, -f 14)
swap_space_mb=$(echo $lastline|cut -d, -f 15)
gmt_offset=$(echo $lastline|cut -d, -f 16)
export ORACLE_BASE=/oracle/app
export ORACLE_SID=hpov
export ORACLE_HOME=/oracle/app/10.0.1
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -c <<EOF
sqlplus /nolog
connect sim/hpsim@ov_net]sim/hpsim@ov_net
set feedback off;
set pagesize 0;
update permon set comtype=$machine_model,servertype=$machine_model,comsystemed=$os_name$os_version$os_release,comuserinfo=$machine where permondate=$date$time and ip=$ip;
fi
done
/getdata/profilesystem.sh
procfilesystem.sh
#!/bin/sh
for i in *.csv
do
ip=$(echo $i|cut -d, -f 1)
temp=$(echo $i|cut -d, -f 2)
type=$(echo $temp|cut -d. -f 1)
if [ "$type" = "Filesystem Details" ]
then
lastline=$(tail -8 "$i")
for j in $lastline
do
date=$(echo $j|cut -d, -f 1)
time=$(echo $j|cut -d, -f 2)
directory_name=$(echo $j|cut -d, -f 3)
space_utilization=$(echo $j|cut -d, -f 4)
max_size=$(echo $j|cut -d, -f 5)
space_used=$(echo $j|cut -d, -f 6)
space_reserved=$(echo $j|cut -d, -f 7)
type=$(echo $j|cut -d, -f 8)
device_name=$(echo $j|cut -d, -f 9)
id=$(echo $j|cut -d, -f 10)
inode_utilization=$(echo $j|cut -d, -f 11)
max_inodes=$(echo $j|cut -d, -f 12)
blocksize=$(echo $j|cut -d, -f 13)
fragment_size=$(echo $j|cut -d, -f 14)
export ORACLE_BASE=/oracle/app
export ORACLE_SID=hpov
export ORACLE_HOME=/oracle/app/10.0.1
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -c <<EOF
sqlplus /nolog
connect sim/hpsim@ov_net]sim/hpsim@ov_net
set feedback off;
set pagesize 0;
update permon set filesyssize=$max_size,useunixinode=$inode_utilization,spareunixinode=$max_inodes where permondate=$date$time and ip=$ip;
done
fi
done
请问什么地方不正确,为什么插入不进去数据库里头
[ 本帖最后由 qwldcl 于 2008-5-7 21:32 编辑 ]
|