How do I get alerted for an exception in a custom plugin?
To get alerted for an exception in a custom plugin, include the attributes ['status'] = 0 and ['msg']=str(e) under Exception.
What do the attributes denote?
1. status: Denotes the availability of the monitor.
The value can either be:
- 1, which means the status is Up and metrics are collected successfully, or
- 0, indicating the status is Down and metrics cannot be collected due to a script error or failure to connect to the remote server or API.
2. msg: These are messages for the monitor when in Down status.
Both of the above are
reserved keys, and you can add the above attributes in the Exception section.
This would change the monitor status to Down if there is an error in the plugin, and ensure that the exception captured in the 'msg' keyword would be shown as the reason for the Down status.
except Exception as e:
data["status"]=0
data["msg"]=str(e)
catch
{
$Script:Status = 0
$Script:msg = $_.Exception.Message
}
Tip: Add this in your plugin scripts for faster troubleshooting.
Related Articles
Troubleshoot the "pymysql module not found" error when installing the MySQL plugin
If you're encountering the pymysql module not found error, it likely means that the pymysql Python library is not installed on the server. pymysql is a Python package that provides a way to interact with MySQL databases using Python code and is used ...
Troubleshoot the Error 404 and Error 99 for RabbitMQ
When installing the RabbitMQ plugin, you may encounter the following errors: HTTP Error 404: Not Found: This error usually occurs when Site24x7's RabbitMQ monitoring plugin attempts to access the /api/overview page of RabbitMQ, but the resource ...
How to configure the NGINX status page for monitoring NGINX performance
The NGINX plugin uses the NGINX status page to pull the performance metrics of the NGINX server. You may encounter the following errors while installing the NGINX plugin integration: Error_code : HTTP Error 404: This error usually indicates that the ...
Difference between a website monitor and a SOAP Web Service monitor
Website monitor will support monitoring of any web application via POST, GET and HEAD methods of configuration. Learn more on the performance metrics provided for a website monitor. SOAP Web Service monitors , on the other hand, lets you to ...
Setting up a website monitor w.r.t content match and HTTP configuration
Regarding the website defacement (content match) configuration, you can set keyword checks to find the existence and non-existence of keywords in your HTML response. As far as the HTTP configurations are concerned, we support HEAD, GET, and POST ...