This file is indexed.

/usr/bin/mk-job is in check-mk-agent 1.2.6p12-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
#!/bin/bash
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2014             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.

export MK_VARDIR=/var/lib/check_mk_agent

help() {
    echo "Usage: mk-job IDENT PROGRAM [ARGS...]"
    echo ""
    echo "Execute PROGRAM as subprocess while measuring performance information"
    echo "about the running process and writing it to an output file. This file"
    echo "can be monitored using Check_MK. The Check_MK Agent will forward the"
    echo "information of all job files to the monitoring server."
    echo ""
    echo "This file is being distributed with the Check_MK Agent."
}

if [ $# -lt 2 ]; then
    help >&2
    exit 1
fi

MYSELF=$(id -nu)
OUTPUT_PATH=$MK_VARDIR/job/$MYSELF
IDENT=$1
shift

if [ ! -d "$OUTPUT_PATH" ]; then
    if [ "$MYSELF" = root ] ; then
        mkdir -p "$OUTPUT_PATH"
    else
        echo "ERROR: Missing output directory $OUTPUT_PATH for non-root user '$MYSELF'." >&2
        exit 1
    fi
fi

if ! type $1 >/dev/null 2>&1; then
    echo -e "ERROR: Cannot run $1. Command not found.\n" >&2
    help >&2
    exit 1
fi

date +"start_time %s" > "$OUTPUT_PATH/$IDENT.running"
/usr/bin/time -o "$OUTPUT_PATH/$IDENT.running" --append \
              -f "exit_code %x\nreal_time %E\nuser_time %U\nsystem_time %S\nreads %I\nwrites %O\nmax_res_kbytes %M\navg_mem_kbytes %K\ninvol_context_switches %c\nvol_context_switches %w" "$@"
RC=$?
mv "$OUTPUT_PATH/$IDENT.running" "$OUTPUT_PATH/$IDENT"
exit $RC