Shrink & spoiler large service check plugin output

Hello Icinga2 community,

I am curious if it is possible to shrink very large plugin outputs to 1 line in the icinga2web service check overview page, because they take place a lot of space on that view.

Here is an example of the initial issue:

Hi.

You could wrap the output of the plugin.
For example with this script.


Greetings.

1 Like

Hi,
thanks a lot for that interesting plugin suggestion!
This looks like the first step to a well working solution, but so far I am not there.

When setting the WRAPPED_OUTPUT variable to $null or just shorten it by X characters, the performance data in Icinga will be lost. So performance data is not displayed anymore in this case.

But I want to keep this:
2021-07-29_16-24-58
Is there any other way (using this script) to keeping the performance data, while the output will be displayed for just one or two lines?

That’s quiet interesting!
When implementing an error, the service check preview is shortened to the error output only, but the plugin output itself is enriched by the error output, but the performance data stays!

Hi again.

Sorry for the confusion.
The script, like it is, is only a starting point. You can do whatever to want with the output returned from the original plugin.
If you want to keep the performance-data, just keep it.

It is only a way to handle the output like you want it to be displayed at icingaweb2, including performance-data.

The work to do is using sed, grep, awk or whatever to bring the output to the format you prefer (in the wrapper-script).

Anyway, just an idea.

Hope this helps.


Greetings.

1 Like

So to what structure has to output to be brought, so that
a) it’s as short es possible, while
b) the performance data is still being able to be parsed and displayed tabular

Here is an example of an massive output I want to shorten:

OK - interface Ethernet1 (alias Citrix ADC DMZSDX1 10-2) discards in:0.00% out:0.00% , interface Ethernet2 (alias Citrix ADC DMZSDX2 10-2) discards in:0.00% out:0.00% , interface Ethernet3 (alias Port Channel to Management Network) discards in:0.00% out:0.00% , interface Ethernet4 (alias Port Channel to Management Network) discards in:0.00% out:0.00% , interface Ethernet29 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet30 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet31 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet32 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet33 (alias Data Spine #02 D08 HU18 e35) discards in:0.00% out:0.00% , interface Ethernet34 (alias Data Spine #01 D03 HU21 e35) discards in:0.00% out:0.00% , interface Ethernet35 (alias MLAG) discards in:0.00% out:0.00% , interface Ethernet36 (alias MLAG) discards in:0.00% out:0.00% , interface Ethernet6/1 (alias Port Channel to NetScaler #01) discards in:0.00% out:0.00% , interface Ethernet6/2 (alias Port Channel to NetScaler #01) discards in:0.00% out:0.00% , interface Ethernet6/3 (alias Port Channel to NetScaler #01) discards in:0.00% out:0.00% , interface Ethernet6/4 (alias HA-Link SDX1 10/8) discards in:0.00% out:0.00% , interface Ethernet7/1 (alias Port Channel to NetScaler #02) discards in:0.00% out:0.00% , interface Ethernet7/2 (alias Port Channel to NetScaler #02) discards in:0.00% out:0.00% , interface Ethernet7/3 (alias Port Channel to NetScaler #02) discards in:0.00% out:0.00% , interface Ethernet7/4 (alias HA-Link SDX2 10/8) discards in:0.00% out:0.00% , interface Ethernet8/1 (alias RESERVED for Port Channel to NetScaler #03) discards in:0.00% out:0.00% , interface Ethernet8/2 (alias RESERVED for Port Channel to NetScaler #03) discards in:0.00% out:0.00% , interface Ethernet8/3 (alias RESERVED for Port Channel to NetScaler #03) discards in:0.00% out:0.00% , interface Ethernet8/4 (alias RESERVED for NetScaler #03 PaloAlto) discards in:0.00% out:0.00% , interface Ethernet9/1 (alias RESERVED for Port Channel to NetScaler #04) discards in:0.00% out:0.00% , interface Ethernet9/2 (alias RESERVED for Port Channel to NetScaler #04) discards in:0.00% out:0.00% , interface Ethernet9/3 (alias RESERVED for Port Channel to NetScaler #04) discards in:0.00% out:0.00% , interface Ethernet9/4 (alias RESERVED for NetScaler #04 PaloAlto) discards in:0.00% out:0.00% , interface Ethernet10/1 (alias 80G Port Channel 1 to FortiGate / MDL) discards in:0.00% out:0.00% , interface Ethernet11/1 (alias 80G Port Channel 2 to FortiGate / MDL) discards in:0.00% out:0.00% , interface Ethernet12/1 (alias RESERVED for Moonshot Deployer) discards in:0.00% out:0.00% , interface Ethernet12/2 (alias RESERVED for Moonshot Deployer) discards in:0.00% out:0.00% , interface Ethernet12/3 (alias RESERVED for Moonshot Deployer) discards in:0.00% out:0.00% , interface Ethernet12/4 (alias RESERVED for Moonshot Deployer) discards in:0.00% out:0.00% , interface Ethernet13/1 (alias Stephans sniffer Port 2) discards in:0.00% out:0.00% , interface Ethernet13/2 discards in:0.00% out:0.00% , interface Ethernet13/3 discards in:0.00% out:0.00% , interface Ethernet13/4 discards in:0.00% out:0.00% , interface Ethernet14/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet15/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet16/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet17/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet18/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet19/1 (alias RESERVED for future spines + used for mirror session with Ralf) discards in:0.00% out:0.00% , interface Ethernet20/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet21/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet22/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet23/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet24/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet25/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet26/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet27/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Ethernet28/1 (alias RESERVED for future spines) discards in:0.00% out:0.00% , interface Management1 (alias Mgmt) discards in:0.00% out:0.00% , interface Port-Channel10 (alias Port Channel to MDL) discards in:0.00% out:0.00% , interface Port-Channel11 (alias 80G Port Channel 1 to FortiGate / MDL) discards in:0.00% out:0.00% , interface Port-Channel12 (alias 80G Port Channel 2 to FortiGate / MDL) discards in:0.00% out:0.00% , interface Port-Channel20 (alias Port Channel to Management Network) discards in:0.00% out:0.00% , interface Port-Channel30 (alias Port Channel to DMZ) discards in:0.00% out:0.00% , interface Port-Channel81 (alias Port Channel to NetScaler #01) discards in:0.00% out:0.00% , interface Port-Channel82 (alias Port Channel to NetScaler #02) discards in:0.00% out:0.00% , interface Port-Channel83 (alias Port Channel to NetScaler #03) discards in:0.00% out:0.00% , interface Port-Channel84 (alias Port Channel to NetScaler #04) discards in:0.00% out:0.00% , interface Port-Channel94 (alias MLAG) discards in:0.00% out:0.00% , interface Port-Channel99 (alias Port-Channel HA SDX1) discards in:0.00% out:0.00% , interface Port-Channel100 (alias Port-Channel HA SDX2) discards in:0.00% out:0.00% , interface Vlan299 discards in:0.00% out:0.00% , interface Vlan522 discards in:0.00% out:0.00% , interface Vlan526 discards in:0.00% out:0.00% , interface Vlan600 discards in:0.00% out:0.00% , interface Vlan601 discards in:0.00% out:0.00% , interface Vlan803 discards in:0.00% out:0.00% , interface Vlan804 discards in:0.00% out:0.00% , interface Vlan805 discards in:0.00% out:0.00% , interface Vlan806 discards in:0.00% out:0.00% , interface Vlan808 discards in:0.00% out:0.00% , interface Vlan900 discards in:0.00% out:0.00% , interface Vlan901 discards in:0.00% out:0.00% , interface Vlan905 discards in:0.00% out:0.00% , interface Vlan906 discards in:0.00% out:0.00% , interface Vlan1188 discards in:0.00% out:0.00% , interface Vlan1189 discards in:0.00% out:0.00% , interface Vlan1190 (alias IP Helper address workaround for Manfred) discards in:0.00% out:0.00% , interface Vlan1191 discards in:0.00% out:0.00% , interface Vlan1194 discards in:0.00% out:0.00% , interface Vlan1195 discards in:0.00% out:0.00% , interface Vlan1196 discards in:0.00% out:0.00% , interface Vlan1197 discards in:0.00% out:0.00% , interface Vlan1201 discards in:0.00% out:0.00% , interface Vlan1202 discards in:0.00% out:0.00% , interface Vlan1205 discards in:0.00% out:0.00% , interface Vlan1206 discards in:0.00% out:0.00% , interface Vlan1207 discards in:0.00% out:0.00% , interface Vlan1208 discards in:0.00% out:0.00% , interface Vlan1209 discards in:0.00% out:0.00% , interface Vlan1210 discards in:0.00% out:0.00% , interface Vlan1211 discards in:0.00% out:0.00% , interface Vlan1212 discards in:0.00% out:0.00% , interface Vlan1213 discards in:0.00% out:0.00% , interface Vlan1224 discards in:0.00% out:0.00% , interface Vlan3999 discards in:0.00% out:0.00% , interface Vlan4094 discards in:0.00% out:0.00% , interface Loopback100 (alias VTEP Loopback) discards in:0.00% out:0.00% , interface Vxlan1 discards in:0.00% out:0.00%

Hi.

This output does not seem to contain performance-data.
Please run the script with the same arguments on the commandline.

Performance-data is seperated by “|”.
That’s a starting point to figure out where to cut/replace the output.

Edit: Example output including performance data:

CHECK_RANCHER2 OK - All workloads (39) in project a-bdcde:f-ghijk are healthy/active|'workloads_total'=39;;;; 'workloads_errors'=0;;;; 'workloads_warnings'=0;;;; 'workloads_paused'=0;;;;

The output in icingaweb2 would be:

CHECK_RANCHER2 OK - All workloads (39) in project a-bdcde:f-ghijk are healthy/active

The performance-data would be:

'workloads_total'=39;;;; 'workloads_errors'=0;;;; 'workloads_warnings'=0;;;; 'workloads_paused'=0;;;;

This performance data would look like this in icingaweb2:
image


Greetings.

1 Like

Correct, when executing the check command on commandline, performance data is returned as well as the output. Eg.
OK - interface Ethernet1 ... | 'Ethernet1_discards_in'=0%;5;10;0;100 ' ...

When executing the plugin_wrapper script, it’s just returning the output, e.g.:
OK - interface Ethernet1 ...

Removing this output, or just even shortening it, will also make the tabular performance data to vanish in the UI.

For testing, I added one performance data entry static into the script:
WRAPPED_OUTPUT="| 'Ethernet1_discards_in'=0%;5;10;0;100"

This followed the plugin output to be empty in the UI and the performance data be displayed.

I am a bit confused why the script is not returning any performance data by the variable OUTPUT=$($ARGS) because somewhere it must be stored.

Okay, I figured this out!
Everything after the pipe symbol (=performance data) gets parsed and converted automatically into the tabular structure. That’s why the performance data was not visible to me, until I executed this check on the command line.

I modified the script, so that only the status check will remain in the plugin output (e.g. “OK”) and the performance data will get parsed like before.

#!/usr/bin/env bash
# Usage
#
# See https://github.com/dnsmichi/icinga-plugin-wrapper
ARGS=$@
OUTPUT=$($ARGS)
STATUS=$?

#Get the check status part of the plugin output, e.g.: "OK"
STATUS_TEXT="$($ARGS | sed 's/ - .*//g')"

#Get the performance data of the plugin output by deleting everything before " | ", except " | " and following characters
PERFORMANCE_DATA="$($ARGS | sed 's/^.*|/|/')"

#Concatenate status string and performance data string
WRAPPED_OUTPUT=$STATUS_TEXT$PERFORMANCE_DATA

# Change the exit status if needed
WRAPPED_STATUS=$STATUS

echo $WRAPPED_OUTPUT
exit $WRAPPED_STATUS

Thank you @homerjay for your very helping advises! :slight_smile:

2 Likes

Hi.

I am glad it works. You are welcome.


Greetings.