On Thu, Apr 10, 2014 at 12:25:37PM +0200, Alvaro Neira Ayuso wrote:
From: Álvaro Neira Ayuso <anayuso(a)sysmocom.de>
Added the vty support for configuring the parameter for using the
OML report in manager when we have anomalous temperature.
Signed-off-by: Alvaro Neira Ayuso <anayuso(a)sysmocom.de>
---
[changes in v3]
* Fixed some coding style errors
* Changed the port of the sysmo-mgr vty because the previous was already being
used
doc/examples/osmobts-mgr.cfg | 30 ++++
src/osmo-bts-sysmo/Makefile.am | 5 +-
src/osmo-bts-sysmo/misc/sysmobts_mgr.c | 43 ++++-
src/osmo-bts-sysmo/misc/sysmobts_mgr.h | 16 ++
src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c | 250 ++++++++++++++++++++++++++++
5 files changed, 341 insertions(+), 3 deletions(-)
create mode 100644 doc/examples/osmobts-mgr.cfg
create mode 100644 src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c
diff --git a/doc/examples/osmobts-mgr.cfg b/doc/examples/osmobts-mgr.cfg
new file mode 100644
index 0000000..f1c4e8e
--- /dev/null
+++ b/doc/examples/osmobts-mgr.cfg
@@ -0,0 +1,30 @@
+!
+! SysmoMgr (0.3.0.137-7576) configuration saved from vty
+!!
+!
+log stderr
+ logging filter all 1
+ logging color 1
+ logging timestamp 0
+ logging level all everything
+ logging level temp info
+ logging level fw info
+ logging level find info
+ logging level lglobal notice
+ logging level llapd notice
+ logging level linp notice
+ logging level lmux notice
+ logging level lmi notice
+ logging level lmib notice
+ logging level lsms notice
+!
+line vty
+ no login
+!
+config-mgr
+ temp-warn-board -30 50
+ temp-sever-board -50 80
+ temp-warn-pa -30 50
+ temp-sever-pa -50 80
+ pwr-action 1 1 0
+ pwr-max-transmiter 32
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index 1c08af3..b4b7de7 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -22,8 +22,9 @@ l1fwd_proxy_LDADD = $(top_builddir)/src/common/libbts.a
$(COMMON_LDADD)
sysmobts_mgr_SOURCES = \
misc/sysmobts_mgr.c misc/sysmobts_misc.c \
- misc/sysmobts_par.c misc/sysmobts_nl.c
-sysmobts_mgr_LDADD = $(LIBOSMOCORE_LIBS)
+ misc/sysmobts_par.c misc/sysmobts_nl.c \
+ misc/sysmobts_mgr_vty.c
+sysmobts_mgr_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS)
sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.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 7a50bdc..2635c5f 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -57,6 +57,24 @@ static int fd_unix = -1;
void *tall_mgr_ctx;
static struct sbts2050_config_info confinfo;
+static struct sysmobts_mgr_instance sysmobts_mgr_inst = {
+ .config_file = "osmobts-mgr.cfg",
+};
+
+const char *sysmomgr_copyright =
+ "(C) 2012 by Harald Welte <laforge(a)gnumonks.org>\r\n"
+ "(C) 2014 by Holger Hans Peter Freyther\r\n"
+ "License AGPLv3+: GNU AGPL version 2 or later
<http://gnu.org/licenses/agpl-3.0.html>\r\n"
+ "This is free software: you are free to change and redistribute it.\r\n"
+ "There is NO WARRANTY, to the extent permitted by law.\r\n";
+
+static struct vty_app_info vty_info = {
+ .name = "SysmoMgr",
+ .version = PACKAGE_VERSION,
+ .go_parent_cb = mgr_vty_go_parent,
+ .is_config_node = mgr_vty_is_config_node,
+};
+
/* every 6 hours means 365*4 = 1460 EEprom writes per year (max) */
#define TEMP_TIMER_SECS (6 * 3600)
@@ -217,13 +235,14 @@ static void print_help(void)
printf(" -s Disable color\n");
printf(" -d CAT enable debugging\n");
printf(" -D daemonize\n");
+ printf(" -c Specify the filename of the config file\n");
}
static int parse_options(int argc, char **argv)
{
int opt;
- while ((opt = getopt(argc, argv, "nhsd:")) != -1) {
+ while ((opt = getopt(argc, argv, "nhsd:c:")) != -1) {
switch (opt) {
case 'n':
no_eeprom_write = 1;
@@ -240,6 +259,9 @@ static int parse_options(int argc, char **argv)
case 'D':
daemonize = 1;
break;
+ case 'c':
+ sysmobts_mgr_inst.config_file = optarg;
+ break;
default:
return -1;
}
@@ -443,6 +465,25 @@ int main(int argc, char **argv)
if (rc < 0)
exit(2);
+ vty_info.copyright = sysmomgr_copyright;
+ vty_init(&vty_info);
+ logging_vty_add_cmds(&mgr_log_info);
+
+ sysmobts_mgr_vty_init();
+
+ rc = sysmobts_mgr_parse_config(sysmobts_mgr_inst.config_file,
+ &confinfo);
+ if (rc < 0) {
+ LOGP(DFIND, LOGL_FATAL, "Cannot parse config file\n");
+ exit(2);
IIRC these error values indicate from which point we have failed. So
this should be exit(3).