VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /lib64/nagios/plugins/nccustom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/nagios/plugins/nccustom/check_ncsslplugin.py
#!/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))

VaKeR 2022