Пример #1
0
def main():
    opts, args = parse_opts()
    cp = ConfigParser.ConfigParser()
    cp.read(opts.config)
    config_logging(cp, opts)

    if opts.cron > 0:
        random_sleep = random.randint(1, opts.cron)
        log.info("gratia-xdmod called from cron; sleeping for %d seconds." % \
            random_sleep)
        time.sleep(random_sleep)

    lockfile = cp.get("transaction", "lockfile")
    locking.exclusive_lock(lockfile)
   
    iteration = 0
    job_count = 1
    while job_count > 0 and iteration < MAX_ITERATIONS:

        iteration = iteration + 1

        last_dbid = xdmod.get_last_dbid(cp)

        log.debug("Starting from DBID %d" % last_dbid)

        jobs = gratia.query_gratia(cp, last_dbid)

        job_count = 0
        for job in jobs:
            log.debug("Processing job: %s" % str(job))
            
            if not xdmod.add(cp, job):
                log.fatal("Fatal error inserting thew job in the XDMoD database - exiting!")
                return 1
            
            job_count += 1

    return 0
Пример #2
0
        try:
            for rules_row in self.rules_rows:
                if((rules_row[0] == host) and (rules_row[4] != '')):
                    starttime = rules_row[4]
                    break
            self.log.debug("starttime is: " + str(starttime))
        except Exception, e:
            self.log.error("Caught an exception and the detail is: \n\"" + str(e) + "\". Please check your rules file syntax. Exiting Now !") 
            sys.exit(1)

        rules_min_dbid = 0
        starttime_dict = {}
        #Need to find the minimum dbid, from the Monitoring Start Time, if defined
        if(starttime is not None):
            try:
                rules_min_dbid = gratia.query_gratia(self.cp,probename=probename,starttime=starttime)
            except:
                self.log.error("Unable to Query Gratia ! Please check your database access parameters ! Exiting now.")
                sys.exit(1)
        self.log.debug("rules_min_dbid is: " + str(rules_min_dbid))
        return rules_min_dbid


    def CloseFile(self):
        #close the open files now
        if(self.file_reference != None):
            self.file_reference.close()
            self.log.debug("Closed File: " + str(self.file_reference))


Пример #3
0
                self.log.debug("Current transaction: probe=" + str(probename) + " DBID=" + str(txn[probename]))
                roll_fd = None
                try:
                    roll_fd = transaction.check_rollback(cp)
                except Exception, e:
                    self.log.error("Caught an exception and the detail is: \n\"" + str(e) + "\" Exiting Now !")
                    sys.exit(1)

                self.log.debug("Query_And_Process: setting gratia_query_txn...")
                jobs = None
                self.previous_query_dbid = txn[probename]
                gratia_query_txn = {'probename': probename, 'last_successful_id':txn[probename]}
                try:
                    # If there's no quarantine id, GetQuarantineDBID would return None and so, it should be safe to pass it in directly
                    jobs = gratia.query_gratia(cp, gratia_query_txn,quarantine_dbid=quarantine.GetQuarantineDBID(probename))
                except:
                    self.log.error("Unable to Query Gratia ! Please check your database access parameters ! Exiting now.")
                    sys.exit(1)

                processed_jobs = {}
                max_id = 0
                job_count = 0

                self.log.debug("jobs.length is: " + str(len(jobs)))
                for job in jobs:
                    self.log.debug("Processing job: %s" % str(job))
                    self.log.debug("Befor:DBID:" + str(job['dbid']) + ":Project_Name:" + str(job['project_name']) + ":User:"******":Hostname:" + str(self.hostname))
                    skip_job = False
                    job_status_valid = True