Service Status Website
Following guide describes configuration of separate website which can integrate information about different services required by Historian and their functionality. This website can provide status information back to the Historian.
Basic deployment
Following code ensures that Apache has built-in module headers enabled and install Python package manager (pip) as well as Python MQTT Paho Client, which is needed for full functionality. These packages are generally being used (by TXPMQTT part, etc.), so you may expect them to be already installed.
sudo a2enmod headers sudo apt-get install python-pip sudo pip install mysql-connector sudo pip install paho-mqtt
Note: On some server we have experienced an error symbol SSLv2_client_method, version OPENSSL_1.0.0 not defined in file libssl.so.1.0.0 with link time reference, which has been solved by doing sudo apt-get update and sudo apt-get upgrade.
Afterwards create an Apache configuration file (eg. /etc/apache/sites-available/004-status.conf) with following content:
<VirtualHost *:8084> DocumentRoot /var/www/status <Directory /var/www/status> Header set Access-Control-Allow-Origin "*" <Files ~ "\.py"> Order allow,deny Deny from all </Files> </Directory> </VirtualHost>
where /var/www/status is a folder where you have unpacked the content of archive from here. In the example, the website is to be started at local ip address and port 8084. Modify this to suit your needs. However same configuration should be added also into the file /etc/apache/ports.conf
Listen 8084
Afterwards you may activate the website and restart Apache
sudo a2ensite 004-status sudo service apache2 restart
In order to schedule regular service checks, it is needed to include
sudo crontab -e
*/5 * * * * /var/www/status/checkStatus.py
Configuration
The status application should be properly configured in order to know what services should be checked. The configuration is in file /var/www/status/confStatus.py
#!/usr/bin/env python selectedChecks = ['MQTT_TXP', 'VMOD_TAVS_PENDING', 'VMOD_RUNNING', 'VMOD_SU', 'MYSQL_CONNECT', 'HISTORIAN_STATUS'] # configuration for individual checks pendingTavsFile = '/volumes/data/vmodd/pendigtav.txt' vmodRunningFile = '/volumes/data/vmodd/status.txt' suHostsFile = '/volumes/data/vmodd/sustatus.txt' statusFile = '/var/www/status/status.json' historianBaseUrl = 'http://localhost' mqttHost = '172.17.90.5' mqttPort = '22883' mqttServiceTopicA = 'service/mqtta/#' mqttServiceTopicB = 'service/mqttb/#' mysqlConfig = { 'user': 'inflex', 'password': '/1inflex', 'host': '127.0.0.1', 'database': 'C004V020', 'raise_on_warnings': True, }
Variable selectedChecks lists all checks you want to include in the status. Following variables provide additional configuration for VMOD (pendingTavsFile, vmodRunningFile, suHostsFile), Historian (historianBaseUrl), MySQL (mysqlConfig) and MQTT (mqttHost, mqttPort, mqttServiceTopicA, mqttServiceTopicB).
Note: Only Historian v2.0.4 (=44) and later provide required communication means.
Variable statusFile contains the name of the resulting json file (usually does not needs a change).
Now you should be able to open the status website in your browser.
Historian Integration
In order to insert a link into Historian, you simply include the link inside its instance.xml (usually available on /var/www/poweranalyzer/App_Data) configuration as any other link. For detailed explanation of the configuration please see Server App Configuration.
<relatedLinks> <relatedLink name="STATUS" defaultUrl="http://192.168.70.35:8084" target="_blank" addCssClass="serviceLink" /> </relatedLinks>
Please note the attribute addCssClass (introduced in Historian v2.0.4) which allows the website to understand what is this link intended for. Based on this attribute, client JavaScript tries to retrieve the status.json file available within the status website and highlight the link if there are some errors or warnings that should be inspected.
Miscellaneous
In case the VMOD status files are not on the same server as status application, one may configure automatic synchronization of the remote files to a local folder.
First you need to create an SSH key (WITHOUT PASSPHRASE) which will be used to access remote computer automatically (please note the command are not prefixed with sudo).
ssh-keygen -t rsa -b 4096 -C "horak@inflex.cz"
Next you sign with your credentials to a remote computer (where 192.168.88.41 is the remote machine with original VMOD status files)
ssh-copy-id txpom@192.168.88.41
Now you may schedule an automated copying every five minutes to a local folder
crontab -e
*/5 * * * * rsync -chavzP --stats txpom@192.168.88.41:/volumes/data/vmodd /var/tmp/vmodd