HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //usr/lib/python2.7/site-packages/lap/tac_flows_received.py
import os
import time
from lap import check_ha


def extract_info(line):
    return((line.split(" ")[15]).replace(',',''))


def __run__(params):
    iface = params.get("iface")
    if not check_ha(iface):
        return [0, "OK: This server is slave"]

    tcpdump_file = params.get("tcpdump_file")
    if not tcpdump_file:
        return [3, "UNKNOWN: tcpdump_file is not given"]

    delay = int(params.get("delay", 300))
    if not (time.time() - os.path.getmtime(tcpdump_file)) > delay:
        with open(tcpdump_file, "r") as fh:
            switches_ips = params.get("switches_ips")
            check = dict([(x, False) for x in switches_ips])
            for line in fh:
                ip = extract_info(line)
                if (ip in switches_ips):
                    check[ip] = True
                else:
                    check[ip] = "Unauthorized"

        failed_ips = [k for k, v in check.items() if not v]
        unauthorized_ips = [k for k, v in check.items() if v == "Unauthorized"]
        if not len(failed_ips) and not len(unauthorized_ips) > 0:
            return [0, "OK: All IP's are sending flows"]
        elif len(failed_ips) and len(unauthorized_ips) > 0:
            return [2, "CRITICAL: IP(s) %s didn't sent flows and IP(s) %s not authorized" % (failed_ips, unauthorized_ips)]
        elif len(failed_ips) > 0:
            return [2, "CRITICAL: IP(s) %s didn't sent flows" % failed_ips]
        else:
            return [2, "CRITICAL: IP(s) %s not authorized" % unauthorized_ips]
    else:
        return [1, "WARNING: TCPDUMP File is out of date"]