/usr/lib/python2.7/dist-packages/nagiosplugin/output.py is in python-nagiosplugin 1.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87  | # Copyright (c) gocept gmbh & co. kg
# See also LICENSE.txt
import itertools
def filter_output(output, filtered):
    """ Filters out characters from output """
    for char in filtered:
        output = output.replace(char, '')
    return output
class Output(object):
    ILLEGAL = '|'
    def __init__(self, logchan, verbose=0):
        self.logchan = logchan
        self.verbose = verbose
        self.status = ''
        self.out = []
        self.warnings = []
        self.longperfdata = []
    def add(self, check):
        self.status = self.format_status(check)
        if self.verbose == 0:
            perfdata = self.format_perfdata(check)
            if perfdata:
                self.status += ' ' + perfdata
        else:
            self.add_longoutput(check.verbose_str)
            self.longperfdata.append(self.format_perfdata(check, 79))
    def format_status(self, check):
        if check.name:
            name_prefix = check.name.upper() + ' '
        else:
            name_prefix = ''
        summary_str = check.summary_str.strip()
        return self._screen_chars('{0}{1}{2}'.format(
            name_prefix, str(check.state).upper(),
            ' - ' + summary_str if summary_str else ''), 'status line')
    def format_perfdata(self, check, linebreak=None):
        if not check.perfdata:
            return ''
        lines = ['|']
        for item, i in zip(check.perfdata, itertools.count()):
            if linebreak and len(lines[-1]) + len(item) >= linebreak:
                lines.append(item)
            else:
                lines[-1] += ' ' + self._screen_chars(
                    item, 'perfdata {0}'.format(i))
        return '\n'.join(lines)
    def add_longoutput(self, text):
        if isinstance(text, list) or isinstance(text, tuple):
            for line in text:
                self.add_longoutput(line)
        else:
            self.out.append(self._screen_chars(text, 'long output'))
    def __str__(self):
        output = [elem for elem in
                  [self.status] +
                  self.out +
                  [self._screen_chars(self.logchan.stream.getvalue(),
                                      'logging output')] +
                  self.warnings +
                  self.longperfdata
                  if elem]
        return '\n'.join(output) + '\n'
    def _screen_chars(self, text, where):
        text = text.rstrip('\n')
        screened = filter_output(text, self.ILLEGAL)
        if screened != text:
            self.warnings.append(self._illegal_chars_warning(
                where, set(text) - set(screened)))
        return screened
    def _illegal_chars_warning(self, where, removed_chars):
        hex_chars = ', '.join('0x{0:x}'.format(ord(c)) for c in removed_chars)
        return 'warning: removed illegal characters ({0}) from {1}'.format(
            hex_chars, where)
 |