How to modify $SERVICEOUTPUT

Hi

I’d like to modify $SERVICEOUTPUT.

it is too much long to be used by sms 80byte text and i need to summrize content of event.

i want to cut off some text but can’t find any setting in Check_MK UI and files in /omd/sites/mysite/etc.

could you please tell me how to modify $SERVICEOUTPUT?

thank you!

This is not possible as it is the normal output of the check plugins.
If you want to shorten this you have to modify all the check plugins important for your SMS notification.

Why has your SMS only 80 characters? Here you can have a minimum of 160 characters plus the possibility of concatenated messages up to over 1k characters.
If this is needed the notification plugin should shorten your message.

2 Likes

Maybe the poster uses a “free” SMS service and the other 80 bytes are filled with ads :wink:

2 Likes

i can only use 80 SMS character because of some reason.
in this case, can i shorten output message?
i can’t find any file related with $SERVICEOUTPUT

The SMS notification plugin shortens the message to 160 characters. You can modify this script and insert your 80 character limit instead of the default 160. The variable is “max_len”.

Copy this plugin to your “~/local/share/check_mk/notifications” and do the modification.

2 Likes

That’s exactly what I was about to write, @andreas-doehler. The script’s full name is ~/share/check_mk/notifications/sms.
I’m not sure if this is neccessary, but in the copy below ~/local/... I suggest changing the 2nd line from

#!/usr/bin/env python
# SMS (using smstools)

to

#!/usr/bin/env python
# 80 character SMS (using smstools)

(or something similar) to be able to distinguish it from the original script in the GUI.

2 Likes

first of all, thank you for your answer!! :smile:

actually, i’m using my own script in Notification Method to send sms by another tool :expressionless:

i just want to know how to modify $NOTIFY_SERVICEOUTPUT in check_mk…

it is too long to use normal $NOTIFY_SERVICEOUTPUT.

:sob:

So you are basically asking how to pick only the first N characters of a string in bash?

That’s quite easy:

echo ${NOTIFY_SERVICEOUTPUT:0:30}

will print the first 30 characters of $NOTIFY_SERVICEOUTPUT. See Shell Parameter Expansion (Bash Reference Manual) for more examples.

From the screenshot you posted it isn’t exactly clear to me who actually sends the SMS. But if it is some Java program, then I’m confident that Java also has some kind of substring function. :wink:

I want to have a specific item on output like this :grin:

if i print only first 30 charaters there is a problem with some cases like this

commit charge percentage will not be shown in sms text.

so i want to cut off unnessary item in $SERVICEOUTPUT.

Then you have to pick those characters that you consider important and cut off the rest. The first 30 was just an example.

In your example you mark Size: 19.8 GB, 92.04% used as important, but the check isn’t WARN because of the 92.04% but rather because only 1.58 GB are left.

How would checkmk know that? I’m afraid you have to modify your SMS sending tool to only consider what you think is relevant.

1 Like

It would also be possible to extend your script in the way that it sent’s two sms if the string is longer than 80 characters (whats your limit).

2 Likes

Thank you for your answer! :heart_eyes:
I appreciate your advice, Dirk, andreas-doehler.
i rather find another way to shorten this message.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.