Widgets : Access widgets externally Access widgets externally
It is possible to access a widget from an external site, like an intranet or network status page.
Server side setup
To configure this you need to configure a contact and a group, edit php-settings for external widgets and insert an iframe on your external web site.
Contact configuration
To set up a widget contact you first need to create a user. When that is configured create a contact with the same name as the user and specify which contact group(s) it should be a member of.
Like as a normal contact the contact groups defines which hosts are accessible.
Login as the user created for the widget.
PHP settings
After the contact is created log in to the op5 Monitor server using SSH.
# cp /opt/monitor/op5/ninja/application/config/external_widget.php /opt/monitor/op5/ninja/application/config/custom
# cd /opt/monitor/op5/ninja/application/config/custom
Edit the file external_widget.php with your favorite editor.
This file has two variables, “widget_name” specifies which widget that should be shown by default if no widget is set in the iframe. The next one is “username” and this sets the user that should be allowed to fetch the widget.
Example:
$config['widget_name'] = 'netw_health';
$config['username'] = 'jsmith';
$config['groups'] = array('');
In this example the contact jsmith will be used to view widgets and by default it will show the network health widget.
External website setup
On the external website you will need to add an iframe in which the widget is displayed.
The format of the iframe looks like this:
<iframe src="http://<SERVER_NAME>/ninja/index.php/external_widget/show_widget/<OPTIONAL WIDGET_NAME>" height="500px" frameborder=0 width="600px" scrolling='no'></iframe>
In this iframe you will need to change the <SERVER_NAME> to your op5 monitor host name and <OPTIONAL WIDGET_NAME> can either be removed and the default widget will be used or you can specify a widget name to view another widget.
The widgets names can we found in the folder /opt/monitor/op5/ninja/application/widgets. The folder names is the same as the widget name.