Upgrading BMON to Python 3 in Webfaction

This assumes you have advanced knowledge of BMON system administration. This how to is an essence of the steps necessary but this is not a step-by-step approach, if you’re lost review this.

  • Login to your webfaction account

  • Under Applications, install most recent Python 3.7 / Django release from Webfaction Control Panel. Name the application: django_bmon3

  • SSH into your webfaction server and cd to webapps/django_bmon3

  • Delete myproject.

  • git clone https://github.com/alanmitchell/bmon.git

  • Then fix references according to: https://bmon-documentation.readthedocs.io/en/latest/how-to-install-BMON-on-a-web-server.html#installing-the-bmon-project

  • Do: pip3.7 install --user -r requirements.txt.

    • Remember the pip3.7
    • if you have trouble installing numpy via requirements.txt run pip3.7 uninstall numpy it may take several attempts
  • From the Old BMON application, copy over: bmon.sqlite, and settings.py to your New BMON.

  • Edit your New BMON settings.py file:

    • to fix an import in settings.py to make it Python 3 compatible, the last line of the file before any customizations should be from .settings_common import *

    • Remove the BMSAPP_FOOTER setting

    • Change BMSAPP_NAV_LINKS to:

      BMSAPP_NAV_LINKS = (('Map', 'map'),
                ('Graphs', 'reports', True),
                ('Energy Reports', 'energy-reports'),
                ('Custom Reports', 'custom-reports'),
                ('Training', 'training-anthc'),
                ('Sys Admin', 'admin-reports'),
                )
      
  • Copy over phantomjs.exe from Old BMON to bmon/bmsapp/calcs, if this file is present in the old app.

  • Run: ./manage.py migrate (if running it with python, run python3.7 manage.py migrate.)

  • Run: ./manage.py collectstatic

  • Edit your Cron crontab -e

    • Comment out the Start Cron job related to old application.
  • Stop Old application and copy over bms_data.sqlite to your New BMON so that reading data is up to date.

  • In Webfaction control panel, point BMON website at the New BMON application.

  • Start the new application.

  • Get CRON jobs pointed at the new directory: “runscript main_cron”

  • Comment out cron jobs related to old application.

  • Test the http redirect.

  • Make sure cron jobs run by looking a weather sensor after the 15 or 45 minute point.

  • If using Ecobee sensors, make sure the Ecobee script is working.

  • Watch error log.

    • if something isn’t looking right but you’re not seeing it in the error log, consider modifying your settings.py file to set BMSAPP_LOG_LEVEL to logging.DEBUG for a more verbose error log.
  • If you have custom reports, remove the: style="width: 930px" from the embedded links in all of the Custom Reports. Otherwise, plots are not responsive and do not shrink with the window.

  • In Custom Reports, replace any select_sensor query parameters for Time Series charts with select_sensor_multi.

  • Find links in Alerts and update the select_sensor parameter to select_sensor_multi.

  • Eventually delete files from old application.

A note about running two instances of the same BMON (like Old BMON and New BMON above)

If Old BMON has active alerts and you plan on running both Old and New simultaneously (see note below), which is possible but not recommended, you will want to disable all alerts on Old BMON after New has been installed and is active. Disabling the alerts before migration means having to enable them all again on the new system so it is recommended you do this after.

If you do not do this you may receive erroneous alerts which may be hung in the system and no one likes getting paged in the middle of the night for no reason, for fun.

Why would I leave 2 instances of the same BMON running? Perhaps for a third party or primary dashboard user to verify everything has copied over correctly who needs access to both versions concurrently.