This file is indexed.

/usr/share/check_mk/checks/ipmi_sensors is in check-mk-server 1.1.12-1ubuntu1.

This file is owned by root:root, with mode 0o755.

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
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2010             mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  check_mk is  distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# ails.  You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.

# Example output of agent:
# <<<ipmi_sensors>>>
# 32 Temperature_Ambient 20.00_C_(1.00/42.00) [OK]
# 96 Temperature_Systemboard 23.00_C_(1.00/65.00) [OK]
# 160 Temperature_CPU_1 31.00_C_(1.00/90.00) [OK]
# 224 Temperature_CPU_2 NA(1.00/78.00) [Unknown]
# 288 Temperature_DIMM-1A 54.00_C_(NA/115.00) [OK]
# 352 Temperature_DIMM-1B 56.00_C_(NA/115.00) [OK]
# 416 Temperature_DIMM-2A NA(NA/115.00) [Unknown]
# 480 Temperature_DIMM-2B NA(NA/115.00) [Unknown]
# 544 Temperature_DIMM-3A NA(NA/115.00) [Unknown]
# 608 Temperature_DIMM-3B NA(NA/115.00) [Unknown]
# 672 Temperature_DIMM-4A NA(NA/NA) [Unknown]
# 736 Temperature_DIMM-4B NA(NA/NA) [Unknown]
# 800 Temperature_DIMM-1C NA(NA/115.00) [Unknown]
# 864 Temperature_DIMM-1D NA(NA/115.00) [Unknown]
# 928 Temperature_DIMM-2C NA(NA/115.00) [Unknown]
# 992 Temperature_DIMM-2D NA(NA/115.00) [Unknown]
# 1056 Temperature_DIMM-3C NA(NA/115.00) [Unknown]
# 1120 Temperature_DIMM-3D NA(NA/115.00) [Unknown]
# 1184 Temperature_DIMM-4C NA(NA/NA) [Unknown]
# 1248 Temperature_DIMM-4D NA(NA/NA) [Unknown]
# 4288 Power_Unit_PSU [Redundancy_Lost]
# 4336 Power_Unit_PSU [Unknown]
# 3104 Fan_FAN1_CPU 3600.00_RPM_(1800.00/NA) [OK]
# 3168 Fan_FAN2_CPU 3600.00_RPM_(1800.00/NA) [OK]
# 3232 Fan_FAN3_CPU 3540.00_RPM_(1800.00/NA) [OK]
# 3296 Fan_FAN4_CPU NA(1800.00/NA) [Unknown]
# 3360 Fan_FAN5_CPU NA(1800.00/NA) [Unknown]
# 3424 Fan_FAN6_CPU NA(1800.00/NA) [Unknown]
# 3488 Fan_FAN1_SYS 3360.00_RPM_(1800.00/NA) [OK]
# 3552 Fan_FAN2_SYS NA(1800.00/NA) [Unknown]
# 3616 Fan_FAN_PSU1 6840.00_RPM_(2760.00/NA) [OK]
# 3680 Fan_FAN_PSU2 0.00_RPM_(2760.00/NA) [OK]

def inventory_freeipmi(info):
    return [ (line[1], "", None) for line in info if line[-1] != '[Unknown]' ]

def check_freeipmi(item, _no_params, info):
    for line in info:
        if line[1] == item:
            status = line[-1][1:-1]
            perfdata = []
            infotext = "Sensor status is " + status

            # some sensors have a value and levels (e.g. temperature)
            if len(line) == 4:
                current, levels = line[2].split('(')

                # extract current sensor value
                cparts = current.split("_")
                if cparts[0] == "NA":
                    current = None
                else:
                    current = float(cparts[0])
                    if len(cparts) > 1:
                        unit = " " + cparts[1]
                    else:
                        unit = ""

                    # extract levels
                    lower, upper = levels[:-1].split("/")
                    if lower == "NA" and upper != "NA":
                        crit = upper
                        levelstext = ", critical at %.1f%s" % (float(upper), unit)
                    elif lower != "NA" and upper == "NA":
                        crit = lower
                        levelstext = ", critical below %.1f%s" % (float(lower), unit)
                    elif lower != "NA" and upper != "NA":
                        # PNP 0.4.14 cannot handle ranges in thresholds :-(
                        # crit = "%s:%s" % (lower, upper)
                        crit = upper
                        levelstext = ", valid range is %.1f%s ... %.1f%s" % \
                                      (float(lower), unit, float(upper), unit)
                    else:
                        crit = None
                        levelstext = ""

                    # Do not save performance data for FANs. This produces
                    # much data and is - in my opinion - useless.
                    if item.startswith("Fan_"):
                        perfdata = []
                    else:
                        perfdata = [ ("value", current, None, crit) ]
                    infotext = "Current value %.1f%s%s" % (current, unit, levelstext) 
            if status == "OK" \
                    or status == "Entity_Present" \
                    or status.endswith("is_connected") \
                    or status.endswith("Presence_detected") \
                    or status.startswith("Fully_Redundant"):
                return (0, "OK - " + infotext, perfdata)
            else:
                return (2, "CRIT - " + infotext, perfdata)

    return (3, "UNKNOWN - item %s not found" % item)


check_info['ipmi_sensors'] = (check_freeipmi, "IPMI Sensor %s", 1, inventory_freeipmi)