Ejemplo n.º 1
0
    def __init__(self, modconf):
        BaseModule.__init__(self, modconf)
        self.backend = getattr(modconf, 'backend', 'mongodb')
        self.uri = getattr(modconf, 'uri', 'localhost')
        self.database = getattr(modconf, 'database', 'shinken')
        self.replica_set = getattr(modconf, 'replica_set', '')

        # 15min chunks
        self.chunk_interval = int(getattr(modconf, 'chunk_interval', '900'))

        # Some used variable init
        self.con = None
        self.db = None
        self.col = None

        self.host_dict = {}
        self.svc_dict = {}

        # And our final trender object
        self.trender = Trender(self.chunk_interval)
Ejemplo n.º 2
0
                      dest='uri',
                      help='Mongodb URI to connect from')

    if len(sys.argv) == 1:
        sys.argv.append('-h')

    opts, args = parser.parse_args()

    do_regexp = opts.do_regexp
    uri = opts.uri or 'localhost'

    # ok open the connexion
    open_connexion(uri)

    CHUNK_INTERVAL = int(opts.chunk_interval or '300')
    trender = Trender(CHUNK_INTERVAL)

    hname = opts.host_name
    sdesc = opts.service_description
    metric = opts.metric
    prevision = int(opts.prevision or '0')
    check_time = int(opts.check_time or time.time())

    sec_from_morning = get_sec_from_morning(check_time)
    wday = get_wday(check_time)
    chunk_nb = sec_from_morning / CHUNK_INTERVAL

    if prevision == 0:
        def_warn = '20%'
        def_crit = '50%'
    else: