Hi,
I'am a beginner in VBS and have zero knowledge about programming but I need to create a simple script for monitoring my customer network. Basically I will run the script in different routers..
Could any expert here guide a or share any forum thread related to my requirement for me to study? Appreciate any advise. Thank you
Below is sample code that I did for a start from reference for Internet.
##############################sample code that I did ###############################################################
crt.Screen.Send "show interfaces descriptions | match BLOCKD | no-more" & VbCr
crt.Screen.WaitForString "show interfaces descriptions | match BLOCKD | no-more"
crt.Screen.WaitForString vbcrlf
strOutput = crt.Screen.ReadString(vbcrlf)
vParse = Split(strOutput, " ")
strResultint = vParse(Lbound(vParse))
crt.Screen.WaitForString(">")
crt.Screen.Send "show interface terse | match " & strResultint & vbcr
crt.Screen.WaitForString vbcrlf
########################### output from above code #################################################
{master}
user@router1> show interfaces descriptions | match BLOCKD | no-more
[highlight #FCE94F]ds-2/1/0:1:5[/highlight] up up VPN - ABC-Office (BLOCKD)
{master}
user@router1> show interfaces terse | match [highlight #FCE94F]ds-2/1/0:1:5[/highlight]
ds-2/1/0:1:5 up up
ds-2/1/0:1:5.0 up up inet 58.139.27.217/30
{master}
user@router1>
###############################################################################################################
From above script I'm able to get interface name from first command and parse to next command that router will execute that will show IP address configure for that interface.
But I'm unable to grab the IP address to move forward.
Basically what I need as below:
1) In the script, user will use specific command to match VPN Name
e.g. show interfaces descriptions | match VPNC | no-more
or maybe
e.g. show interfaces descriptions | match VPNB | no-more
2) Then, script will send the command. For the command, router will list all interfaces in the router that match the description VPNC..for example.
Different routers will probably have more or less interfaces that match the description.
3) Then, script will extract all the interfaces name
4) Proceed to send next command to find IP address using command "show interface terse <Interface name> for each interfaces found in the router that match the description in step 2
5) Do ping test to each interface/ip address by add 1 at the last octet of the IP address..i.e. IP address is 58.139.101.53. Command will ping to 58.139.101.54.
The problem I have currently is how to capture string without knowing how many row/column/array from the output and parse all that information for next command to execute.
This is because different router probably will show more or less Interface name. Example below first command will show result with 5 interfaces.
######################## Desired output from router ###########################################################
{master}
user@router> show interfaces descriptions | match VPNC | no-more
[highlight #FCE94F]ds-2/1/0:7:1[/highlight] up up IPVPN - VPNC - NO:21103
[highlight #FCE94F]ds-2/1/0:40:1[/highlight] up up IPVPN - VPNC - NO:21104
[highlight #FCE94F]ds-2/1/0:41:1[/highlight] up up IPVPN - VPNC - NO:21105
[highlight #FCE94F]ds-2/2/0:4:1[/highlight] up up IPVPN - VPNC - NO:21106
[highlight #FCE94F]ds-2/3/0:2:1[/highlight] up up IPVPN - VPNC - NO:21107
{master}
user@router> show interfaces terse [highlight #FCE94F]ds-2/1/0:7:1[/highlight]
Interface Admin Link Proto Local Remote
ds-2/1/0:7:1 up up
ds-2/1/0:7:1.0 up up inet [highlight #FCE94F]58.139.114.105[/highlight]/30
{master}
user@router> ping routing-instance VPNC-h [highlight #FCE94F]58.139.114.106[/highlight] rapid
PING 58.139.114.106 (58.139.114.106): 56 data bytes
!!!!!
--- 58.139.114.106 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 6.277/6.521/6.808/0.182 ms
{master}
user@router> show interfaces terse [highlight #FCE94F]ds-2/1/0:40:1[/highlight]
Interface Admin Link Proto Local Remote
ds-2/1/0:40:1 up up
ds-2/1/0:40:1.0 up up inet [highlight #FCE94F]58.139.101.53[/highlight]/30
{master}
user@router> ping routing-instance VPNC-h [highlight #FCE94F]58.139.101.54[/highlight] rapid
PING 58.139.101.54 (58.139.101.54): 56 data bytes
!!!!!
--- 58.139.101.54 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 5.211/5.447/6.169/0.363 ms
######################## Desired output from router ############################################################
I'am a beginner in VBS and have zero knowledge about programming but I need to create a simple script for monitoring my customer network. Basically I will run the script in different routers..
Could any expert here guide a or share any forum thread related to my requirement for me to study? Appreciate any advise. Thank you
Below is sample code that I did for a start from reference for Internet.
##############################sample code that I did ###############################################################
crt.Screen.Send "show interfaces descriptions | match BLOCKD | no-more" & VbCr
crt.Screen.WaitForString "show interfaces descriptions | match BLOCKD | no-more"
crt.Screen.WaitForString vbcrlf
strOutput = crt.Screen.ReadString(vbcrlf)
vParse = Split(strOutput, " ")
strResultint = vParse(Lbound(vParse))
crt.Screen.WaitForString(">")
crt.Screen.Send "show interface terse | match " & strResultint & vbcr
crt.Screen.WaitForString vbcrlf
########################### output from above code #################################################
{master}
user@router1> show interfaces descriptions | match BLOCKD | no-more
[highlight #FCE94F]ds-2/1/0:1:5[/highlight] up up VPN - ABC-Office (BLOCKD)
{master}
user@router1> show interfaces terse | match [highlight #FCE94F]ds-2/1/0:1:5[/highlight]
ds-2/1/0:1:5 up up
ds-2/1/0:1:5.0 up up inet 58.139.27.217/30
{master}
user@router1>
###############################################################################################################
From above script I'm able to get interface name from first command and parse to next command that router will execute that will show IP address configure for that interface.
But I'm unable to grab the IP address to move forward.
Basically what I need as below:
1) In the script, user will use specific command to match VPN Name
e.g. show interfaces descriptions | match VPNC | no-more
or maybe
e.g. show interfaces descriptions | match VPNB | no-more
2) Then, script will send the command. For the command, router will list all interfaces in the router that match the description VPNC..for example.
Different routers will probably have more or less interfaces that match the description.
3) Then, script will extract all the interfaces name
4) Proceed to send next command to find IP address using command "show interface terse <Interface name> for each interfaces found in the router that match the description in step 2
5) Do ping test to each interface/ip address by add 1 at the last octet of the IP address..i.e. IP address is 58.139.101.53. Command will ping to 58.139.101.54.
The problem I have currently is how to capture string without knowing how many row/column/array from the output and parse all that information for next command to execute.
This is because different router probably will show more or less Interface name. Example below first command will show result with 5 interfaces.
######################## Desired output from router ###########################################################
{master}
user@router> show interfaces descriptions | match VPNC | no-more
[highlight #FCE94F]ds-2/1/0:7:1[/highlight] up up IPVPN - VPNC - NO:21103
[highlight #FCE94F]ds-2/1/0:40:1[/highlight] up up IPVPN - VPNC - NO:21104
[highlight #FCE94F]ds-2/1/0:41:1[/highlight] up up IPVPN - VPNC - NO:21105
[highlight #FCE94F]ds-2/2/0:4:1[/highlight] up up IPVPN - VPNC - NO:21106
[highlight #FCE94F]ds-2/3/0:2:1[/highlight] up up IPVPN - VPNC - NO:21107
{master}
user@router> show interfaces terse [highlight #FCE94F]ds-2/1/0:7:1[/highlight]
Interface Admin Link Proto Local Remote
ds-2/1/0:7:1 up up
ds-2/1/0:7:1.0 up up inet [highlight #FCE94F]58.139.114.105[/highlight]/30
{master}
user@router> ping routing-instance VPNC-h [highlight #FCE94F]58.139.114.106[/highlight] rapid
PING 58.139.114.106 (58.139.114.106): 56 data bytes
!!!!!
--- 58.139.114.106 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 6.277/6.521/6.808/0.182 ms
{master}
user@router> show interfaces terse [highlight #FCE94F]ds-2/1/0:40:1[/highlight]
Interface Admin Link Proto Local Remote
ds-2/1/0:40:1 up up
ds-2/1/0:40:1.0 up up inet [highlight #FCE94F]58.139.101.53[/highlight]/30
{master}
user@router> ping routing-instance VPNC-h [highlight #FCE94F]58.139.101.54[/highlight] rapid
PING 58.139.101.54 (58.139.101.54): 56 data bytes
!!!!!
--- 58.139.101.54 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 5.211/5.447/6.169/0.363 ms
######################## Desired output from router ############################################################