aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/vty_interface_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/vty_interface_cmds.c')
-rw-r--r--openbsc/src/vty_interface_cmds.c149
1 files changed, 121 insertions, 28 deletions
diff --git a/openbsc/src/vty_interface_cmds.c b/openbsc/src/vty_interface_cmds.c
index d4945840e..dd5e108ab 100644
--- a/openbsc/src/vty_interface_cmds.c
+++ b/openbsc/src/vty_interface_cmds.c
@@ -30,6 +30,8 @@
#include <stdlib.h>
+#define LOGGING_STR "Configure log message to this terminal\n"
+
static void _vty_output(struct log_target *tgt, const char *line)
{
struct vty *vty = tgt->tgt_vty.vty;
@@ -55,6 +57,7 @@ struct log_target *log_target_create_vty(struct vty *vty)
DEFUN(enable_logging,
enable_logging_cmd,
"logging enable",
+ LOGGING_STR
"Enables logging to this vty\n")
{
struct telnet_connection *conn;
@@ -76,6 +79,7 @@ DEFUN(enable_logging,
DEFUN(logging_fltr_imsi,
logging_fltr_imsi_cmd,
"logging filter imsi IMSI",
+ LOGGING_STR
"Print all messages related to a IMSI\n")
{
struct telnet_connection *conn;
@@ -93,6 +97,7 @@ DEFUN(logging_fltr_imsi,
DEFUN(logging_fltr_all,
logging_fltr_all_cmd,
"logging filter all <0-1>",
+ LOGGING_STR
"Print all messages to the console\n")
{
struct telnet_connection *conn;
@@ -110,6 +115,7 @@ DEFUN(logging_fltr_all,
DEFUN(logging_use_clr,
logging_use_clr_cmd,
"logging color <0-1>",
+ LOGGING_STR
"Use color for printing messages\n")
{
struct telnet_connection *conn;
@@ -127,6 +133,7 @@ DEFUN(logging_use_clr,
DEFUN(logging_prnt_timestamp,
logging_prnt_timestamp_cmd,
"logging timestamp <0-1>",
+ LOGGING_STR
"Print the timestamp of each message\n")
{
struct telnet_connection *conn;
@@ -142,12 +149,48 @@ DEFUN(logging_prnt_timestamp,
}
/* FIXME: those have to be kept in sync with the log levels and categories */
-#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref)"
+#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref|gprs|ns|bssgp|all)"
+#define CATEGORIES_HELP \
+ "A-bis Radio Link Layer (RLL)\n" \
+ "Layer3 Call Control (CC)\n" \
+ "Layer3 Mobility Management (MM)\n" \
+ "Layer3 Radio Resource (RR)\n" \
+ "A-bis Radio Signalling Link (RSL)\n" \
+ "A-bis Network Management / O&M (NM/OML)\n" \
+ "Layer3 Short Messagaging Service (SMS)\n" \
+ "Paging Subsystem\n" \
+ "MNCC API for Call Control application\n" \
+ "A-bis Input Subsystem\n" \
+ "A-bis Input Driver for Signalling\n" \
+ "A-bis Input Driver for B-Channel (voice data)\n" \
+ "A-bis B-Channel / Sub-channel Multiplexer\n" \
+ "Radio Measurements\n" \
+ "SCCP\n" \
+ "Mobile Switching Center\n" \
+ "Media Gateway Control Protocol\n" \
+ "Hand-over\n" \
+ "Database Layer\n" \
+ "Reference Counting\n" \
+ "GPRS Core\n" \
+ "GPRS Network Service (NS)\n" \
+ "GPRS BSS Gateway Protocol (BSSGP)\n" \
+ "Global setting for all subsytems\n"
+
#define VTY_DEBUG_LEVELS "(everything|debug|info|notice|error|fatal)"
+#define LEVELS_HELP \
+ "Log simply everything\n" \
+ "Log debug messages and higher levels\n" \
+ "Log informational messages and higher levels\n" \
+ "Log noticable messages and higher levels\n" \
+ "Log error messages and higher levels\n" \
+ "Log only fatal messages\n"
DEFUN(logging_level,
logging_level_cmd,
"logging level " VTY_DEBUG_CATEGORIES " " VTY_DEBUG_LEVELS,
- "Set the log level for a specified category\n")
+ LOGGING_STR
+ "Set the log level for a specified category\n"
+ CATEGORIES_HELP
+ LEVELS_HELP)
{
struct telnet_connection *conn;
int category = log_parse_category(argv[0]);
@@ -159,13 +202,19 @@ DEFUN(logging_level,
return CMD_WARNING;
}
- if (category < 0) {
- vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE);
+ if (level < 0) {
+ vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
return CMD_WARNING;
}
- if (level < 0) {
- vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
+ /* Check for special case where we want to set global log level */
+ if (!strcmp(argv[0], "all")) {
+ log_set_log_level(conn->dbg, level);
+ return CMD_SUCCESS;
+ }
+
+ if (category < 0) {
+ vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -178,6 +227,7 @@ DEFUN(logging_level,
DEFUN(logging_set_category_mask,
logging_set_category_mask_cmd,
"logging set log mask MASK",
+ LOGGING_STR
"Decide which categories to output.\n")
{
struct telnet_connection *conn;
@@ -192,10 +242,11 @@ DEFUN(logging_set_category_mask,
return CMD_SUCCESS;
}
-DEFUN(logging_set_log_level,
- logging_set_log_level_cmd,
- "logging set log level <0-8>",
- "Set the global log level. The value 0 implies no filtering.\n")
+DEFUN(diable_logging,
+ disable_logging_cmd,
+ "logging disable",
+ LOGGING_STR
+ "Disables logging to this vty\n")
{
struct telnet_connection *conn;
@@ -205,14 +256,42 @@ DEFUN(logging_set_log_level,
return CMD_WARNING;
}
- log_set_log_level(conn->dbg, atoi(argv[0]));
+ log_del_target(conn->dbg);
+ talloc_free(conn->dbg);
+ conn->dbg = NULL;
return CMD_SUCCESS;
}
-DEFUN(diable_logging,
- disable_logging_cmd,
- "logging disable",
- "Disables logging to this vty\n")
+static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
+ const struct log_target *tgt)
+{
+ unsigned int i;
+
+ vty_out(vty, " Global Loglevel: %s%s",
+ log_level_str(tgt->loglevel), VTY_NEWLINE);
+ vty_out(vty, " Use color: %s, Print Timestamp: %s%s",
+ tgt->use_color ? "On" : "Off",
+ tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE);
+
+ vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE);
+
+ for (i = 0; i < info->num_cat; i++) {
+ const struct log_category *cat = &tgt->categories[i];
+ vty_out(vty, " %-10s %-10s %-8s %s%s",
+ info->cat[i].name+1, log_level_str(cat->loglevel),
+ cat->enabled ? "Enabled" : "Disabled",
+ info->cat[i].description,
+ VTY_NEWLINE);
+ }
+}
+
+#define SHOW_LOG_STR "Show current logging configuration\n"
+
+DEFUN(show_logging_vty,
+ show_logging_vty_cmd,
+ "show logging vty",
+ SHOW_STR SHOW_LOG_STR
+ "Show current logging configuration for this vty\n")
{
struct telnet_connection *conn;
@@ -221,23 +300,37 @@ DEFUN(diable_logging,
vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
return CMD_WARNING;
}
+ vty_print_logtarget(vty, &log_info, conn->dbg);
- log_del_target(conn->dbg);
- talloc_free(conn->dbg);
- conn->dbg = NULL;
return CMD_SUCCESS;
}
-void openbsc_vty_add_cmds()
+void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
{
- install_element(VIEW_NODE, &enable_logging_cmd);
- install_element(VIEW_NODE, &disable_logging_cmd);
- install_element(VIEW_NODE, &logging_fltr_imsi_cmd);
- install_element(VIEW_NODE, &logging_fltr_all_cmd);
- install_element(VIEW_NODE, &logging_use_clr_cmd);
- install_element(VIEW_NODE, &logging_prnt_timestamp_cmd);
- install_element(VIEW_NODE, &logging_set_category_mask_cmd);
- install_element(VIEW_NODE, &logging_level_cmd);
- install_element(VIEW_NODE, &logging_set_log_level_cmd);
+ vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
+ counter_get(net->stats.chreq.total),
+ counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
+ vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
+ counter_get(net->stats.chan.rf_fail),
+ counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
+ vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
+ counter_get(net->stats.paging.attempted),
+ counter_get(net->stats.paging.completed),
+ counter_get(net->stats.paging.expired), VTY_NEWLINE);
+ vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
+ counter_get(net->stats.bts.oml_fail),
+ counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
+}
+void openbsc_vty_add_cmds()
+{
+ install_element_ve(&enable_logging_cmd);
+ install_element_ve(&disable_logging_cmd);
+ install_element_ve(&logging_fltr_imsi_cmd);
+ install_element_ve(&logging_fltr_all_cmd);
+ install_element_ve(&logging_use_clr_cmd);
+ install_element_ve(&logging_prnt_timestamp_cmd);
+ install_element_ve(&logging_set_category_mask_cmd);
+ install_element_ve(&logging_level_cmd);
+ install_element_ve(&show_logging_vty_cmd);
}