You are currently viewing How to Write Your First 360 Monitoring Plugin

How to Write Your First 360 Monitoring Plugin

First, you need to find out the location where your 360 Monitoring plugins are currently installed. To do so, simply execute the following code:

agent360 info

Example output:

Version: 1.2.33

Plugins enabled: ping, apt-updates, system, iostat, httpd, loadavg, memory, mysql, nginx, diskusage, network, process, docker, cpu, swap

Plugins directory: /usr/local/lib/python3.7/dist-packages/agent360/plugins

Server: 12354148123124

As described in the documentation for the plugins, it will now tell you the exact location. Next up, for my plugin I need to create a file, which I have named plesk-wpt.py in the given folder (i.e. in the location discovered in the previous step). 

Now simply open the file, paste the code and save it. 

Before testing, we need to make sure the user agent360 is allowed to access the Plesk command line with sudo and without password. Therefore we’re adding the following line to /etc/sudoers:

agent360 ALL=(ALL) NOPASSWD: /usr/sbin/plesk

To verify the plugin is installed and all data can be fetched, run this code:

sudo -u agent360 agent360 test plesk-wpt

Now you should get an output with the actual data. To finally activate the plugin and make sure the data is reported in the 360 Monitoring infrastructure, we need to add the following lines to /etc/agent360.ini:

        [plesk-wpt]

        enabled = yes

        interval = 600

This configuration tells the agent360 not only to start using the plugin but to report the status every 600 seconds.

 Once done, restart the monitoring service:

service agent360 restart

https://www.plesk.com/blog/product-technology/how-to-write-360-monitoring-plugin/

Leave a Reply