def Main(): cgiEnv = lib_common.ScriptEnvironment() configNam = cgiEnv.GetId() nodeManager = survol_rabbitmq_manager.MakeUri(configNam) creds = lib_credentials.GetCredentials("RabbitMQ", configNam) # cl = Client('localhost:12345', 'guest', 'guest') cl = Client(configNam, creds[0], creds[1]) grph = cgiEnv.GetGraph() try: lstOverview = cl.get_overview() except Exception as exc: lib_common.ErrorMessageHtml("Caught:" + str(exc)) for keyOverview in lstOverview: valOverview = lstOverview[keyOverview] valClean = valOverview # Otherwise it does not work as these chars should be espaced. # TODO: Nice display for Python lists and dicts. valClean = str(valClean).replace("{", "").replace("}", "") grph.add((nodeManager, lib_common.MakeProp(keyOverview), lib_util.NodeLiteral(valClean))) cgiEnv.OutCgiRdf()
parser.add_option('-s', '--scheme', help='Graphite string to prepend for metrics', dest='scheme', metavar='SCHEME') (options, args) = parser.parse_args() cl = Client('%s:%s' % (options.rmqHost, options.rmqPort), options.rmqUser, options.rmqPass, timeout=15) if options.numExchanges: numExchanges = cl.get_overview()['object_totals']['exchanges'] if options.scheme: print options.scheme + '.rmqQueueStats.ExchangeCount.' + str( numExchanges) else: if int(numExchanges) > int(options.warn) and int(numExchanges) > int( options.crit): print 'Number of exchanges CRITICAL - %s' % (numExchanges) sys.exit(2) if int(numExchanges) > int(options.warn) and int(numExchanges) < int( options.crit): print 'Number of exchanges WARNING - %s' % (numExchanges) sys.exit(1) if options.numQueues: numQueues = cl.get_overview()['object_totals']['queues']