Example #1
0
def load_agent():

    try:

        process = subprocess.Popen(load_command, stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent loaded.')

        elif 'Already loaded' in error_output:

            logger.log('Agent is already loaded.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not load agent.", logger.LogLevel.Error)
        logger.log_exception(e)
Example #2
0
def restart_agent():

    try:

        process = subprocess.Popen(stop_command, stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent has restarted.')

        elif 'No such process' in error_output:

            logger.log('Agent not found. Nothing to restart.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not start agent.", logger.LogLevel.Error)
        logger.log_exception(e)
Example #3
0
def start_agent():

    result = False
    try:

        process = subprocess.Popen(start_command, stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent started.')
            result = True

        elif 'No such process' in error_output:

            logger.log('Agent not found.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not start agent.", logger.LogLevel.Error)
        logger.log_exception(e)

    return result
Example #4
0
def load_agent():

    try:

        process = subprocess.Popen(load_command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent loaded.')

        elif 'Already loaded' in error_output:

            logger.log('Agent is already loaded.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not load agent.", logger.LogLevel.Error)
        logger.log_exception(e)
Example #5
0
def restart_agent():

    try:

        process = subprocess.Popen(stop_command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent has restarted.')

        elif 'No such process' in error_output:

            logger.log('Agent not found. Nothing to restart.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not start agent.", logger.LogLevel.Error)
        logger.log_exception(e)
Example #6
0
def start_agent():

    result = False
    try:

        process = subprocess.Popen(start_command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        raw_output, error_output = process.communicate()

        if raw_output == '' and error_output == '':

            logger.log('Agent started.')
            result = True

        elif 'No such process' in error_output:

            logger.log('Agent not found.')

        else:

            logger.log('Unknown output: "%s"' % error_output)

    except Exception as e:

        logger.log("Could not start agent.", logger.LogLevel.Error)
        logger.log_exception(e)

    return result