whoami7 - Manager
:
/
usr
/
local
/
nagios
/
plugins
/
Upload File:
files >> //usr/local/nagios/plugins/check_ro_fs.py
#!/usr/bin/python ##################################### # this file is under Puppet control # # the last change: # # 2013/11/15, Eduard N. # ##################################### # version 2013/07/31 # writen by ED # modified by Ol'egg # Requirements: # you need to allow fillowing commands in sudo: # "/bin/cat /etc/cagefs/cagefs.mp" and "/bin/touch /backup/ro_backup_test.tmp" import os, re, sys, time, random from subprocess import Popen, PIPE debug = 0 cur_mount = [x.split(' ') for x in Popen('cat /proc/mounts', stdout=PIPE, shell=True).stdout.read().split('\n') if len(x) != 0 ] ro_re = re.compile('^ro,.*$') war_list = [] backup_dir = '/backup/' test_file_name = 'ro_backup_test.tmp' test_command = Popen('sudo /bin/touch '+backup_dir+test_file_name, stderr=PIPE, shell=True) test_out, test_err = test_command.communicate() if test_command.returncode and len(test_err): war_list.append(backup_dir+' is in '+test_err+' state,') result_re = re.compile("^.* is in.* state,$") result = 0 if len(war_list) != 0: for res_line in war_list: if result_re.match(res_line): result = 1 if result: print (war_list) sys.exit(2) else: raise SystemExit(war_list) else: print ('Ok')
Copyright ©2021 || Defacer Indonesia