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
This commit is contained in:
parent
e1ceb6f767
commit
25cc407c5b
|
@ -657,6 +657,8 @@ extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1];
|
|||
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);
|
||||
|
||||
|
|
|
@ -240,6 +240,21 @@ static int get_bts_oml_conn(struct ctrl_cmd *cmd, void *data)
|
|||
|
||||
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 @@ int bsc_base_ctrl_cmds_install(void)
|
|||
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);
|
||||
|
||||
|
|
|
@ -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 @@ int bsc_shutdown_net(struct gsm_network *net)
|
|||
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;
|
||||
|
|
|
@ -236,8 +236,6 @@ 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",
|
||||
|
@ -309,17 +307,11 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue