added httpd/conf.d/monitorweb.conf to /etc/plc.d/monitor.init
authorStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 3 Dec 2008 19:03:27 +0000 (19:03 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 3 Dec 2008 19:03:27 +0000 (19:03 +0000)
      and tg server start up.
template improvements otherwise.

monitor-server.init
pcucontrol/reboot.py
web/MonitorWeb/monitorweb/controllers.py
web/MonitorWeb/monitorweb/templates/nodelist.kid
web/MonitorWeb/prod.cfg
web/monitorweb-httpd.conf

index dc984ad..c477c89 100644 (file)
@@ -231,6 +231,68 @@ EOF
        fi
 }
 
+function create_httpd_conf ()
+{
+       MONITOR_HTTP_CONF=/etc/httpd/conf.d/monitorweb.conf
+
+       if [ ! -f ${MONITOR_HTTP_CONF} ] ; then
+               # note: we need to either start this script before httpd, or always
+               # restart httpd, since there's no way to know beyond file's existence
+               # whether the values have changed or not.
+               WROTE_HTTP_CONFIG="true"
+       fi
+
+       # TODO: make http port configurable.
+       # TODO: make proxy port configurable.
+
+       cat <<EOF > ${MONITOR_HTTP_CONF}
+NameVirtualHost ${PLC_MONITOR_IP}:80
+
+<VirtualHost ${PLC_MONITOR_IP}:80>
+    ServerName ${PLC_MONITOR_HOST}
+    ServerAdmin ${PLC_MONITOR_EMAIL}
+    UseCanonicalName Off
+    ServerSignature Off
+
+    DocumentRoot ${MONITORPATH}/web/MonitorWeb/monitorweb
+
+    <Directory "${MONITORPATH}/web/MonitorWeb/monitorweb">
+        Options Indexes FollowSymLinks
+        AllowOverride None
+        Order allow,deny
+        Allow from all
+    </Directory>
+
+    #LogLevel debug
+    Errorlog /var/log/httpd/monitorwebapp-error_log
+    Customlog /var/log/httpd/monitorwebapp-access_log common
+
+    AddDefaultCharset utf-8
+
+    #NOTE: This doesn't work as expected.
+    #  Load everything out of the DocumentRoot that is static
+    #  ProxyPass /monitor/static !
+
+    ProxyPass /tg_js http://127.0.0.1:8080/tg_js
+    ProxyPassReverse /tg_js http://127.0.0.1:8080/tg_js
+
+    ProxyPass /monitor http://127.0.0.1:8080
+    ProxyPassReverse /monitor http://127.0.0.1:8080
+
+    ProxyPreserveHost On
+    ProxyRequests Off
+
+</VirtualHost>
+EOF
+}
+
+function start_tg_server ()
+{
+       pushd ${MONITORPATH}/web/MonitorWeb/
+       ./start-monitorweb.py ${MONITORPATH}/web/MonitorWeb/prod.cfg &> /var/log/monitorweb.log
+       popd
+}
+
 function check_zab_server ()
 {
        ZABBIXCFG=/etc/zabbix
@@ -308,6 +370,7 @@ case "$1" in
                if [ -n "$WROTE_PG_CONFIG" ] ; then
                        # NOTE: restart db to enable access by users granted above.
                        service plc restart postgresql
+                       service plc restart httpd
                fi
 
                check_zabbix_schema_and_data
@@ -316,6 +379,14 @@ case "$1" in
                # WRITE default /etc/monitor.conf
                check_monitor_conf
 
+               # create /etc/httpd/conf.d/monitorweb.conf
+               create_httpd_conf
+               if [ -n "$WROTE_HTTP_CONFIG" ] ; then
+                       # NOTE: restart web server to enable access web cfg
+                       service plc restart httpd
+               fi
+               start_tg_server
+
                # START zabbix services.  SETUP default config files.
                check_zab_server
                check_zab_agentd
index 2e6d2d5..5b322d3 100755 (executable)
@@ -1054,6 +1054,7 @@ class ManualPCU(PCUControl):
                        # TODO: send email message to monitor admin requesting manual
                        # intervention.  This should always be an option for ridiculous,
                        # custom jobs.
+                       pass
                return 0
 
 ### rebooting european BlackBox PSE boxes
index 2d7f23e..db3fbd8 100644 (file)
@@ -50,6 +50,7 @@ class Root(controllers.RootController):
                query = []
                filtercount = {'DOWN' : 0, 'BOOT': 0, 'DEBUG' : 0, 'neverboot' : 0, 'pending' : 0, 'all' : 0}
                for node in fbquery:
+                       # NOTE: reformat some fields.
                        if node.plc_pcuid:
                                pcu = FindbadPCURecord.get_latest_by(plc_pcuid=node.plc_pcuid).first()
                                if pcu:
@@ -67,6 +68,11 @@ class Root(controllers.RootController):
                        else:
                                node.kernel = ""
 
+                       try:
+                               node.loginbase = site_id2lb[node.plc_node_stats['site_id']]
+                       except:
+                               node.loginbase = "unknown"
+
 
                        # NOTE: count filters
                        if node.observed_status != 'DOWN':
index 5e5dec1..c9ec477 100644 (file)
@@ -5,7 +5,8 @@ from monitor.util import diff_time
 from time import mktime
 ?>
 <html py:layout="'sitemenu.kid'"
-      xmlns:py="http://purl.org/kid/ns#">
+      xmlns:py="http://purl.org/kid/ns#"
+         xmlns:mochi="http://www.mochi.org">
 
   <div py:match="item.tag == 'content'">
        <table width="100%">
@@ -22,9 +23,11 @@ from time import mktime
                <tbody>
                <tr>
                <td colspan="5">
-               <table id="sub-table" border="1" width="100%">
+               <table id="sortable_table" class="datagrid" border="1" width="100%">
                        <thead>
                                <tr>
+                                       <th mochi:format="int"></th>
+                                       <th mochi:format="str">Site</th>
                                        <th>Hostname</th>
                                        <th>ping</th>
                                        <!--th>ssh</th-->
@@ -36,6 +39,8 @@ from time import mktime
                        </thead>
                        <tbody>
                                <tr py:for="i,node in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
+                                       <td></td>
+                                       <td><a href="">${node.loginbase}</a></td>
                                  <td nowrap="true" py:content="node.hostname"></td>
                                  <td py:content="node.ping_status"></td>
                                  <!--td py:content="node.ssh_status"></td-->
index f1e675b..91de6f8 100644 (file)
@@ -32,11 +32,12 @@ autoreload.package="monitorweb"
 
 server.socket_host="127.0.0.1"
 server.socket_port=8080
-server.webpath="/monitor/"
 base_url_filter.on = False
-base_url_filter.base_url = "http://127.0.0.1:8080/monitor"
 base_url_filter.use_x_forwarded_host = True
 
+#server.webpath="/monitor/"
+#base_url_filter.base_url = "http://127.0.0.1:8080/monitor"
+
 # Auto-Reload after code modification
 # autoreload.on = True
 
index ee84b73..a1935ae 100644 (file)
@@ -6,9 +6,9 @@ NameVirtualHost 128.112.139.116:80
     UseCanonicalName Off
     ServerSignature Off
 
-    DocumentRoot /usr/share/monitor/tgweb/MonitorWeb/monitorweb
+    DocumentRoot /usr/share/monitor/web/MonitorWeb/monitorweb
 
-    <Directory "/usr/share/monitor/tgweb/MonitorWeb/monitorweb">
+    <Directory "/usr/share/monitor/web/MonitorWeb/monitorweb">
         Options Indexes FollowSymLinks
         AllowOverride None
         Order allow,deny
@@ -20,13 +20,16 @@ NameVirtualHost 128.112.139.116:80
 
     AddDefaultCharset utf-8
 
-    # Load everything out of the DocumentRoot that is static
-    ProxyPass /monitor/static !
+    #NOTE: This doesn't work as expected.
+    #  Load everything out of the DocumentRoot that is static
+    #  ProxyPass /monitor/static !
+
+    ProxyPass /tg_js http://127.0.0.1:8080/tg_js
+    ProxyPassReverse /tg_js http://127.0.0.1:8080/tg_js
+
+    ProxyPass /monitor http://127.0.0.1:8080
+    ProxyPassReverse /monitor http://127.0.0.1:8080
 
-    ProxyPass /monitor http://127.0.0.1:8080/
-    ProxyPassReverse /monitor http://127.0.0.1:8080/
-    ProxyPass /monitor/ http://127.0.0.1:8080/
-    ProxyPassReverse /monitor/ http://127.0.0.1:8080/
     ProxyPreserveHost On
     ProxyRequests Off