This file is indexed.

/usr/share/check_mk/checks/df is in check-mk-server 1.2.2p3-1.

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
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2013             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.

# <<<df>>>
# /dev/sda3     ext4     8123200   1207512   6496392      16% /
# /dev/sda6     ext3   117794932    192192 111522544       1% /data
# /dev/sda2     ext3     8123200    220388   7483516       3% /var
# /dev/sda1     reiserfs  256666     16052    227362       7% /boot
# /dev/mapper/mirrored-database ext3  20642428   1027112  19405604       6% /mirrored/database

def inventory_df(info):
    mplist = []
    for line in info:
        if line[1] in inventory_df_exclude_fs:
            continue # ignore this filesystem type

        size_kb = int(line[2])
        if size_kb == 0 or line[5] == '-':
            continue # exclude filesystems without size

        mountpoint = " ".join(line[6:]).replace('\\', '/') # Windows \ is replaced with /
        if mountpoint in inventory_df_exclude_mountpoints:
            continue # exclude this mount point (/tmp, /proc, whatever user wants)

        mplist.append(mountpoint)

    return df_inventory(mplist)


def check_df(item, params, info):
    fslist = []
    for line in info:
        # df outputs seven columns:
        # DEVICE FS-TYPE SIZE(KB) USED(KB) AVAIL(KB) USED(%) MOUNTPOINT
        # The mount point may contain spaces (seen on VMWare volumes and on ESX)
        mountpoint = " ".join(line[6:]).replace('\\', '/')
        if "patterns" in params or item == mountpoint:
            # Beware: the 6th column of df ("used perc") may includes 5% which are reserved
            # for the superuser, whereas the 4th colum ("used MB") does *not* include that.
            # Beware(2): the column used_mb does not account for the reserved space for
            # superusers. So we rather use the column 'avail' and subtract that from total
            # to compute the used space.
            size_mb    = int(line[2]) / 1024.0
            avail_mb   = int(line[4]) / 1024.0
            fslist.append((mountpoint, size_mb, avail_mb))

    return df_check_filesystem_list(item, params, fslist)

check_info['df'] = {
    "check_function"          : check_df,
    "inventory_function"      : inventory_df,
    "service_description"     : "fs_%s",
    "has_perfdata"            : True,
    "group"                   : "filesystem",
    "default_levels_variable" : "filesystem_default_levels",
    "includes"                : [ "df.include" ],
}