Formatting Service State output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
StClairPublic
Posts: 6
Joined: Wed Mar 02, 2016 11:20 am

Formatting Service State output

Post by StClairPublic »

Is there a way to format the output from a service command. Here is what I get when I check the SMART info on drives on The latest version of Windows 10 64 bit

DeviceID=\.PHYSICALDRIVE0Model=WDC WD15EADS-00P8B0Name=\.PHYSICALDRIVE0Size=1500299297280Status=OKDeviceID=\.PHYSICALDRIVE1Model=WDC WD10EZEX-08WN4A0Name=\.PHYSICALDRIVE1Size=1000202273280Status=OKDeviceID=\.PHYSICALDRIVE3Model=Samsung SSD 850 EVO 250GBName=\.PHYSICALDRIVE3Size=250056737280Status=OKDeviceID=\.PHYSICALDRIVE4Model=ST31000524ASName=\.PHYSICALDRIVE4Size=1000202273280Status=OKDeviceID=\.PHYSICALDRIVE2Model=WDC WD15EADS-00P8B0Name=\.PHYSICALDRIVE2Size=1500299297280Status=OK

Would like it to be - so it is easier to read (spacing between would be great but at least each on own line)

DeviceID=\.PHYSICALDRIVE0 Model=WDC WD15EADS-00P8B0 Name=\.PHYSICALDRIVE0 Size=1500299297280 Status=OK
DeviceID=\.PHYSICALDRIVE1 Model=WDC WD10EZEX-08WN4A0 Name=\.PHYSICALDRIVE1 Size=1000202273280 Status=OK
DeviceID=\.PHYSICALDRIVE3 Model=Samsung SSD 850 EVO 250GB Name=\.PHYSICALDRIVE3 Size=250056737280 Status=OK
DeviceID=\.PHYSICALDRIVE4 Model=ST31000524AS Name=\.PHYSICALDRIVE4 Size=1000202273280 Status=OK
DeviceID=\.PHYSICALDRIVE2 Model=WDC WD15EADS-00P8B0 Name=\.PHYSICALDRIVE2 Size=1500299297280 Status=OK
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Formatting Service State output

Post by gormank »

The output depends on the underlying command so you might want to see the help output if any. Nagios wants output as a single line of text something like:

<STATUS> <output> | <perfdata>

I've formatted output as multiple lines that are shown if the service link is clicked. This may lose perfdata (graphs).
You can set nagios to allow HTML tags in output and maybe wrap the check in a script if it doesn't have an HTML format option.
Locked