aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/stats_vty.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-28 21:47:45 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-29 01:10:07 +0100
commitbc4f7ae512b32fa4b569dfc5242d0b7a5da3f81b (patch)
tree26754f63d142105a9b6939efe4378c2c2c6eff9d /src/vty/stats_vty.c
parent490b38f57a24726f3e3493fc3500cda526c5d0aa (diff)
stats: Add log reporter
This reporter passes the measurement values to the logging subsystem as DSTATS (which is currently DLGLOBAL) level INFO messages. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/vty/stats_vty.c')
-rw-r--r--src/vty/stats_vty.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index 18ad283..839dc82 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -258,6 +258,47 @@ DEFUN(cfg_no_stats_reporter_statsd, cfg_no_stats_reporter_statsd_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_stats_reporter_log, cfg_stats_reporter_log_cmd,
+ "stats reporter log",
+ CFG_STATS_STR CFG_REPORTER_STR "Report to the logger\n")
+{
+ struct stats_reporter *srep;
+
+ srep = stats_reporter_find(STATS_REPORTER_LOG, NULL);
+ if (!srep) {
+ srep = stats_reporter_create_log(NULL);
+ if (!srep) {
+ vty_out(vty, "%% Unable to create log reporter%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ /* TODO: if needed, add stats_add_reporter(srep); */
+ }
+
+ vty->index = srep;
+ vty->node = CFG_STATS_NODE;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_stats_reporter_log, cfg_no_stats_reporter_log_cmd,
+ "no stats reporter log",
+ NO_STR CFG_STATS_STR CFG_REPORTER_STR "Report to the logger\n")
+{
+ struct stats_reporter *srep;
+
+ srep = stats_reporter_find(STATS_REPORTER_LOG, NULL);
+ if (!srep) {
+ vty_out(vty, "%% No log reporting active%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ stats_reporter_free(srep);
+
+ return CMD_SUCCESS;
+}
+
DEFUN(show_stats,
show_stats_cmd,
"show stats",
@@ -277,6 +318,9 @@ static int config_write_stats_reporter(struct vty *vty, struct stats_reporter *s
case STATS_REPORTER_STATSD:
vty_out(vty, "stats reporter statsd%s", VTY_NEWLINE);
break;
+ case STATS_REPORTER_LOG:
+ vty_out(vty, "stats reporter log%s", VTY_NEWLINE);
+ break;
}
vty_out(vty, " disable%s", VTY_NEWLINE);
@@ -312,8 +356,11 @@ static int config_write_stats(struct vty *vty)
{
struct stats_reporter *srep;
+ /* TODO: loop through all reporters */
srep = stats_reporter_find(STATS_REPORTER_STATSD, NULL);
config_write_stats_reporter(vty, srep);
+ srep = stats_reporter_find(STATS_REPORTER_LOG, NULL);
+ config_write_stats_reporter(vty, srep);
vty_out(vty, "stats interval %d%s", stats_config->interval, VTY_NEWLINE);
@@ -326,6 +373,8 @@ void stats_vty_add_cmds()
install_element(CONFIG_NODE, &cfg_stats_reporter_statsd_cmd);
install_element(CONFIG_NODE, &cfg_no_stats_reporter_statsd_cmd);
+ install_element(CONFIG_NODE, &cfg_stats_reporter_log_cmd);
+ install_element(CONFIG_NODE, &cfg_no_stats_reporter_log_cmd);
install_element(CONFIG_NODE, &cfg_stats_interval_cmd);
install_node(&cfg_stats_node, config_write_stats);