Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Nagios check_log style perl script that is called via check_by_ssh. The log file entries can contain characters like '>' and '$', which are dangerous and not allowed in SERVICEOUTPUT or LONGSERVICEOUTPUT. The output is stripping these characters making the alerts hard to read. Is there a workaround for escaping characters in SERVICEOUTPUT, or an option to tun on this dangerous activity?

share|improve this question
1  
could you post your scripts? –  pablo Mar 2 '11 at 18:13
    
I'd prefer not to - they work from the command line just fine and contain information I'm not comfortable sharing here. It's the processing that Nagios is doing with the output that is stripping the characters. The illegal_object_name_chars and illegal_macro_output_chars from the nagios.cfg have no effect on the SERVICEOUTPUT. –  timd Mar 2 '11 at 18:22

2 Answers 2

Remove the characters from the illegal_macro_output_chars config option.

share|improve this answer
    
This doesn't work. I've tried this even though the comments in the nagios.cfg clearly state: This DOES NOT affect macros used in service or host check commands. –  timd Mar 2 '11 at 18:29
    
Works for me(tm). I removed "$" from illegal_macro_output_chars and SERVICEOUTPUT could then contain that character. Note you remove a character from this list to allow it to be in the output macros. –  Mark Wagner Mar 2 '11 at 18:43
    
Interesting. I'm going to run some test cases to see if it works with SERVICEOUTPUT but not LONGSERVICEOUTPUT. This might be the difference. Are you calling your plugins locally, or using NRPE or check_by_ssh? –  timd Mar 2 '11 at 19:03

Try escaping the output with a perl function. Without the scripts I can't provide a solution to you but here is an example:

  sub esc_chars {
  # will change, for example, a!!a to a\!\!a
     @_ =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g;
     return @_;
  }

or to just remove them:

  sub esc_chars {
  # will change, for example, a!!a to a\!\!a
     @_ =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'"])//g;
     return @_;
  }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.