Check_MK hat ein paar kleine Helferlein & Treasures an Board die nicht jeder kennt.
mkcheck
Mkcheck ist ein Script das ein Template für einen neuen eigenen Check erzeugt.
Zu finden ist es unter ~/share/doc/check_mk/helpers/mkcheck
OMD[test1]:~$ ~/share/doc/check_mk/helpers/mkcheck -h DESCRIPTION: This script creates a basic check file or if '-m' specified a manual page. You have to specify at least one name. The created check or manual page are saved to the current directory. It is recommended to run this script in the checks folder if you want to create a check or in the manual page folder if you want to create a man page. USAGE: mkcheck [OPTS] ARGS OPTIONS: -h, --help Show this help -s Adds SNMP info and scan function -p Adds parse function -m Creates the manual page instead of the check
Beispiel für einen SNMP Check:
OMD[test1]:~$ ~/share/doc/check_mk/helpers/mkcheck -sp my_snmp_check OMD[test1]:~$ cat my_snmp_check #!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*- # +------------------------------------------------------------------+ # | ____ _ _ __ __ _ __ | # | / ___| |__ ___ ___| | __ | \/ | |/ / | # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | # | | |___| | | | __/ (__| < | | | | . \ | # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | # | | # | Copyright Mathias Kettner 2017 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. # example output def parse_my_snmp_check(info): pprint.pprint(info) parsed = {} return parsed def inventory_my_snmp_check(parsed): return [] def check_my_snmp_check(item, params, parsed): return 3, 'not yet implemented' check_info['my_snmp_check'] = { 'parse_function' : parse_my_snmp_check, 'inventory_function' : inventory_my_snmp_check, 'check_function' : check_my_snmp_check, 'service_description' : 'DESCR', 'snmp_info' : ('', []), 'snmp_scan_function' : lambda oid: False, }
figheader
Figheader ist ein Helper der Kommentarblöcke im Check_MK Style erzeugt. figlet muss auf dem System installiert sein.
Zu finden unter ~/share/doc/check_mk/helpers/figheader
OMD[test1]:~$ ~/share/doc/check_mk/helpers/figheader whoohoo #. # .--whoohoo-------------------------------------------------------------. # | _ _ | # | __ _| |__ ___ ___ | |__ ___ ___ | # | \ \ /\ / / '_ \ / _ \ / _ \| '_ \ / _ \ / _ \ | # | \ V V /| | | | (_) | (_) | | | | (_) | (_) | | # | \_/\_/ |_| |_|\___/ \___/|_| |_|\___/ \___/ | # | | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------'
wato_import.py
Wato_import.py ist ein Script aus der Schatzkiste und dient zum Import einer CSV Liste in WATO.
Zu finden unter ~/share/doc/check_mk/treasures/wato_import.py
OMD[test1]:~/share/doc/check_mk/treasures$ python wato_import.py Run this script inside a OMD site Usage: ./wato_import.py csvfile.csv CSV Example: wato_foldername;hostname|tag1 tag2;host_alias;ipaddress|None
cmk-delete-host
Cmk-delete-host ist ebenfalls aus der Schatzkiste und dient zum Löschen von Hosts von der Kommandozeile aus. Dazu wird die Automation Schnittstelle verwendet.
Zu finden unter ~/share/doc/check_mk/treasures/cmk-delete-host
extract_inventory.py
Extract_inventory.py ist aus der Schatzkiste und exportiert die Inventory Daten als CSV.
Zu finden unter ~/share/doc/check_mk/treasures/inventory/extract_inventory.py
OMD[test1]:~/share/doc/check_mk/treasures/inventory$ ./extract_inventory.py creating relation inv_raw_generic(OS) for localhost creating relation inv_raw_generic(Linux) for localhost creating relation inv_raw_arp for localhost creating relation devices for localhost creating relation inv_raw_file for localhost mmm@max:/var/tmp# ls -la insgesamt 32 drwxrwxrwt 3 root root 4096 Jul 14 11:41 . drwxr-xr-x 13 root root 4096 Feb 3 2014 .. -rw-r--r-- 1 test1 test1 377 Jul 14 11:41 devices -rw-r--r-- 1 test1 test1 75 Jul 14 11:41 inv_raw_arp -rw-r--r-- 1 test1 test1 114 Jul 14 11:41 inv_raw_file -rw-r--r-- 1 test1 test1 59 Jul 14 11:41 inv_raw_generic(Linux) -rw-r--r-- 1 test1 test1 43 Jul 14 11:41 inv_raw_generic(OS) mmm@max:/var/tmp# cat devices "import_id", "import_data_source_id", "import_org_level_2_id", "device_key", "device_manufacturer", "device_model", "serial_number", "operating_system", "inventory_date", "installation_date", "cpu_socket_count", "cpu_chip_count", "cpu_core_count", "cpu_speed", "cpu_name" "localhost", "sla", "default", "localhost", "", "", "", "", "2017-07-14", "", "", "1", "4", "3200.0", ""
Inoffizielle Notification Scripts
In den Treasures befinden sich noch einige Notification Scripts welche man gut als Vorlage für eigene Scripte verwenden kann. Eigene Notification Scripte sind unter ~/local/share/check_mk/notifications abzulegen.
OMD[test1]:~/share/doc/check_mk/treasures/notifications$ ls -la insgesamt 64 drwxr-xr-x 2 root root 4096 Jul 11 13:55 ./ drwxr-xr-x 21 root root 4096 Jul 11 13:55 ../ -rwxr-xr-x 1 root root 2829 Okt 12 2016 braintower* -rwxr-xr-x 1 root root 24497 Jul 5 14:53 glpi.py* -rwxr-xr-x 1 root root 3842 Okt 12 2016 mobilant* -rwxr-xr-x 1 root root 5114 Okt 12 2016 multitech* -rwxr-xr-x 1 root root 2059 Okt 12 2016 opcmsg* -rw-r--r-- 1 root root 344 Okt 12 2016 README -rwxr-xr-x 1 root root 632 Okt 12 2016 slack* -rwxr-xr-x 1 root root 803 Okt 12 2016 snmp_trap*
Andere Dinge
In der Schatzkiste und in vielen Ordnern im Check_MK Root verbergen sich noch viele coole Sachen am besten geht ihr mal selbst auf die Suche 🙂
~/share/doc/check_mk/treasures
~/share/doc/check_mk/helpers