Skip to content

Commit

Permalink
ovsdb: integrate perf-counter infrastructure into ovsdb-server
Browse files Browse the repository at this point in the history
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 <azhou@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
  • Loading branch information
azhou-nicira committed Apr 14, 2015
1 parent 619c3a4 commit 97a3c43
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion ovsdb/ovsdb-server.c
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand All @@ -338,7 +347,7 @@ main(int argc, char *argv[])
run_command, process_status_msg(status));
}
}

perf_counters_destroy();
service_stop();
return 0;
}
Expand Down Expand Up @@ -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_)
Expand Down

0 comments on commit 97a3c43

Please sign in to comment.