This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged.
Change subject: ctrl: add oml-uptime command
......................................................................
ctrl: add oml-uptime command
Expose OML link uptime available via vts's "sh bts 0" command with the
new "bts.0.oml-uptime" ctrl command. To avoid code duplication, move
uptime computation into separate function and use it for both.
Change-Id: Iec405aa949d6a38a9c8e64cd7ee4b49fd416835d
Related: OS#2486
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_ctrl_commands.c
M src/libbsc/bsc_init.c
M src/libbsc/bsc_vty.c
4 files changed, 43 insertions(+), 13 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 429526d..51b2c98 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -657,6 +657,8 @@
char *get_oml_status(const struct gsm_bts *bts);
char *get_model_oml_status(const struct gsm_bts *bts);
+unsigned long long bts_uptime(const struct gsm_bts *bts);
+
/* control interface handling */
int bsc_base_ctrl_cmds_install(void);
diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c
index d925e67..2d6fcb6 100644
--- a/src/libbsc/bsc_ctrl_commands.c
+++ b/src/libbsc/bsc_ctrl_commands.c
@@ -240,6 +240,21 @@
CTRL_CMD_DEFINE_RO(bts_oml_conn, "oml-connection-state");
+static int get_bts_oml_up(struct ctrl_cmd *cmd, void *data)
+{
+ const struct gsm_bts *bts = cmd->node;
+
+ cmd->reply = talloc_asprintf(cmd, "%llu", bts_uptime(bts));
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE_RO(bts_oml_up, "oml-uptime");
+
static int verify_bts_gprs_mode(struct ctrl_cmd *cmd, const char *value, void *_data)
{
int valid;
@@ -450,6 +465,7 @@
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_si);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_chan_load);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_oml_conn);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_oml_up);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_gprs_mode);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_rf_state);
diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c
index f5f265f..674813c 100644
--- a/src/libbsc/bsc_init.c
+++ b/src/libbsc/bsc_init.c
@@ -37,6 +37,8 @@
#include <osmocom/bsc/e1_config.h>
#include <osmocom/bsc/common_bsc.h>
#include <osmocom/bsc/pcu_if.h>
+
+#include <time.h>
#include <limits.h>
#include <stdbool.h>
@@ -98,6 +100,24 @@
return 0;
}
+unsigned long long bts_uptime(const struct gsm_bts *bts)
+{
+ struct timespec tp;
+
+ if (!bts->uptime || !bts->oml_link) {
+ LOGP(DNM, LOGL_ERROR, "BTS %u OML link uptime unavailable\n", bts->nr);
+ return 0;
+ }
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
+ LOGP(DNM, LOGL_ERROR, "BTS %u uptime computation failure: %s\n", bts->nr, strerror(errno));
+ return 0;
+ }
+
+ /* monotonic clock helps to ensure that the conversion is valid */
+ return difftime(tp.tv_sec, bts->uptime);
+}
+
static int rsl_si(struct gsm_bts_trx *trx, enum osmo_sysinfo_type i, int si_len)
{
struct gsm_bts *bts = trx->bts;
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 43cb282..ca29b4c 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -236,8 +236,6 @@
{
struct pchan_load pl;
unsigned long long sec;
- struct timespec tp;
- int rc;
vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
"BSIC %u (NCC=%u, BCC=%u) and %u TRX%s",
@@ -309,17 +307,11 @@
bts->paging.available_slots, VTY_NEWLINE);
if (is_ipaccess_bts(bts)) {
vty_out(vty, " OML Link state: %s", get_model_oml_status(bts));
- if (bts->oml_link) {
- if (bts->uptime) {
- rc = clock_gettime(CLOCK_MONOTONIC, &tp);
- if (rc == 0) { /* monotonic clock helps to ensure that conversion below is valid */
- sec = (unsigned long long)difftime(tp.tv_sec, bts->uptime);
- vty_out(vty, " %llu days %llu hours %llu min. %llu sec.%s",
- OSMO_SEC2DAY(sec), OSMO_SEC2HRS(sec), OSMO_SEC2MIN(sec),
- sec % 60, VTY_NEWLINE);
- }
- }
- }
+ sec = bts_uptime(bts);
+ if (sec)
+ vty_out(vty, " %llu days %llu hours %llu min. %llu sec.%s",
+ OSMO_SEC2DAY(sec), OSMO_SEC2HRS(sec), OSMO_SEC2MIN(sec), sec % 60,
+ VTY_NEWLINE);
} else {
vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
e1isl_dump_vty(vty, bts->oml_link);
--
To view, visit https://gerrit.osmocom.org/4197
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec405aa949d6a38a9c8e64cd7ee4b49fd416835d
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder