Aliyun Monitoring System supports user-defined monitoring types, has a strong ability to monitor and expand, support users to write their own monitoring plug-ins to implement custom monitoring types. After writing, place the plug-in under the Scripts directory under the agent installation directory, or under the/usr/local/cms/scripts directory if it is a Linux server.
The monitoring plug-in, no matter what language is written, can be executed directly, it can be a compiled executable binary program file (e.g. C, C + +, etc.), or executable script files (such as Shell, Perl, PHP, etc.).
In order for the cloud Monitor plug-in to be properly invoked and executed by the cloud monitoring agent, the parameters and exit values of the monitor plug-in must comply with the following rules, in which the business logic is entirely up to you:
1, Cloud monitoring plug-in output specification
The cloud monitor agent determines whether the state is OK or critical according to the return value of the plug-in. There are currently only two states of OK and critical.
If it is exit (0), it indicates that its status is OK. This state indicates that the results of the plug-in detection are normal and do not need to be alerted.
If it is exit (2), it indicates that its state is critical. This state indicates that the plug-in detects an exception and needs to be alerted.
If the exit value of the Cloud Monitor plug-in is not above the fixed value, cloud monitoring will not do any processing.
The specific alarm information is the output string that the cloud monitors the plug-in executes, it can be decided entirely by yourself.
2, Cloud Monitoring plug-in input specification
The cloud monitoring agent will pass three parameters to the plug-in when it invokes the plug-in. You can not process these parameters, or you can handle them.
The first input parameter is the parameter of the monitor item on the page, which is entered by you on the page.
The second input parameter is the alert threshold value, which is the alert threshold that you configure on the page. If your plug-in requires a threshold value, your plug-in needs to resolve the threshold and compare it to the threshold to determine whether the return value is 0, or 1 or 2.
The third input parameter is the timeout time, which is the timeout that you select on the page. This parameter can be based on your needs to decide whether to process. If the plug-in executes longer than this time value, the cloud monitoring agent terminates the operation of the plug-in.
3, the plug-in attention matters:
If the plugin is written in scripting language, the first line should have an interpreter, otherwise the cloud monitoring agent cannot execute the plug-ins. For example, if it is written in a shell, the first line should look something like this: #!/bin/sh
#!/bin/sh #请注意这个shell的解释器POLICY_PARAMS =$1 #将第一个参数接收进来 for later processing of the critical_params=$2 #将报警阈值接收进来, followed by a value such as this threshold, If the threshold is greater than or equal, exit (1) exits, indicating critical; if less than the threshold, exit (0) exits, indicating OK. Timeout=$3 #将超时时间接收进来, easy to handle later. For example, the inside call wget command, I want this command to execute more than this time after the timeout, you can use the wget command $timeout this variable ... If (Critical) Echo "critical-the filesystem is readonly." Exit 1 #异常退出If (OK) Echo "ok-the filesystem is normal." Exit 0 #正常退出