Hi
My script validates the main functions from 61 servers.
CPU
FILESYSTEMS
PROCESS
Inside the shell, I execute an 'expect script' to do this. If I execute this script manually, it functions very well, but if i run it from cron service, it generate the next message -> WARNING: terminal not capable of 'window' mode
I dont know if this issues is related with the ssh server o ssh client, expect or $TERM enviorment ????
WARNING: terminal not capable of 'window' mode
DataSource st cong PduLost MsuSend Fail Msu/Sec Byt/sec Last State Time mfId tId
The line that generate the issue is:
send "routeDisp\n"
set timeout 2
while (1) {
expect {
timeout { send "\003";break}
"." {send "\003";break}
}
}
expect "*user "
Script.
#!/usr/bin/expect -f
set length [string length $comando]
if {$length != 0} {
spawn ssh -Y root@10.83.xx.xx
expect {
"(yes/no)? " { send "yes\r";exp_continue }
timeout { send_user "\nNo se recibe el prompt de sistema\n"; puts $output "$server\n"; exit 1 }
eof { send_user "\nFalla al conectarse a traves de ssh al $server\n"; puts $output2 "$server\n"; exit 1 }
"*assword*"
}
send "$clave\r"
expect {
timeout { send_user "\nAutenticacion fallida. clave incorrecta.\n";puts $output1 "$server\n"; exit 1}
"* ~]# "
}
#send "ssh -q -o StrictHostKeyChecking=no $user@$server\r"
send "ping -q -c4 $server \| awk \' \$0\~\/4 received\/ \{print \$4 \} \' \r"
expect "* ~]# "
set elbuffer $expect_out(buffer)
#puts $elbuffer
foreach line [split $elbuffer \n ] {
set myswitch [lindex $line ]
if {$myswitch == 4} {
puts $myswitch
send "ssh -Y $user@$server\r"
set timeout 10
expect {
"(yes/no)? " { send "yes\r";exp_continue }
timeout { send_user "\nNo se recibe el prompt de sistema\n";puts $output "$server\n"; exit 1 }
eof { send_user "\nFalla al conectarse a traves de ssh al $server\n<br>"; exit 1 }
"*assword*" { send "$clave\r" }
"* ~]# " { send "\r" }
}
expect {
timeout { send_user "\nAutenticacion fallida. clave incorrecta.\n";puts $output1 "$server\n"; exit 1}
"* ~]# "
}
send "/sbin/ifconfig | grep \"inet\"\r"
expect "* ~]# "
send "hostname\r"
expect "* ~]# "
send "${comando}\r"
set timeout 80
expect {
timeout { send_user "\nNo se recibe el prompt de sistema\n";puts $output3 "$server\n"; exit 1 }
eof { send_user "\nFalla al conectarse a traves de ssh al $server\n<br>"; exit 1 }
"* ~]# " { send "\r"; set timeout 5 }
}
expect "* ~]# "
send "top -bn1 | grep \"Cpu\(s\)\" | sed \"s\/.*, *\\(\[0-9.\]*\\)%*id.*\/\\1\/\" | awk \' \{print 100 - \$1\"\%\"\} \' \r"
expect "* ~]# "
puts "FILESYSTEMI\r"
send "df | awk \' BEGIN\{rows=0\} NF>=4\&\&\$0\~\/\\\/\/\{ if\( \$\(NF-1\) \~ \/\[0-9\]*\%\/\) \{ val=substr\(\$\(NF-1\),1,match\(\$\(NF-1\),\"\%\"\)-1\);if\(val*1
> 90\)\{a\[rows, ++m\]=\$\(NF-1\);a\[rows, ++m\]=\$\(NF\);++rows;m=0\}\} \}END\{ for \(i=2;i>=1;i--\)for\(j=0;j<=rows;j++\)\{printf \"\%-20s \%s\",a\[j,i\],\(j<rows)\?\"\":\"\\n\"\}\} \'\r"
expect "* ~]# "
puts "FILESYSTEMF\r"
if { $IMF == 1 } {
send "su - xxxxxx\n"
expect "*user "
send "routeDisp\n"
set timeout 2
while (1) {
expect {
timeout { send "\003";break}
"." {send "\003";break}
}
}
expect "*user "
send "exit\r"
expect "* ~]# "
}
send "exit\r"
expect "* ~]# "
break
}
}
send "exit\r"
}
close $output
expect eof
any suggestion
Thanks a lot
malpa