added raritan_rack_power
This commit is contained in:
parent
d4d4074b1b
commit
3df43bbe83
10
check_mk-rack-power/README.MD
Normal file
10
check_mk-rack-power/README.MD
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
First of all, you need to create a dummy host, with IP ( localhost) and create the rule
|
||||||
|
"Individual program call instead of agent access". The value for program call should be:
|
||||||
|
|
||||||
|
~/local/share/check_mk/agents/special/pdu_rack_summary.sh
|
||||||
|
|
||||||
|
The reason for the rule is that the agent should be run under the check_mk site user.
|
||||||
|
This special agent takes data for all hosts that containes "pdu" in it and from it's alias
|
||||||
|
will take the rack information.
|
||||||
|
|
||||||
|
It is providing back the information via piggyback mechanism
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
host_hostalias=`lq "GET hosts\nFilter: host_name ~ pdu\nColumns: name host_alias" |tr ";" " "`
|
||||||
|
hostnames=`lq "GET hosts\nFilter: host_name ~ pdu\nColumns: name"`
|
||||||
|
for hostname in $hostnames
|
||||||
|
do
|
||||||
|
echo "<<<<"$hostname">>>>"
|
||||||
|
echo "<<<"rack_power">>>"
|
||||||
|
alias=`lq "GET hosts\nFilter: host_name ~ $hostname\nColumns:host_alias"`
|
||||||
|
rack=${alias:0:31}
|
||||||
|
echo $rack `lq "GET services\nFilter: description ~ Input Summary\nAND\nFilter: host_alias ~ $rack\nAND\nFilter: state < 3\nStats: sum perf_data"`
|
||||||
|
echo "<<<<>>>>"
|
||||||
|
done
|
@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||||
|
# +------------------------------------------------------------------+
|
||||||
|
# | ____ _ _ __ __ _ __ |
|
||||||
|
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||||
|
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||||
|
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||||
|
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||||
|
# | |
|
||||||
|
# | Copyright Mathias Kettner 2018 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-
|
||||||
|
# tails. 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.
|
||||||
|
|
||||||
|
|
||||||
|
# Author: Markus Lengler <ml@lengler-it.de>
|
||||||
|
|
||||||
|
# Example outputs from agent:
|
||||||
|
# <<<rack_power>>>
|
||||||
|
# PDU_NAME_TEST appower=1299.000000 current=4.400000 energy=29197620.000000 power=1227.000000 voltage=822.000000
|
||||||
|
|
||||||
|
def inventory_rack_power(checkname, info):
|
||||||
|
yield info[0][0],None
|
||||||
|
|
||||||
|
|
||||||
|
def check_rack_power(item, params, info):
|
||||||
|
if params:
|
||||||
|
warn, crit = params["power"]
|
||||||
|
else:
|
||||||
|
warn, crit = (16000,17500)
|
||||||
|
if info[0][0] in item:
|
||||||
|
value=int(str(info[0][4]).split("=")[1].split(".")[0])
|
||||||
|
perfdata = [ ("power", value , warn, crit ) ]
|
||||||
|
state = 0
|
||||||
|
infotext = "Power usage: %s W" % str(value)
|
||||||
|
if value > crit:
|
||||||
|
state = 2
|
||||||
|
infotext = "Power usage is higher than %s" % crit
|
||||||
|
elif value > warn:
|
||||||
|
state = 1
|
||||||
|
infotext = "Power is higher than %s" % warn
|
||||||
|
|
||||||
|
yield state, infotext, perfdata
|
||||||
|
|
||||||
|
|
||||||
|
check_info["rack_power"] = {
|
||||||
|
'check_function' : check_rack_power,
|
||||||
|
'inventory_function' : inventory_rack_power,
|
||||||
|
'service_description' : 'Cabinet Summary %s',
|
||||||
|
'includes' : [ 'raritan.include', 'elphase.include' ],
|
||||||
|
'has_perfdata' : True,
|
||||||
|
'group' : "rack_power"
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
register_check_parameters(
|
||||||
|
subgroup_environment,
|
||||||
|
"rack_power",
|
||||||
|
_("Parameters for input summary of PDUs in a rack(A+B)"),
|
||||||
|
Dictionary(
|
||||||
|
help = _("This rule allows you to specify levels for the power summary of multiple"
|
||||||
|
" PDUs in the rack ."),
|
||||||
|
elements = [
|
||||||
|
( "power",
|
||||||
|
Tuple(
|
||||||
|
title = _("Power"),
|
||||||
|
elements = [
|
||||||
|
Integer(title = _("warning at"), unit = u"W", default_value = 16000),
|
||||||
|
Integer(title = _("critical at"), unit = u"W", default_value = 17500),
|
||||||
|
]
|
||||||
|
)),
|
||||||
|
]),
|
||||||
|
TextAscii(
|
||||||
|
title = _("Input Summary Rack"),
|
||||||
|
help = _("The name of the rack")),
|
||||||
|
"dict"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user