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
Build custom Linux plugins
Plugins are a great way to measure customized attributes and keep track of the data that matters the most. You can set thresholds to individual attributes and choose to get alerted if the set values exceed. Please follow the below steps to configure ...
Disable alerts for a plugin if the parent server is down
If a plugin monitor's parent server goes down, you can choose to exclude additional alerts from the plugin monitor. This way, you won’t receive alerts when the plugin monitor goes down as a result of the parent server being unavailable. To enable ...
Add a new Windows plugin
Our open eco system for plugins give you the flexibility to create your own plugins and monitor data that you need, the way you want. You can also set thresholds to individual attributes and choose to get alerted if the set values exceed. 10 plugins ...
FAQ on Custom Roles
What is the Created permission and what does it allow users to do? The Created permission is a specific type of access control that permits users to perform actions such as View, Write, or Delete solely on the modules, like dashboard, that they have ...
How to troubleshoot my Windows PowerShell Plugin?
By default, the Site24x7 monitoring Windows agent will run as a SYSTEM user. In case, if you would like to verify if the plugin script is giving the output properly as SYSTEM user, follow these steps: Download PsExec from this link and extract the ...