Skip to content

Commit

Permalink
update check_mk agent and plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
elnappo committed May 2, 2016
1 parent 02203e1 commit 3e5a82c
Show file tree
Hide file tree
Showing 52 changed files with 4,058 additions and 654 deletions.
68 changes: 41 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,53 @@ Installs check mk agent. Run it with xinit or over ssh (default). Get more infor
Only testet with Ubuntu and Debian, should run on more platforms.

## Role Variables
* `check_mk_agent_deb_package: check-mk-agent_1.2.4p5-2_all.deb`
* `check_mk_agent_deb_package: check-mk-agent_1.2.6p16-1_all.deb` Path to deb package
* `check_mk_agent_over_ssh: True`
* `check_mk_agent_plugins_requirements: ["smartmontools"]` Requirements for extra plugins
* `check_mk_agent_plugins: ["smart", ]` List of extra plugins to install
* `check_mk_agent_plugins_requirements: []` Requirements for extra plugins
* `check_mk_agent_plugins: []` List of extra plugins to install
* `check_mk_agent_pubkey_file:` Path to ssh pubkey file

## Included check_mk extra plugins
* apache_status
* arc_raid_status.sh
* db2_mem.sh
* dmi_sysinfo
* dmraid
* j4p_performance
* jar_signature
* mailman_lists
* mk_jolokia
* mk_logwatch
* mk_mysql
* mk_oracle
* mk_oracle_asm
* mk_postgres
* mk_sap
* mk_tsm
* mk_zypper
* apache\_status
* db2\_mem
* dnsclient
* hpux\_lunstats
* hpux\_statgrab
* jar\_signature
* kaspersky\_av
* lnx\_quota
* mailman\_lists
* mk\_inventory.aix
* mk\_inventory.linux
* mk\_inventory.solaris
* mk\_jolokia
* mk\_logins
* mk\_logwatch
* mk\_logwatch\_aix
* mk\_mysql
* mk\_oracle
* mk\_oracle.aix
* mk\_oracle.solaris
* mk\_oracle\_asm
* mk\_oracle\_crs
* mk\_postgres
* mk\_sap
* mk\_tsm
* mk\_zypper
* netstat.aix
* netstat.linux
* nfsexports
* plesk_backups
* plesk_domains
* resolve_hostname
* nfsexports.solaris
* nginx\_status
* plesk\_backups
* plesk\_domains
* runas
* smart
* sylo
* vxvm_enclosures
* vxvm_multipath
* vxvm_objstatus
* symantec\_av
* unitrends\_backup
* unitrends\_replication
* vxvm
* websphere\_mq

## Dependencies
None.
Expand Down
6 changes: 3 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# defaults file for agent
check_mk_agent_deb_package: check-mk-agent_1.2.4p5-2_all.deb
check_mk_agent_deb_package: check-mk-agent_1.2.6p16-1_all.deb
check_mk_agent_over_ssh: True
check_mk_agent_plugins_requirements: ["smartmontools"]
check_mk_agent_plugins: ["smart", ]
check_mk_agent_plugins_requirements: []
check_mk_agent_plugins: []
check_mk_agent_pubkey_file:
Binary file added files/check-mk-agent_1.2.6p16-1_all.deb
Binary file not shown.
38 changes: 34 additions & 4 deletions files/plugins/apache_status
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#!/usr/bin/python
# encoding: utf-8
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | 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.

# Check_MK-Agent-Plugin - Apache Server Status
#
Expand All @@ -18,13 +41,19 @@
# It is also possible to override or extend the ssl_ports variable to make the
# check contact other ports than 443 with HTTPS requests.

import os, sys, urllib2, re
import os, sys, urllib2, re, socket

config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/apache_status.conf"

if not os.path.exists(config_file):
config_file = config_dir + "/apache_status.cfg"

# We have to deal with socket timeouts. Python > 2.6
# supports timeout parameter for the urllib2.urlopen method
# but we are on a python 2.5 system here which seem to use the
# default socket timeout. We are local here so set it to 1 second.
socket.setdefaulttimeout(5.0)

# None or list of (proto, ipaddress, port) tuples.
# proto is 'http' or 'https'
Expand All @@ -47,7 +76,7 @@ def try_detect_servers():
to_replace = re.compile('^.*/')
proc = to_replace.sub('', proc)

procs = [ 'apache2', 'httpd', 'httpd2-prefork', 'httpd2-worker', 'httpd.worker' ]
procs = [ 'apache2', 'httpd', 'httpd2-prefork', 'httpd2-worker', 'httpd.worker', 'fcgi-pm' ]
# the pid/proc field length is limited to 19 chars. Thus in case of
# long PIDs, the process names are stripped of by that length.
# Workaround this problem here
Expand Down Expand Up @@ -103,7 +132,8 @@ for server in servers:
url = '%s://%s:%s/%s?auto' % (proto, address, port, page)
# Try to fetch the status page for each server
try:
fd = urllib2.urlopen(url)
request = urllib2.Request(url, headers={"Accept" : "text/plain"})
fd = urllib2.urlopen(request)
except urllib2.URLError, e:
if 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(e):
# HACK: workaround misconfigurations where port 443 is used for
Expand Down
5 changes: 0 additions & 5 deletions files/plugins/arc_raid_status.sh

This file was deleted.

15 changes: 8 additions & 7 deletions files/plugins/db2_mem.sh → files/plugins/db2_mem
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2013 mk@mathias-kettner.de |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
Expand All @@ -25,9 +25,10 @@

INSTANCES=$(ps -ef | grep db2sysc | awk '{print $1}' | sort -u | grep -v root)

for INSTANCE in $INSTANCES; do
if [ "$INSTANCES" ] ; then
echo "<<<db2_mem>>>"
echo "Instance $INSTANCE"
su - $INSTANCE -c "db2pd -dbptnmem " | egrep '(Memory Limit|HWM usage)'
done

for INSTANCE in $INSTANCES; do
echo "Instance $INSTANCE"
su - $INSTANCE -c "db2pd -dbptnmem " | egrep '(Memory Limit|HWM usage)'
done
fi
6 changes: 0 additions & 6 deletions files/plugins/dmi_sysinfo

This file was deleted.

19 changes: 0 additions & 19 deletions files/plugins/dmraid

This file was deleted.

48 changes: 48 additions & 0 deletions files/plugins/dnsclient
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | 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.

# This check can be used to test the name resolution of a given host
# address using the local resolver of the system this script is
# running on.

HOSTADDRESSES=mathias-kettner.de

if [ -e $MK_CONFDIR/dnsclient.cfg ] ; then
. $MK_CONFDIR/dnsclient.cfg
fi

echo "<<<mrpe>>>"
for HOSTADDRESS in $HOSTADDRESSES
do
ADDRESSES=`nslookup $HOSTADDRESS | sed -n -e 1,3d -e '/^Address: *\(.*\)$/s//\1/p'`
if [ ! "$ADDRESSES" ] ; then
STATE=2
OUTPUT="CRIT - $HOSTADDRESS could not be resolved"
else
STATE=0
OUTPUT="OK - $HOSTADDRESS resolved into $ADDRESSES"
fi
echo Resolve_$HOSTADDRESS $STATE $OUTPUT
done
91 changes: 91 additions & 0 deletions files/plugins/hpux_lunstats
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/ksh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | 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.

# Put this file into /usr/lib/check_mk_agent/plugins. Then
# reinventorize your host.
# Actually querying these stats is quite slow since they freshly update
# on each call. If you have a few 1000 luns then this will not work.

get_stats()
{
scsimgr get_stat -D $LUN | tr '\=' ':' | grep -e 'STATISTICS FOR LUN' -e 'Bytes' -e 'Total I/Os processed' -e 'I/O failure' -e 'IO failures due
to'
return $?
}


# Ex:
#LUN PATH INFORMATION FOR LUN : /dev/pt/pt2
#World Wide Identifier(WWID) =
#LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk5
#World Wide Identifier(WWID) = 0x60a98000572d44745634645076556357
#LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk6

get_lun_map()
{
scsimgr lun_map | egrep '^[[:space:]]*(LUN PATH|World Wide Identifier)' | tr '\=' ':'
}


main()
{
get_lun_map | while read line ; do
descr=$(echo $line | awk -F: '{print $1}')
val=$( echo $line | awk -F: '{print $2}')
case $descr in
LUN*)
if echo $val | grep /dev/rdisk 1>/dev/null; then
DMP=yes
LUN=$val
else
DMP=no
unset LUN
fi
;;
World*)
if [ $DMP = "yes" ]; then
echo "WWID: $val"
get_stats $LUN
fi
;;
*)
echo "Fehler:"
echo $line
echo $descr
echo $val
sleep 1
;;
esac
done
}



# Verify the system is using new multipath device model.
if [ -d /dev/rdisk ] && [ -d /dev/disk ]; then
echo '<<<hpux_lunstats:sep(58)>>>'
main
fi

Loading

0 comments on commit 3e5a82c

Please sign in to comment.