# # A script to: # check for mount requests in data protector (so we know somebody needs a tape) # provide nagios output for monitoring # provide a nagios return code. 0=ok, 1=warning, 2=critical, 3=unknown # # Author: Derek Jones, CQUniversity Australia, Apr 2016 # # Version: 1.0 # An exmaple output from "omnistat -mount" : #$output ="SessionID Type Status User #============================================== #2014/02/07-9 Backup Mount Request username1\@domain.com #2014/02/07-9 Restore Mount Request username2\@domain.com # #" # use the Data Protector omnistat command to look for any mount requests $output = cmd /c omnistat -mount $warnings = @(); $returnState = 3; # unknown # Loop over each line of the output foreach ( $line in $output.split("`r`n") ) { # skip the headers if ( $line -like "*SessionID*" ) { continue; } # should be actual output from here on if ( ( $line -like "*no required sessions are running*" ) -or ( $line -like "*no currently running sessions*" ) ) { "OK: $output"; exit 0; # OK } else { # we only want any line with "mount request" written on it if ( $line -like "*mount request*" ) { # break the line up into an array $fields = ($line -replace '\s+', ' ').split() # grab the fields we need... session, type and user $session = $fields[0]; $session_type = $fields[1]; $user = $fields[4]; $warnings+="Mount request for '$user' in session $session ($session_type)"; $returnState=2; # we want this go critical } } } $string = $warnings -join ', '; "CRITICAL: " + $string; exit $returnState;