Go to All Forums

Linux shell script plugin with JSON output

Is it possible to create a shell plugin that outputs JSON?  I've attempted to do this but it does not seem to work as expected.  If I alter the script to output the data with | separators then it seems to work but I'd rather use JSON if possible.

A sample of the output I'm generating is as follows

getSite24x7PluginData.sh
{
"data": {
"searchDuration":1.935},
"plugin_version": 1,
"heartbeat_required": "true",
"units": {
"searchDuration":"seconds"}
}

Thanks

Like (2) Reply
Replies (4)

Hi,

Please change the script accordingly to get the output as follows:

{
"searchDuration":1.935,
"plugin_version": 1,
"heartbeat_required": "true",
"units": {
"searchDuration":"seconds"}
}

 

Let us know if this helps. For any further queries, please reply back in this thread.

Happy Monitoring!

Like (0) Reply

Great thanks, that works!

I modeled my output on the PowerShell example which outputs this... so perhaps that example is wrong?

{
"data": {
"CPU": 81,
"Memory": 85,
"name": "Process"
},
"validation output": {
"Result": "**************Plugin output is valid**************"
},
"plugin_version": 1,
"heartbeat_required": "true",
"units": {
"CPU": "%",
"Memory": "%"
},
"displayname": "Process Monitor"
}


 

Like (0) Reply

There seems to be some inconsistency in the expected plugin output between Windows and Linux installations.

www.site24x7.com/help/admin/adding-a-monitor/plugins/windows-custom-plugins.html

The first section specifying the output just has values at the top level of the JSON object.

The examples for Windows all seem to include a "data" array with the values inside that array.  In my testing it seems that the examples work and if I change them to exclude the data array then they no longer work.

The opposite is the case for Linux plugins (i.e. including the "data" array causes them to fail).

Am I missing something?

Like (0) Reply

Hi Micheal,

This was a bug and was fixed in the Windows server agent version 18.0.0.

Now, you don't have to include the data attribute in Windows to push the data. (However, it will work even if it is present.) 

 

Thanks,

Anita

Like (0) Reply

Was this post helpful?