This file is indexed.

/usr/share/check_mk/checks/df 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
#!/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.

# <<<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

check_includes['df'] = [ "df.include" ]

def inventory_df(info):
    inventory = []
    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)

        inventory.append((mountpoint, {}))

    return inventory


def check_df(mountpoint, params, 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)

    used_list = [ l for l in info if " ".join(l[6:]).replace('\\','/') == mountpoint ]

    if len(used_list) == 0:
        return (3, "UNKNOWN - %s missing or not a partition" % mountpoint )
    used = used_list[0] # might be listed twice. We take the first occurance

    # In some rare cases the mountpoint may contain a space (happened on ESX).
    if len(used) > 7:
        used = used[0:6] + [ " ".join(used[6:]) ]

    if len(used) != 7 or used[5][-1] != '%':
        return (3, "UNKNOWN - Invalid output from agent (%s)" % (' '.join(used),))

    # 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(used[2]) / 1024.0
    avail_mb   = int(used[4]) / 1024.0

    return df_check_filesystem(g_hostname, mountpoint, size_mb, avail_mb, params)


check_info['df']        = (check_df, "fs_%s", 1, inventory_df)
check_default_levels['df'] = "filesystem_default_levels"