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: //lib/python2.7/site-packages/lap/subinterfaces.py
#!/usr/bin/python
import socket
import fcntl
import struct
import array
import glob
import re
import platform

def all_interfaces():
    max_possible = 128
    bytes        = max_possible *32
    s            = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    names        = array.array('B', '\0' * bytes)
    outbytes     = struct.unpack('iL', fcntl.ioctl(
                    s.fileno(),
                    0x8912, # SIOCGICONF
                    struct.pack('iL', bytes, names.buffer_info()[0])
                ))[0]
    namestr      = names.tostring()
    lst          = []
    for i in range(0, outbytes, 40):
        name = namestr[i:i+16].split('\0', 1)[0]
        lst.append(name)
    return lst

def __run__(params):
    try:
        dist_name   = platform.dist()[0]
        interfaces  = all_interfaces()
        ifaces_down = []
        if dist_name == 'debian':
            pass
        elif dist_name == 'redhat':
            iface_files   = glob.glob('/etc/sysconfig/network-scripts/ifcfg*:*')
            re_iface_name = re.compile('.*?/ifcfg-(.*?:.*)$')
            re_onboot     = re.compile('ONBOOT=yes', re.IGNORECASE)
            ifaces_up     = True
            for iface_file in iface_files:
                if re_iface_name.match(iface_file):
                    iface_match = re_iface_name.match(iface_file)
                    iface_name = iface_match.group(1)
                    # Truncate interface name
                    iface_name = iface_name[:15]
                    with open(iface_file) as fd_iface:
                        onboot = False
                        for line in fd_iface.readlines():
                            if re_onboot.match(line):
                                onboot = True
                        if onboot == True:
                            if iface_name not in interfaces:
                                ifaces_up = False
                                ifaces_down.append(iface_name)
            if ifaces_up == True:
                return [0,'OK']
            else:
                return [2,'CRITICAL: Interfaces down %s' % ifaces_down]
        elif dist_name == 'Ubuntu':
            iface = []
            f = open("/etc/network/interfaces")
            for line in f.readlines():
                line = line.strip()
                if "iface" in line:
                    iface.append(line.split()[1])
            for a in iface:
                if a not in interfaces:
                    return [2,'CRITICAL: Interfaces down %s' % a]
            return [0, 'OK']

    except Exception, e:
        return [2,'CRITICAL: %s' % repr(e)]