Alerting for an exception in a custom plugin

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. 1, which means the status is Up and metrics are collected successfully, or
    2. 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)

In a sample PowerShell plugin script , include these attributes as follows: 
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 ...
    • 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 ...
    • How to set thresholds and get alerted based on the number of DOWN locations?

      By configuring the proper thresholds for your web application, you can decide when to get alerted for a DOWN monitor. Let's say you have a web application that you monitor from our three global locations and your downtime rule is set as three ...
    • 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 ...
    • How do I add the Dell iDRAC plugin for Windows?

      Prerequisites Install the latest version of the Net-SNMP package. Follow these steps to install and configure it. Install Python 3.6. Plugin Installation Create a folder named idrac. Download the files from our GitHub repository and place them in the ...