From c580632e905f4b6857586ca9422267d88590d0cd Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 26 Mar 2014 09:04:32 +0100 Subject: [PATCH] Add check plugin for net-snmp extend checks. Fixes #5861 --- etc/CMakeLists.txt | 1 + etc/icinga2/scripts/snmp-extend.sh | 25 +++++++++++++++++++++++++ itl/command-common.conf | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100755 etc/icinga2/scripts/snmp-extend.sh diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index 2669b5619..fd26e4195 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -44,6 +44,7 @@ install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_S install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) install_if_not_exists(icinga2/scripts/mail-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) +install_if_not_exists(icinga2/scripts/snmp-extend.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) install_if_not_exists(logrotate.d/icinga2 ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d) install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")") diff --git a/etc/icinga2/scripts/snmp-extend.sh b/etc/icinga2/scripts/snmp-extend.sh new file mode 100755 index 000000000..85772d922 --- /dev/null +++ b/etc/icinga2/scripts/snmp-extend.sh @@ -0,0 +1,25 @@ +#!/bin/sh +SNMPGET=$(which snmpget) +test -x $SNMPGET || exit 3 + +if [ -z "$3" ]; then + echo "Syntax: $0 " + exit 3 +fi + +HOST=$1 +COMMUNITY=$2 +PLUGIN=$3 + +RESULT=$(snmpget -v2c -c $COMMUNITY -OQv $HOST .1.3.6.1.4.1.8072.1.3.2.3.1.2.\"$PLUGIN\" 2>&1 | sed -e 's/^"//' -e 's/"$//') + +if [ $? -ne 0 ]; then + echo $RESULT + exit 3 +fi + +STATUS=$(echo $RESULT | cut -f1 -d' ') +OUTPUT=$(echo $RESULT | cut -f2- -d' ') + +echo $OUTPUT +exit $STATUS diff --git a/itl/command-common.conf b/itl/command-common.conf index 3e0087573..71e5e9b89 100644 --- a/itl/command-common.conf +++ b/itl/command-common.conf @@ -241,3 +241,14 @@ object CheckCommand "icinga" inherits "icinga-check-command" { object CheckCommand "cluster" inherits "cluster-check-command" { } + +object CheckCommand "snmp-extend" inherits "plugin-check-command" { + command = [ + IcingaSysconfDir + "/icinga2/scripts/snmp-extend.sh", + "$HOSTADDRESS$", + "$community$", + "$plugin$" + ], + + macros["community"] = "public" +}