Table of Contents

Parsing ping test

The goal of this example is to use a ping test and use its result as a condition.

Vendor: Cisco_IOS

Command Job

The job is “empty”. It still requires something though, so it's filled with a '!'.

!

Parsing template ping_cisco_ios

The command that is used is ping <ip>.

The output is shown below:

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.6, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/9/17 ms

This parse template will match specifically on the words “Success rate is” and “percent”, the variable is set which is in between, in this case the digit “100”. The remainder of the line is ignored by using “|*|”

Success rate is <percent> percent |*|

Job scenario

Description Parsing vlan and interfaces on <node> 
task = ping_test

Scenario ping_test

# Test whether node is live and reachable
reachable -n <node>
if error
    LogAction -n <node> -a Parse_job -m "<node> is not reachable"
    stop
endif
LogAction -n <node> -a Parse_job -m "<node> is reachable"

<@cmd> = parse_cmd -n <node> -t ping_cisco_ios -r "ping <ip>"

if ! <percent> == 0
  log -m "ping is successful"
  # choose your action
endif

end