This file is indexed.

/usr/sbin/check-mc-nrpe is in mcollective-plugins-nrpe 0.0.0~git20120105.9b90c2b-0ubuntu2.

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
#!/usr/bin/env ruby

# Nagios check for the mcollective nrpe agent found at https://github.com/puppetlabs/mcollective-plugins
#
# Returns std Nagios exit codes and performance data.  Lists of hosts in the given status is printed
# on subsequent lines of output, Nagios 3 will read these and display them up to 4KB

require 'mcollective'

include MCollective::RPC

nrpe = rpcclient("nrpe")
nrpe.progress = false

if ARGV.length > 0
    command = ARGV.shift
else
    puts("UNKNOWN: NRPE command not specified")
    exit 3
end


labels = ["OK", "WARNING", "CRITICAL", "UNKNOWN"]
stats = [[], [], [], []]
statuscodes = [0]

if nrpe.discover.size == 0
    puts("#{command}: UNKNOWN: did not discovery any nodes")
    exit 3
end

nrpe_results = nrpe.runcommand(:command => command)

nrpe_results.each do |result|
    exitcode = result[:data][:exitcode].to_i
    statuscodes << exitcode
    stats[exitcode] << result[:sender]
end

# Nodes that don't respond are UNKNOWNs
if nrpe.stats[:noresponsefrom].size > 0
    stats[3] << nrpe.stats[:noresponsefrom]
    statuscodes << 3

    stats[3].flatten!
end

# If we didn't discover any then thats an unknown
statuscodes << 3 if nrpe.discover.size == 0

puts("#{command}: OK: %d WARNING: %d CRITICAL: %d UNKNOWN: %d|total=%d ok=%d warn=%d crit=%d unknown=%d checktime=%f" % [stats[0].size, stats[1].size, stats[2].size, stats[3].size, nrpe_results.size, stats[0].size, stats[1].size, stats[2].size, stats[3].size, nrpe.stats.blocktime])

[2,1,3].each do |e|
    if stats[e].size > 0
        puts "#{labels[e]}:"
        puts "   " + stats[e].join(" ")
    end
end

# if there's any critical checks, exit critical
# else just take the highest.  UNKNOWN is 3 while
# critical is 2, just exiting with max would hide
# the fact that there are criticals.
if statuscodes.include?(2)
    exit 2
else
    exit statuscodes.max
end

# vi:tabstop=4:expandtab:ai