From: Andy Zhou Date: Sat, 21 Mar 2015 07:00:49 +0000 (-0700) Subject: ovsdb: integrate perf-counter infrastructure into ovsdb-server X-Git-Tag: v2.4.0~339 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=97a3c43515e86afaff0808e9a9f4cdfaca39792b ovsdb: integrate perf-counter infrastructure into ovsdb-server This integration also adds two commands: ovsdb-server/perf-counters-show -- show all counters ovsdb-server/perf-counters-clear -- clear all counters There is no pre-configured sample points. A programmer needs to added sampling point by changing the source code. However he does not need to worry about infrastructures such as initialization or cleaning up memory when ovsdb-server exits. Signed-off-by: Andy Zhou Acked-by: Ethan Jackson --- diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index deb2b8bb3..cd13b0de1 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -53,6 +53,7 @@ #include "trigger.h" #include "util.h" #include "unixctl.h" +#include "perf-counter.h" #include "openvswitch/vlog.h" VLOG_DEFINE_THIS_MODULE(ovsdb_server); @@ -76,6 +77,8 @@ static bool bootstrap_ca_cert; static unixctl_cb_func ovsdb_server_exit; static unixctl_cb_func ovsdb_server_compact; static unixctl_cb_func ovsdb_server_reconnect; +static unixctl_cb_func ovsdb_server_perf_counters_clear; +static unixctl_cb_func ovsdb_server_perf_counters_show; struct server_config { struct sset *remotes; @@ -292,6 +295,8 @@ main(int argc, char *argv[]) daemonize_complete(); + perf_counters_init(); + if (!run_command) { /* ovsdb-server is usually a long-running process, in which case it * makes plenty of sense to log the version, but --run makes @@ -318,6 +323,10 @@ main(int argc, char *argv[]) ovsdb_server_remove_database, &server_config); unixctl_command_register("ovsdb-server/list-dbs", "", 0, 0, ovsdb_server_list_databases, &all_dbs); + unixctl_command_register("ovsdb-server/perf-counters-show", "", 0, 0, + ovsdb_server_perf_counters_show, NULL); + unixctl_command_register("ovsdb-server/perf-counters-clear", "", 0, 0, + ovsdb_server_perf_counters_clear, NULL); main_loop(jsonrpc, &all_dbs, unixctl, &remotes, run_process, &exiting); @@ -338,7 +347,7 @@ main(int argc, char *argv[]) run_command, process_status_msg(status)); } } - + perf_counters_destroy(); service_stop(); return 0; } @@ -1021,6 +1030,26 @@ ovsdb_server_exit(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, NULL); } +static void +ovsdb_server_perf_counters_show(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, + void *arg_ OVS_UNUSED) +{ + char *s = perf_counters_to_string(); + + unixctl_command_reply(conn, s); + free(s); +} + +static void +ovsdb_server_perf_counters_clear(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, + void *arg_ OVS_UNUSED) +{ + perf_counters_clear(); + unixctl_command_reply(conn, NULL); +} + static void ovsdb_server_compact(struct unixctl_conn *conn, int argc, const char *argv[], void *dbs_)