Created
March 7, 2018 12:24
-
-
Save zmousm/7ae7d8d4a7f943090c449ecbbbd58522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version 1.0; | |
ns junos = "http://xml.juniper.net/junos/*/junos"; | |
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; | |
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; | |
ns grnet = "urn:mace:grnet.gr:slax"; | |
import "../import/junos.xsl"; | |
function grnet:snmp_set($val) { | |
var $rpc = <request-snmp-utility-mib-set> { | |
<object-type> "integer"; | |
<instance> "var-prop-mounted"; | |
<object-value> $val; | |
} | |
result jcs:invoke($rpc); | |
} | |
match / { | |
<op-script-results> { | |
mvar $fpc_count = 0; | |
mvar $mnt_count = 0; | |
/* try all-members first, should work more often (switches > routers) */ | |
mvar $rpc = <command> "show system storage detail all-members"; | |
mvar $res = jcs:invoke($rpc); | |
if ($res/../xnm:error) { | |
set $rpc = <command> "show system storage detail invoke-on all-routing-engines"; | |
set $res = jcs:invoke($rpc); | |
} | |
if ($res/../xnm:error) { | |
copy-of $res../xnm:error; | |
expr grnet:snmp_set(2); | |
terminate "show system storage accepts neither all-members nor invoke-on all-routing-engines."; | |
} | |
for-each ($res//multi-routing-engine-item) { | |
set $fpc_count = $fpc_count + 1; | |
var $fsvar = .//filesystem[mounted-on="/var"]; | |
var $fsvar_count = count($fsvar); | |
var $fsvar_ok_count = count($fsvar[starts-with(./filesystem-name, "/dev/da")]); | |
if ($fsvar_count == $fsvar_ok_count) { | |
set $mnt_count = $mnt_count + 1; | |
} | |
} | |
if ($fpc_count == $mnt_count) { | |
<output> "OK"; | |
expr grnet:snmp_set(0); | |
} else if ($mnt_count > 0) { | |
<output> "WARN"; | |
expr grnet:snmp_set(1); | |
} else { | |
<output> "CRIT"; | |
expr grnet:snmp_set(2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment