X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=monitor-server.init;h=544b47e9526731772070e527ea1bc6b550b13884;hp=ee7c469b99d7e33a86b9e8c698c167aad1db1159;hb=HEAD;hpb=ce9101bfa7720c131a982220f2905e4439b324fc diff --git a/monitor-server.init b/monitor-server.init index ee7c469..544b47e 100644 --- a/monitor-server.init +++ b/monitor-server.init @@ -18,6 +18,8 @@ local_config=/etc/planetlab/configs/site.xml MONITORPATH=/usr/share/monitor +WEB_ROOT_PATH=web/MonitorWeb/monitorweb +WEB_XML_PATH=static/xml # Be verbose set -x @@ -31,8 +33,8 @@ pghba_conf=$PGDATA/pg_hba.conf export PGPORT=$PLC_DB_PORT -MONITOR_DB_USER="monitoruser" -MONITOR_DB_NAME="monitor" +MONITOR_DB_USER=$PLC_MONITOR_DBUSER +MONITOR_DB_NAME=$PLC_MONITOR_DBNAME WROTE_PG_CONFIG= @@ -40,10 +42,45 @@ if [ -z "$PLC_MONITOR_IP" ] ; then PLC_MONITOR_IP=$( gethostbyname $PLC_MONITOR_HOST ) fi -function check_monitor_schema_and_data() +function update_config () { - # NOTE: call create_all() to setup the database from the info model. - python -c "from monitor.database.info.model import *; from elixir import create_all; create_all()" + pattern=$1 + with=$2 + file=$3 + sed -i -e "s/$pattern/$with/g" $file +} +function apply_template () +{ + TEMPLATE=$1 + DESTFILE=$2 + + tmp_file=$(mktemp) + cp $TEMPLATE $tmp_file + + update_config PLC_NAME "$PLC_NAME" $tmp_file + update_config PLC_WWW_HOSTNAME $PLC_WWW_HOST $tmp_file + update_config MONITOR_HOSTNAME $PLC_MONITOR_HOST $tmp_file + + cp $tmp_file $DESTFILE + rm -f $tmp_file +} + +function check_gadget_config () +{ + for input_file in $MONITORPATH/$WEB_ROOT_PATH/$WEB_XML_PATH/*.in ; do + output_file=$MONITORPATH/$WEB_ROOT_PATH/$WEB_XML_PATH/`basename $input_file | sed -e 's/.in\$//'` + if [ $input_file -nt $output_file ] ; then + apply_template $input_file $output_file + fi + done +} + +function check_monitor_schema_and_data_init() +{ + # from monitor.functions + check_monitor_schema_and_data + + $MONITORPATH/config.d/init-bootman-sequence.py } function check_monitor_conf () @@ -61,21 +98,16 @@ EOF if [ ! -f ${MONITOR_CONFIG} ] ; then cat < ${MONITOR_CONFIG} [monitorconfig] -RT_DB_HOST=rt.planet-lab.org -RT_DB_USER= -RT_DB_PASSWORD= -RT_DB_NAME= - # RT Web user account -RT_WEB_SERVER=https://rt.planet-lab.org/ -RT_WEB_TOOLS_PATH= -RT_WEB_USER= -RT_WEB_PASSWORD= +RT_WEB_SERVER=http://${PLC_RT_HOST}/ +RT_WEB_TOOLS_PATH=/usr/bin/ +RT_WEB_USER=${PLC_RT_WEB_USER} +RT_WEB_PASSWORD=${PLC_RT_WEB_PASSWORD} RT_WEB_DEBUG=0 -RT_QUEUE= +RT_QUEUE=${PLC_MONITOR_RT_QUEUE} # PLC admin account -API_SERVER=https://${PLC_BOOT_HOST}/PLCAPI/ +API_SERVER=https://${PLC_API_HOST}:${PLC_API_PORT}/PLCAPI/ API_AUTH_USER=${PLC_MONITOR_EMAIL} API_AUTH_PASSWORD=${PLC_MONITOR_DBPASSWORD} @@ -91,21 +123,23 @@ MONITOR_IP=${PLC_MONITOR_IP} PLC_WWW_HOSTNAME=${PLC_WWW_HOST} PLC_NAME=${PLC_NAME} -# used for debug mode -email= - +email=${PLC_MONITOR_EMAIL} # all messages will appear to be from this address from_email=${PLC_MONITOR_EMAIL} - # a separate address for support messages support_email=${PLC_MAIL_SUPPORT_ADDRESS} - # mailing list copied on all out-going messages -cc_email= +cc_email=${PLC_MONITOR_CC_EMAIL} +exception_email=${PLC_MONITOR_CC_EMAIL} + +# these are reserved values +RT_DB_HOST=${PLC_RT_HOST} +RT_DB_USER= +RT_DB_PASSWORD= +RT_DB_NAME= [monitordatabase] -monitor_dburi=postgres://${MONITOR_DB_USER}:${PLC_MONITOR_DBPASSWORD}@localhost:5432/${MONITOR_DB_NAME} -zabbix_dburi=postgres://${ZABBIX_DB_USER}:${PLC_MONITOR_DBPASSWORD}@localhost:5432/${ZABBIX_DB_NAME} +monitor_dburi=postgres://${MONITOR_DB_USER}:${PLC_MONITOR_DBPASSWORD}@${PLC_MONITOR_DBHOST}:5432/${MONITOR_DB_NAME} cachetime=60 @@ -113,6 +147,7 @@ cachetime=60 [commandline] cachecalls=True embedded=False +zabbix_enabled=False echo=False debug=False @@ -150,6 +185,7 @@ function create_httpd_conf () # NOTE: redirect path without trailing '/' to path with. Favor SSL. Redirect /monitor https://${PLC_MONITOR_HOST}:${PLC_WWW_SSL_PORT}/monitor/ +#RedirectMatch ^/$ https://${PLC_MONITOR_HOST}:${PLC_WWW_SSL_PORT}/monitor # NOTE: this directive strips '/monitor/' from the requested path and pastes # the remaining part to the end of the ProxyPass url below. All TG urls @@ -172,6 +208,8 @@ function start_tg_server () { stop_tg_server pushd ${MONITORPATH}/web/MonitorWeb/ + mkdir -p /var/lib/monitor/monitorweb/ + cp /var/log/monitorweb.log /var/lib/monitor/monitorweb/`date +%Y-%m-%d-%H-%M`-monitorweb.log ./start-monitorweb.py ${MONITORPATH}/web/MonitorWeb/prod.cfg &> /var/log/monitorweb.log & popd } @@ -199,6 +237,8 @@ case "$1" in # WRITE default /etc/monitor.conf check_monitor_conf + check_gadget_config + if [ -n "$WROTE_PG_CONFIG" ] ; then # NOTE: restart db to enable access by users granted above. service plc restart postgresql @@ -207,7 +247,7 @@ case "$1" in dialog "$MESSAGE" fi - check_monitor_schema_and_data + check_monitor_schema_and_data_init # create /etc/httpd/conf.d/monitorweb.conf create_httpd_conf