Server IP : 66.29.132.122 / Your IP : 3.147.58.159 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/lib64/nagios/plugins/nccustom/ |
Upload File : |
#!/usr/libexec/platform-python # -*- coding: utf-8 -*- # 2015/09/02, Eduard N. # version 1.1 """Nagios plugin to check status of un|installation NC ssl plugin.""" import os, re, sys from subprocess import Popen, PIPE log_file = '/usr/local/cpanel/logs/nc-ssl-cpanel-install.log' version_file = '/usr/local/cpanel/3rdparty/ncssl/VERSION' OK = 0; WARNING = 1; CRITICAL = 2; UNKNOWN = 3 re_status_critical = re.compile('[^#].* ERROR (Uni|I)nstallation: .*') re_status_warning = re.compile('[^#].* WARNING (Uni|I)nstallation: .*') def end(status, message, perfdata=""): """Exits the plugin with first arg as the return code and the second arg as the message to output.""" if perfdata: print("{} | {}".format(message, perfdata)) else: print("{}".format(message)) if status == OK: sys.exit(OK) elif status == WARNING: sys.exit(WARNING) elif status == CRITICAL: sys.exit(CRITICAL) else: sys.exit(UNKNOWN) status = False if os.path.isfile(version_file): version = open(version_file).readline().strip() else: version = Popen('/usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/whostmgr/cgi/ncssl/source/bin/console secrets:list -reveal |awk -e \'$1 ~ /VERSION/ {print $2}\'', stdout=PIPE, encoding="utf-8", shell=True).stdout.read() if os.path.isfile(log_file): for line in open(log_file): if re.match(re_status_critical, line): status = CRITICAL message = line.strip() break elif re.match(re_status_warning, line): status = WARNING message = line.strip() if status == CRITICAL: end(status, message + ', ' + version) elif status == WARNING: end(status, message + ', ' + version) else: end(OK, "OK. File is present and no error is found, " + version) else: end(CRITICAL, "Log file %s doesn't exist, %s" % (log_file, version))