def main(): db_sec = os.path.expandvars("$HOME/dbinfo/DBSecurity.xml") if not os.path.exists(db_sec): db_sec = os.path.expandvars("$DBSECURITY_LOCATION") if not os.path.exists(db_sec): db_sec = os.path.expandvars("/etc/DBSecurity.xml") if not os.path.exists(db_sec): db_sec = os.path.expandvars("/etc/DBParam.xml") x = XmlConfig(file=db_sec) filename = resource_filename("gratia.config", "gratia_data_queries.xml") x = XmlConfig(file=filename) conn_man = x.globals['GratiaSecurityDB'] gratia_data = x.globals['GratiaDataQueries'] conn_obj = conn_man.get_connection(None) conn = conn_obj.get_connection() curs = conn.cursor() for vo, members in mapVos().items(): try: gratia_voname = gratia_data.vo_lookup(vo=vo)[0][0][0] except: gratia_voname = 'UNKNOWN' print "VO: %s, Gratia VO: %s" % (vo, gratia_voname) try: curs.execute("DELETE FROM VOMembers where vo=?", (vo, )) except TypeError: curs.execute("DELETE FROM VOMembers where vo=%s", (vo, )) for member in members: try: curs.execute("INSERT INTO VOMembers VALUES (?, ?, ?)", (vo, member[0], member[1])) except TypeError: curs.execute("INSERT INTO VOMembers VALUES (%s, %s, %s)", (vo, member[0], member[1])) conn.commit()
def main(): # Load up all the queries xml_config = XmlConfig( file=resource_filename('gratia.config', 'rsv_queries.xml')) xml_config = XmlConfig( file=resource_filename('gratia.config', 'rsv_wlcg.xml')) xml_config = XmlConfig( file=resource_filename('gratia.config', 'rsv_summary.xml')) connman = xml_config.globals['RegistrationDB'].get_connection(None) conn = connman.get_connection() rsv_summary = xml_config.globals['RSVSummaryQueries'] rsv_queries = xml_config.globals['RSVQueries'] rsv_wlcg = xml_config.globals['RSVWLCGQueries'] options, args = parseOptions() days = int(options.days) hours, days, weeks, months = find_missing_intervals(days, rsv_summary) upload_hours(hours, rsv_wlcg, conn) upload_days(days, rsv_wlcg, conn) upload_weeks(weeks, rsv_wlcg, conn) upload_months(months, rsv_wlcg, conn)
def defaultData(self, data): x = XmlConfig() data['vo_list'] = [i for i in x.\ globals['GratiaDataQueries'].vo_list()[0]] data['vo_sets'] = self.vo_sets data['site_sets'] = self.site_sets data['site_list'] = [i for i in x.\ globals['GratiaDataQueries'].site_list()[0]] super(Navigation, self).defaultData(data) data['navigation'] = data.get('navigation', {}) self.navFromRoles(data) self.gridNav(data) self.otherNav(data) return data
#!/usr/bin/env python from graphtool.base.xml_config import XmlConfig import sys, cherrypy xc = XmlConfig(file=sys.argv[1]) cherrypy.quickstart() cherrypy.engine.start() xc.globals['web'].kill()
#!/usr/bin/env python from graphtool.base.xml_config import XmlConfig import cherrypy if __name__ == '__main__': xc = XmlConfig( file='$GRAPHTOOL_CONFIG_ROOT/website_prod.xml' ) cherrypy.server.quickstart() cherrypy.engine.start() xc.globals['web'].kill()
from __future__ import print_function import cgi, cgitb, warnings cgitb.enable() import cStringIO from graphtool.base.xml_config import XmlConfig from graphtool.graphs.graph import draw_empty warnings.filterwarnings('ignore', 'integer argument expected, got float') if __name__ == '__main__': xc = XmlConfig( file="$GRAPHTOOL_CONFIG_ROOT/phedex_graphs.xml" ) classes = xc.find_classes() phedex_grapher = classes['phedex_grapher'] form = cgi.FieldStorage() my_input = {} for key in form.keys(): my_input[key] = form.getfirst( key ) query_name = form.getfirst("graph") try: image = phedex_grapher.run_query( query_name, **my_input ) except Exception as e: image = cStringIO.StringIO() draw_empty( "Error drawing graph:\n%s" % str(e), image, my_input ) image = image.getvalue() print("Content-Type: image/png") print() print(image)
# Exit statuses recognized by Nagios UNKNOWN = -1 OK = 0 WARNING = 1 CRITICAL = 2 # Load the DB filename = os.path.expandvars("$HOME/dbinfo/DBParam.xml") if not os.path.exists(filename): filename = os.path.expandvars("$DBPARAM_LOCATION") if not os.path.exists(filename): filename = '/etc/DBParam.xml' x = XmlConfig(file=filename) conn = None row = None try: conn = x.globals['GIPConnMan'].get_connection(None).get_connection() curs = conn.cursor() except Exception, e: print 'CRITICAL - GIPConnMan DB Connection error: e' % e raise SystemExit, CRITICAL try: curs.execute ("SELECT count(*) FROM subcluster_score WHERE timestamp > DATE_SUB(NOW(), INTERVAL 2 DAY)") row = curs.fetchone () except Exception, e: print 'CRITICAL - GIPConnMan DB Query error: e' % e raise SystemExit, CRITICAL
def main(): # Load up the config file. cp = config_file() # Load the DB filename = os.path.expandvars("$HOME/dbinfo/DBParam.xml") if not os.path.exists(filename): filename = os.path.expandvars("$DBPARAM_LOCATION") if not os.path.exists(filename): filename = '/etc/DBParam.xml' x = XmlConfig(file=filename) conn = x.globals['GIPConnMan'].get_connection(None).get_connection() curs = conn.cursor() # Read the CE entries from the BDII. entries = read_bdii(cp, query="(&(objectClass=GlueCE))") cluster_info = create_count_dict(entries) # Map from the cluster hostname to the unique ID id_to_hostname = {} for entry in entries: fk = entry.glue['ForeignKey'] info = fk.split("=", 1) if len(info) != 2: continue if info[0] != "GlueClusterUniqueID": print >> sys.stderr, "Entry has unknown cluster FK: %s" % entry continue id = info[1] id_to_hostname[id] = entry.glue['CEHostingCluster'] sc_info = sub_cluster_info(id_to_hostname.keys(), cp) # For each unique cluster ID, map to one of the cluster hostnames new_sc_info = {} for id, info in sc_info.items(): if id not in id_to_hostname: print >> sys.stderr, "ID %s has no matching cluster hostname." % id continue new_sc_info[id_to_hostname[id]] = info sc_info = new_sc_info specint = get_cpu_normalizations() now = datetime.datetime.now() curs.execute("DELETE FROM cpu_score") for cpu, score in specint.items(): if isinstance(score, types.TupleType): score = score[0] #specint[cpu] = score curs.execute("INSERT INTO cpu_score VALUES (%s, %s, %s)", (cpu, \ int(score), int(0))) site_ownership = create_site_dict(entries, cp) ownership = ownership_info(entries, cp) # Initialize the Probe's configuration ProbeConfig = '/etc/osg-storage-report/ProbeConfig' try: Gratia.Initialize(ProbeConfig) except Exception, e: print e raise