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/.
Max gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/1630 Use oml-alert CTRL command for temp report Send temperature reports via OML alert facility exposed by CTRL protocol. Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Related: OS#1615 --- M src/osmo-bts-sysmo/Makefile.am M src/osmo-bts-sysmo/misc/sysmobts_mgr.c M src/osmo-bts-sysmo/misc/sysmobts_mgr.h M src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c 4 files changed, 31 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/1630/1 diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index 8e39a3a..7b27e70 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -29,7 +29,7 @@ misc/sysmobts_mgr_temp.c \ misc/sysmobts_mgr_calib.c \ eeprom.c -sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCTRL_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) +sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c eeprom.c sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index f126db2..88bd9b1 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -36,6 +36,8 @@ #include <osmocom/vty/telnet_interface.h> #include <osmocom/vty/logging.h> #include <osmocom/vty/ports.h> +#include <osmocom/ctrl/control_if.h> +#include <osmocom/ctrl/ports.h> #include "misc/sysmobts_misc.h" #include "misc/sysmobts_mgr.h" @@ -246,7 +248,7 @@ int main(int argc, char **argv) { int rc; - + struct ctrl_handle *ch; tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); msgb_talloc_ctx_init(tall_mgr_ctx, 0); @@ -294,7 +296,8 @@ exit(3); /* Initialize the temperature control */ - sysmobts_mgr_temp_init(&manager); + ch = ctrl_interface_connect(NULL, "localhost", OSMO_CTRL_PORT_BTS, NULL); + sysmobts_mgr_temp_init(&manager, ch); if (sysmobts_mgr_calib_init(&manager) != 0) exit(3); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h index b393c38..6b0f509 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h @@ -3,7 +3,7 @@ #include <osmocom/vty/vty.h> #include <osmocom/vty/command.h> - +#include <osmocom/ctrl/control_if.h> #include <osmocom/core/select.h> #include <osmocom/core/timer.h> @@ -108,7 +108,8 @@ int sysmobts_mgr_vty_init(void); int sysmobts_mgr_parse_config(struct sysmobts_mgr_instance *mgr); int sysmobts_mgr_nl_init(void); -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr); +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_handle *ch); const char *sysmobts_mgr_temp_get_state(enum sysmobts_temp_state state); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c index 34af2ab..8e9f0b8 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c @@ -185,9 +185,21 @@ } static void sysmobts_mgr_temp_handle(struct sysmobts_mgr_instance *manager, - int critical, int warning) + struct ctrl_handle *ch, int critical, + int warning) { int new_state = next_state(manager->state, critical, warning); + struct ctrl_cmd *rep = ctrl_cmd_create(tall_mgr_ctx, CTRL_TYPE_SET); + if (!rep) { + LOGP(DTEMP, LOGL_ERROR, "OML alert creation failed.\n"); + } else { + rep->id = "42"; + rep->variable = "oml-alert"; + rep->value = "MGR TEMP CRAP!"; + ctrl_cmd_send_to_all(ch, rep); + talloc_free(rep); + LOGP(DTEMP, LOGL_ERROR, "OML alert sent.\n"); + } /* Nothing changed */ if (new_state < 0) @@ -213,7 +225,7 @@ }; } -static void temp_ctrl_check() +static void temp_ctrl_check(struct ctrl_handle *ch) { int rc; int warn_thresh_passed = 0; @@ -275,20 +287,23 @@ } } - sysmobts_mgr_temp_handle(s_mgr, crit_thresh_passed, warn_thresh_passed); + sysmobts_mgr_temp_handle(s_mgr, ch, crit_thresh_passed, + warn_thresh_passed); } -static void temp_ctrl_check_cb(void *unused) +static void temp_ctrl_check_cb(void *ch) { - temp_ctrl_check(); + temp_ctrl_check(ch); /* Check every two minutes? XXX make it configurable! */ osmo_timer_schedule(&temp_ctrl_timer, 2 * 60, 0); } -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr) +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_handle *ch) { s_mgr = mgr; temp_ctrl_timer.cb = temp_ctrl_check_cb; - temp_ctrl_check_cb(NULL); + temp_ctrl_timer.data = ch; + temp_ctrl_check_cb(ch); return 0; } -- To view, visit https://gerrit.osmocom.org/1630 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de>