...
Sometimes a piece of data is embedded in a lower level (ancestor) but is required to complete the metric information.
Other options can be found here.
Code Block | ||||
---|---|---|---|---|
| ||||
For the following XML data section, we would like to get the interface name from within the Lane table/row: <TABLE_interface> <ROW_interface> <interface>Ethernet1/1</interface> <sfp>present</sfp> <type>10Gbase-SR</type> <name>CISCO-JDSU </name> <partnum>PLRXPL-SC-S43-CS</partnum> <rev>1 </rev> <serialnum>JUR2003G2ZJ </serialnum> <nom_bitrate>10300</nom_bitrate> <len_50>82</len_50> <len_625>26</len_625> <len_50_OM3>300</len_50_OM3> <ciscoid>3</ciscoid> <ciscoid_1>4</ciscoid_1> <TABLE_lane> <ROW_lane> <...> <tx_pwr>-2.24</tx_pwr> <tx_pwr_flag> </tx_pwr_flag> <tx_pwr_alrm_hi>1.69</tx_pwr_alrm_hi> <tx_pwr_alrm_lo>-11.30</tx_pwr_alrm_lo> <tx_pwr_warn_hi>-1.30</tx_pwr_warn_hi> <tx_pwr_warn_lo>-7.30</tx_pwr_warn_lo> <...> </ROW_lane> </TABLE_lane> </ROW_interface> - _groups: # Tx Power Alarm: 0.0 if Tx Power is within warning range ${root}/TABLE_interface/ROW_interface/TABLE_lane/ROW_lane[not(lane_number)]: _temp: tx_pwr: _text: "tx_pwr" low: _text: "tx_pwr_warn_lo" high: _text: "tx_pwr_warn_hi" interface: _text: ancestor::node()/interface _tags: "im.name": _constant: "hardware-element-status" "live-config": _constant: "true" "display-name": _constant: "Optics" "im.dstype.displayType": _constant: "state" "im.identity-tags": _constant: "name" _transform: _value.double: | { if ((${temp.tx_pwr} < ${temp.low}) || (${temp.tx_pwr} > ${temp.high})) { print "0.0" } else { print "1.0" } } _tags: "name": | { print "Optic Tx Power State ${temp.interface}" } "interface": | { print "${temp.interface}" } |
...