Expect script to output gathered info
Budget: $30 – $250 USD
I am looking for a script that will utilize Expect to sign into remote device run 4 commands and return parsed results in a single json output to stout. The script needs to have proper error checking in place for all commands and initial connect. It needs to read user/pass from a config file and receive the remote device IP from input.
IE ipcheck.sh 41.1.1.1 (the remote device IP)
commands to run
ping -q -i 0.001 -w 2 41.*.*.* -I Port2
ping -q -i 0.001 -w 2 41.*.*.* -I Port4
ping -q -i 0.001 -w 2 10.*.*.* -I tun21
ping -q -i 0.001 -w 2 10.*.*.* -I tun22
Expected result
{ "pingresults":
{
"device": "41.1.1.1",
"device_status": "Up",
"port2_status": "Up",
"port2_packet_loss": "4",
"port2_avg_latency": "5.21",
"port4_status": "Up",
"port4_packet_loss": "4",
"port4_avg_latency": "5.21",
"tun21_status": "Up",
"tun21_packet_loss": "4",
"tun21_avg_latency": "5.21",
"tun22_status": "Up",
"tun22_packet_loss": "4",
"tun22_avg_latency": "5.21",
}
}
Device_Status will be determined by Expect connecting to device or not.
The port status will be determined by packet loss, if 100% down else up
PAcket loss and avg latency is parsed from the ping commands results.
Regards
IE ipcheck.sh 41.1.1.1 (the remote device IP)
commands to run
ping -q -i 0.001 -w 2 41.*.*.* -I Port2
ping -q -i 0.001 -w 2 41.*.*.* -I Port4
ping -q -i 0.001 -w 2 10.*.*.* -I tun21
ping -q -i 0.001 -w 2 10.*.*.* -I tun22
Expected result
{ "pingresults":
{
"device": "41.1.1.1",
"device_status": "Up",
"port2_status": "Up",
"port2_packet_loss": "4",
"port2_avg_latency": "5.21",
"port4_status": "Up",
"port4_packet_loss": "4",
"port4_avg_latency": "5.21",
"tun21_status": "Up",
"tun21_packet_loss": "4",
"tun21_avg_latency": "5.21",
"tun22_status": "Up",
"tun22_packet_loss": "4",
"tun22_avg_latency": "5.21",
}
}
Device_Status will be determined by Expect connecting to device or not.
The port status will be determined by packet loss, if 100% down else up
PAcket loss and avg latency is parsed from the ping commands results.
Regards