Beispiel #1
0
from create_json import Create_Json


def set_exit_handler(func):
    signal.signal(signal.SIGTERM, func)


def on_exit(sig, func=None):
    print "exit handler triggered"
    sys.exit(1)


if __name__ == '__main__':

    set_exit_handler(on_exit)
    metric_pkgs = cfg.readConfig()

    loglib(cfg.logfile, 'INFO: Starting DynamicGraph...')

    while True:

        cfg.purged = 0
        cfg.purge_errors = 0

        # Create a new object per cluster
        for cluster, metric_list in metric_pkgs.items():
            fqmn = cfg.RRDDIR + '/' + cluster + '/'
            cluster = GangliaClusterSearch(cluster)
            cluster.RRDDIR = cfg.RRDDIR
            nodes = cluster.findClusterMembers()



def set_exit_handler(func):
    signal.signal(signal.SIGTERM, func)

def on_exit(sig, func=None):
    print "exit handler triggered"
    loglib(cfg.logfile,'WARN: Exiting program')
    sys.exit(1)

def get_Eth0():
    ''' We want to ensure we only listen on internal IP
        which is protected from the outside world '''

    ni.ifaddresses('eth0')
    ip = ni.ifaddresses('eth0')[2][0]['addr']
    return(ip)


if __name__ == "__main__":

    set_exit_handler(on_exit)

    listenIp = get_Eth0()

    cfg.readConfig()
    jobs_scheduler = GangliaRestScheduler()
    gangliarest = GangliaRest(host=listenIp,port=8653)
#Importing my other python files
import read_config as rc #python file to read config.txt. Functions from this file: readConfig(configName="config.txt")
import excel_functions as ex #python file to read from the required excel sheet. Functions from this file: openExcel(filename, sheetname)
from question_classes import NumericQn, CategoricalQn, FreeResponseQn, DemographicQn #python file containing classes for each question type, with functions to evaluate them
import output_methods #python file to output the analysis to the console and a word document. Functions from this file: console_output(question, exclude=[ ], summLen=5) and docx_output(question, doc, exclude=[ ], summLen=5)

#Importing other libraries
import docx #allows me to write to a Microsoft Word Document

####################
### Main program ###
####################

#reading from the configuration file
configs = rc.readConfig() #read config.txt. Returns a list containing various information (as listed below)
                          #simply returns "ERROR" when an error occurs
if configs != "ERROR": #if configs == "ERROR", do not execute the rest of the program
    #elements of the configuration file
    xlName = configs[0] #first element: the name of the Excel file containing the desired sheet
    sheetName = configs[1] #second element: the name of the Excel sheet to read the data from
    docName = configs[2] #third element: the name of the Word Document to save the analysis from
    questions = configs[3] #fourth element: a dictionary with the details of each question
                           #each question is arranged as <question no.>: <question type>
    leaveOut = configs[4] #fifth element: a list of words (strings) to leave out from the summary
    summLen = configs[5] #sixth element: the number of sentences to be included in the summary

    #opening the files
    responses = ex.openExcel(xlName, sheetName) #reads from the desired excel sheet. Returns a 2D list containing the responses for each question

if configs != "ERROR" and responses != "ERROR": #if configs == "ERROR" or responses == "ERROR", do not execute the rest of the program
    #opening the files (cont'd)
Beispiel #4
0
# 
# This file part of gangliarest
#
# Dave Carroll - [email protected]
#
#

import os
import sys
import time
import redis
import read_config as cfg
from loglib import loglib


cfg.readConfig()

rootDir = cfg.rrdDir 


class GangliaIndexer(object):
    ''' Indexer class. This class contains two methods
        which are responsible for indexing operations. Indexing
        the locations of Ganglia node directories into Redis speeds
        up access and response time for API clients requesting metric
        info.  '''

    # Set in /etc/GangliaRest.cfg and defines how often we index
    indexer_frequency = cfg.indexFreq 
    index_adds = 0
Beispiel #5
0

def set_exit_handler(func):
    signal.signal(signal.SIGTERM, func)

def on_exit(sig, func=None):
    print "exit handler triggered"
    sys.exit(1)



if __name__ == '__main__':


    set_exit_handler(on_exit)
    metric_pkgs = cfg.readConfig()


    loglib(cfg.logfile,'INFO: Starting DynamicGraph...')

    while True:

        cfg.purged = 0
        cfg.purge_errors = 0


        # Create a new object per cluster
        for cluster,metric_list in metric_pkgs.items():
            fqmn = cfg.RRDDIR+'/'+cluster+'/'
            cluster = GangliaClusterSearch(cluster)
            cluster.RRDDIR=cfg.RRDDIR