(**kwargs)
Perform a icmp ping to the specified IP or hostname
Perform a icmp ping to the specified IP or hostname
Perform a icmp ping to the specified IP or hostname
def check(**kwargs):
    """ Perform a icmp ping to the specified IP or hostname """
    jdata = kwargs['jdata']
    run = True
    # Search for bad stuff
    pattern = [".*255$"]
    for regex in pattern:
        match = re.search(regex, jdata['data']['host'])
        if match:
            run = False

    if run is False:
        return False
    else:
        DEVNULL = open(os.devnull, 'wb')
        # ping -c 1 check, -W 3 second timeout, -q quietish
        cmd = ['/bin/ping', '-c', '1', '-W', '3', '-q', jdata['data']['host']]
        result = subprocess.call(
            cmd, shell=False, stdout=DEVNULL, stderr=subprocess.STDOUT)
        DEVNULL.close()
        if result != 0:
            return False
        else:
            return True
def check ( * * kwargs ) : jdata = kwargs [ 'jdata' ] run = True # Search for bad stuff pattern = [ ".*255$" ] for regex in pattern : match = re . search ( regex , jdata [ 'data' ] [ 'host' ] ) if match : run = False if run is False : return False else : DEVNULL = open ( os . devnull , 'wb' ) # ping -c 1 check, -W 3 second timeout, -q quietish cmd = [ '/bin/ping' , '-c' , '1' , '-W' , '3' , '-q' , jdata [ 'data' ] [ 'host' ] ] result = subprocess . call ( cmd , shell = False , stdout = DEVNULL , stderr = subprocess . STDOUT ) DEVNULL . close ( ) if result != 0 : return False else : return True