Go to All Forums

Plugin - HTTP Error raised

Hello,

I want to write my own plugin in shell. 

It should be easy plugin reporting actual disk usage (purpose is ability to monitor multiple threshold for one partition ).

I need tu start my script with parameter. Similar way as nagios plugin, so I cant use this step from plugin guide.

=================

Create a folder under the Plugins directory in the agent installation path and place the plugin script file and other dependency files here. The name of the folder and the plugin script file should be the same.

=================


So I used way same as for nagios plugin.

=================

Include the path of the Nagios script file and its arguments and save the 'nagios_plugins.json' file.

=================

 

Now I have this in /monagent/logs/details/plugins.txt
=================

2018-07-19 17:04:44,854 Worker 3, Registering Plugin =======> {"data": {" Partition": " /dev/mapper/centos_db--devel-root=25% "}, "availability": 1, "units": {"{Partition": "%"}, "type": "disk.sh"}
2018-07-19 17:04:44,854 Worker 3, ================================= SEND REQUEST =================================
2018-07-19 17:04:45,524 Worker 3, ++++++++++++++++++++++++++++++++++ HTTP Error raised ++++++++++++++
2018-07-19 17:04:45,524 Worker 3, Reason : 'Not Found'Code : 404
2018-07-19 17:04:45,525 Worker 3, Return status : False Error code : 404
2018-07-19 17:04:45,525 Worker 3, ==== Removing Plugin Config ===='disk.sh'
2018-07-19 17:04:45,525 Worker 3, ==== Plugin Config after removal ===={}
=================

 

Can someone explain me, what is going on? I am not sure what was not found.. 

 

Here is my script:

=================

#!/usr/bin/env bash

# Easy script reporting partition usage in percetange.

PLUGIN_VERSION="1" ###Mandatory - If any changes in the plugin metrics, increment the plugin version here.
HEARTBEAT="true" ###Mandatory - Setting this to true will alert you when there is a communication problem while posting plugin data to server
METRIC_UNITS={Partition-'%'} ###OPTIONAL - These units will be displayed in the Dashboard

get_data () {
for a in "$@"; do
con=$(df $a)
percent=$(echo ${con}| awk '{print $12}')
part=$(echo ${con}|awk '{print $8}')
printf "Partition: %s=%s\n" "${part}" "${percent} "
done
}

mandatory_attributes="plugin_version:$PLUGIN_VERSION|heartbeat_required:$HEARTBEAT"

plugin_data=$(get_data "$@")
output="${mandatory_attributes} | ${plugin_data} |units: $METRIC_UNITS "
echo ${output}

=================
 
Thanks in advance.


Best Regards,
Marek

Like (1) Reply
Replies (3)

Re: Plugin - HTTP Error raised

Hi Marek,

Since the data format provided by Nagios is different from our Shell script format, you cannot have the same procedure followed. 

Please drop in a mail to support@site24x7.com for further assistance.

 

Regards

- Sriram

Like (0) Reply

Re: Re: Plugin - HTTP Error raised

Hello Siriam,

 

thank you for reply.

Can you tell me, how can I provide a parameter to the shell script.

My goal is to have a general plugin with possibility to assign specific disc partition to monitor eq. I don't want to hard-coded the partition into script itself.

 

Best regards,
Marek

Like (0) Reply

Re: Re: Re: Plugin - HTTP Error raised

Hi Marek,

 

We do not support providing a parameter to Shell script.

You can make use of the Nagios plugin 'check_disk' for this and use our Nagios plugin integration.

Hope this helps. Let me know for further queries, if any.

 

- Sriram

Like (0) Reply

Was this post helpful?