Last active
December 17, 2015 21:29
-
-
Save dangarthwaite/5674708 to your computer and use it in GitHub Desktop.
A first take on configuring check_mk to invoke check_mk_agent on minions over salt publish.
See: http://saltstack.org and http://mathias-kettner.com/check_mk.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
'''Support for running check_mk_agent over salt | |
/srv/salt/_modules/check_mk.py''' | |
import os | |
import salt.utils | |
from salt.exceptions import SaltException | |
def __virtual__(): | |
''' Only load the module if check-mk-agent is installed ''' | |
if os.path.exists('/usr/bin/check_mk_agent'): | |
return 'check_mk' | |
return False | |
def agent(): | |
''' Return the output of check_mk_agent ''' | |
return __salt__['cmd.run']('/usr/bin/check_mk_agent') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
salt \* saltutil.sync_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo -u nagios check_mk -v -II web001 | |
Removing 1 checks from /var/lib/check_mk/autochecks/tcp_conn_stats-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/ntp.time-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/uptime-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/kernel.util-2013-05-21_18.52.27.mk. | |
Removing 2 checks from /var/lib/check_mk/autochecks/df-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/mem.used-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/mem.vmalloc-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/cpu.loads-2013-05-21_18.52.27.mk. | |
Removing 3 checks from /var/lib/check_mk/autochecks/kernel-2013-05-21_18.52.27.mk. | |
Removing 2 checks from /var/lib/check_mk/autochecks/ps.perf-2013-05-21_18.52.27.mk. | |
Removing 1 checks from /var/lib/check_mk/autochecks/cpu.threads-2013-05-21_18.52.27.mk. | |
Removing 2 checks from /var/lib/check_mk/autochecks/mounts-2013-05-21_18.52.27.mk. | |
Skipping web001, not an snmp host | |
Calling external programm sudo /usr/bin/salt-call publish.publish web001 check_mk.agent -l quiet | sed 1d | |
cpu.loads 1 new checks | |
cpu.threads 1 new checks | |
df 2 new checks | |
web001: Invalid output from agent or invalid configuration: list index out of range | |
kernel 3 new checks | |
kernel.util 1 new checks | |
web001: Invalid output from agent or invalid configuration: 'index' | |
mem.used 1 new checks | |
mem.vmalloc 1 new checks | |
mounts 2 new checks | |
ntp.time 1 new checks | |
ps.perf 2 new checks | |
tcp_conn_stats 1 new checks | |
uptime 1 new checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bottom of /etc/check_mk/main.mk | |
all_hosts += [ | |
"web001|vbox", | |
] | |
datasource_programs += [ | |
( "sudo /usr/bin/salt-call publish.publish <HOST> check_mk.agent -l quiet | sed 1d ", ['salt'], ALL_HOSTS ), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/salt/minion.d/peers.conf | |
peer: | |
icinga: | |
- check_mk.agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cmnd_Alias SALT_PUBLISH = /usr/bin/salt-call | |
nagios ALL=NOPASSWD: SALT_PUBLISH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment