From 3360839cf8845850a0fbf3e409dc0fe6d7ee0404 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 1 Mar 2005 23:12:10 +0000 Subject: [PATCH] added a opensrf.router.info.stats method which returns info on all connected server classes and server class nodes git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@144 9efc2488-bf62-4759-914b-345cdb29e865 --- src/router/router.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/router/router.c b/src/router/router.c index 497830d..332f0cb 100644 --- a/src/router/router.c +++ b/src/router/router.c @@ -937,11 +937,65 @@ osrf_message* router_registrar_process_app_request( cur_class = cur_class->next; } - //if( json_object_array_length(result_content) < 1 ) - // result_content = NULL; + } else if(!strcmp(omsg->method_name,"opensrf.router.info.stats")) { - } + /* we have a server_class array which holds an array of node_objects. + each node_object contains an array of stats + */ + + debug_handler("Processing opensrf.router.info.stats request"); + + result_content = json_object_new_object(); + server_class_node* cur_class = router->server_class_list; + + while( cur_class != NULL ) { + + server_node* start_node = cur_class->current_server_node; + server_node* cur_node = start_node; + if( cur_node == NULL ) continue; + + json* server_object = json_object_new_object(); + + do { + + json* node_stats_array = json_object_new_array(); + + json* json_reg_time = json_object_new_object(); + json_object_object_add( json_reg_time, "reg_time", + json_object_new_int((int)cur_node->reg_time)); + json_object_array_add( node_stats_array, json_reg_time ); + + json* json_upd_time = json_object_new_object(); + json_object_object_add( json_upd_time, "upd_time", + json_object_new_int((int)cur_node->upd_time)); + json_object_array_add( node_stats_array, json_upd_time ); + + json* json_la_time = json_object_new_object(); + json_object_object_add( json_la_time, "la_time", + json_object_new_int((int)cur_node->la_time)); + json_object_array_add( node_stats_array, json_la_time ); + json* json_serve_count = json_object_new_object(); + json_object_object_add( json_serve_count, "serve_count", + json_object_new_int((int)cur_node->serve_count)); + json_object_array_add( node_stats_array, json_serve_count ); + + json_object_object_add( server_object, cur_node->remote_id, node_stats_array ); + + cur_node = cur_node->next; + + } while( cur_node != start_node ); + + json_object_object_add( + result_content, cur_class->server_class, server_object ); + + cur_class = cur_class->next; + + } + + } + + if( result_content == NULL ) return NULL; -- 2.11.0