summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-21 16:15:32 +0200
committerMax <msuraev@sysmocom.de>2017-09-27 10:54:11 +0000
commitf79eeca1095fb9493bf74c1fface8e70d61250e7 (patch)
treec31ce9a762cde7db0670f8784d9d57175f3df1e2
parent3ae8682f974058970fa564f09a34a51e867b896b (diff)
Show OML link uptime in vty
Save the time when OML link to BTS was established and show it in vty. That's useful when troubleshooting issues like periodic/sporadic BTS restart. Related: SYS#3889 Change-Id: I9e4e8504afe8ca467b68d41826f61654e24d9600
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h2
-rw-r--r--openbsc/src/libbsc/bsc_vty.c20
-rw-r--r--openbsc/src/libbsc/bts_ipaccess_nanobts.c6
-rw-r--r--openbsc/src/libbsc/e1_config.c6
4 files changed, 31 insertions, 3 deletions
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 6b2269e1b..c19b1255f 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -715,6 +715,8 @@ struct gsm_bts {
struct gsm_e1_subslot oml_e1_link;
uint8_t oml_tei;
struct e1inp_sign_link *oml_link;
+ /* when OML link was established */
+ time_t uptime;
/* Abis network management O&M handle */
struct abis_nm_h *nmh;
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index c6ff6d547..0d5377d6a 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
+#include <time.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
@@ -237,6 +238,9 @@ static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
{
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",
@@ -307,8 +311,20 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
paging_pending_requests_nr(bts),
bts->paging.available_slots, VTY_NEWLINE);
if (is_ipaccess_bts(bts)) {
- vty_out(vty, " OML Link state: %s.%s",
- bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
+ vty_out(vty, " OML Link state: ");
+ if (bts->oml_link) {
+ vty_out(vty, "connected");
+ 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);
+ }
+ }
+ } else
+ vty_out(vty, "disconnected.%s", VTY_NEWLINE);
} else {
vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
e1isl_dump_vty(vty, bts->oml_link);
diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
index a1bde778f..64eb4f24a 100644
--- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c
+++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
@@ -20,6 +20,7 @@
*/
#include <arpa/inet.h>
+#include <time.h>
#include <osmocom/gsm/tlv.h>
@@ -364,6 +365,7 @@ void ipaccess_drop_oml(struct gsm_bts *bts)
e1inp_sign_link_destroy(bts->oml_link);
bts->oml_link = NULL;
+ bts->uptime = 0;
/* we have issues reconnecting RSL, drop everything. */
llist_for_each_entry(trx, &bts->trx_list, list)
@@ -395,6 +397,8 @@ ipaccess_sign_link_up(void *unit_data, struct e1inp_line *line,
struct gsm_bts *bts;
struct ipaccess_unit *dev = unit_data;
struct e1inp_sign_link *sign_link = NULL;
+ struct timespec tp;
+ int rc;
bts = find_bts_by_unitid(bsc_gsmnet, dev->site_id, dev->bts_id);
if (!bts) {
@@ -423,6 +427,8 @@ ipaccess_sign_link_up(void *unit_data, struct e1inp_line *line,
e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML - 1],
E1INP_SIGN_OML, bts->c0,
bts->oml_tei, 0);
+ rc = clock_gettime(CLOCK_MONOTONIC, &tp);
+ bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need sub-second precision for uptime */
break;
case E1INP_SIGN_RSL: {
struct e1inp_ts *ts;
diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c
index d57dec57e..92b247564 100644
--- a/openbsc/src/libbsc/e1_config.c
+++ b/openbsc/src/libbsc/e1_config.c
@@ -20,7 +20,7 @@
#include <string.h>
#include <errno.h>
-
+#include <time.h>
#include <netinet/in.h>
#include <openbsc/gsm_data.h>
@@ -160,6 +160,8 @@ int e1_reconfig_bts(struct gsm_bts *bts)
struct e1inp_line *line;
struct e1inp_sign_link *oml_link;
struct gsm_bts_trx *trx;
+ struct timespec tp;
+ int rc;
DEBUGP(DLMI, "e1_reconfig_bts(%u)\n", bts->nr);
@@ -201,6 +203,8 @@ int e1_reconfig_bts(struct gsm_bts *bts)
if (bts->oml_link)
e1inp_sign_link_destroy(bts->oml_link);
bts->oml_link = oml_link;
+ rc = clock_gettime(CLOCK_MONOTONIC, &tp);
+ bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need sub-second precision for uptime */
llist_for_each_entry(trx, &bts->trx_list, list)
e1_reconfig_trx(trx);