def main(): config = load_config(SERVER_CONFIG_PATH) local_host = config.get("server_ip") #local_host = get_ip_address(config.get("local_interface")) rpc_port = config.get("rpc_port") rpc_server = ThreadingXMLRPCServer((local_host, rpc_port), logRequests=False) #rpc_server.register_function(sign_in) #rpc_server.register_function(howru) rpc_server.register_instance(MonServer()) threadinglize(rpc_server.serve_forever, "rpc_server")() logger.info("start RPC server on %s:%d" % (local_host, rpc_port)) rrd_root = config.get("RRD_root", "/dev/shm") rrd_handler = RRDHandler.getInstance(rrd_root) ds_port = config.get("ds_port") data_server = DataReciever((local_host, ds_port), rrd_handler) threadinglize(data_server.serve_forever, "data_server")() logger.info("start data server on %s:%d" % (local_host, ds_port)) #model_int = Interface() agent_timeout = config.get("agent_timeout") check_alive_interval = config.get("check_alive_interval") scheduled_task(check_alive, "check_alive", True, 0, -1, check_alive_interval)(agent_timeout) logger.info("check_alive started...") while True: myprint(threading.enumerate()) sleep(60)
app = Flask(__name__) from PerfDataCache import PerfDataCache from RRD.RRDHandler import RRDHandler from utils.utils import encode from utils.load_config import load_global_config from utils.get_logger import get_logger logger = get_logger('PerfDataCacheHTTPServer') config = load_global_config() cache_size = config.get('cache_size') rrd_root = config.get("RRD_root") db_handler = RRDHandler.getInstance(rrd_root) cache = PerfDataCache.getInstance(cache_size, db_handler) @app.route('/monitor/<host>/<metric>') @app.route('/monitor/<host>/rawdata/<metric>') def get_stats(host, metric): only_latest = False cf = request.args.get('cf', 'AVERAGE') step = request.args.get('step', 15) start = request.args.get('start') if start is None: only_latest = True start = '-%s' % step end = -1 else: end = request.args.get('end', -1)