Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / ucd_processes
blobd86e823edffefde10c6cf68c30710b5027c3b5f2
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # .1.3.6.1.4.1.2021.2.1.2.1 Web-Processes --> UCD-SNMP-MIB::prNames.1
28 # .1.3.6.1.4.1.2021.2.1.2.2 SMTP-Processes --> UCD-SNMP-MIB::prNames.2
29 # .1.3.6.1.4.1.2021.2.1.2.3 POP3-Processes --> UCD-SNMP-MIB::prNames.3
30 # .1.3.6.1.4.1.2021.2.1.2.4 LPD-Processes --> UCD-SNMP-MIB::prNames.4
31 # .1.3.6.1.4.1.2021.2.1.3.1 5 --> UCD-SNMP-MIB::prMin.1
32 # .1.3.6.1.4.1.2021.2.1.3.2 1 --> UCD-SNMP-MIB::prMin.2
33 # .1.3.6.1.4.1.2021.2.1.3.3 1 --> UCD-SNMP-MIB::prMin.3
34 # .1.3.6.1.4.1.2021.2.1.3.4 1 --> UCD-SNMP-MIB::prMin.4
35 # .1.3.6.1.4.1.2021.2.1.4.1 50 --> UCD-SNMP-MIB::prMax.1
36 # .1.3.6.1.4.1.2021.2.1.4.2 800 --> UCD-SNMP-MIB::prMax.2
37 # .1.3.6.1.4.1.2021.2.1.4.3 800 --> UCD-SNMP-MIB::prMax.3
38 # .1.3.6.1.4.1.2021.2.1.4.4 800 --> UCD-SNMP-MIB::prMax.4
39 # .1.3.6.1.4.1.2021.2.1.5.1 11 --> UCD-SNMP-MIB::prCount.1
40 # .1.3.6.1.4.1.2021.2.1.5.2 1 --> UCD-SNMP-MIB::prCount.2
41 # .1.3.6.1.4.1.2021.2.1.5.3 1 --> UCD-SNMP-MIB::prCount.3
42 # .1.3.6.1.4.1.2021.2.1.5.4 1 --> UCD-SNMP-MIB::prCount.4
43 # .1.3.6.1.4.1.2021.2.1.100.1 0 --> UCD-SNMP-MIB::prErrFlag.1
44 # .1.3.6.1.4.1.2021.2.1.100.2 0 --> UCD-SNMP-MIB::prErrFlag.2
45 # .1.3.6.1.4.1.2021.2.1.100.3 0 --> UCD-SNMP-MIB::prErrFlag.3
46 # .1.3.6.1.4.1.2021.2.1.100.4 0 --> UCD-SNMP-MIB::prErrFlag.4
47 # .1.3.6.1.4.1.2021.2.1.101.1 --> UCD-SNMP-MIB::prErrMessage.1
48 # .1.3.6.1.4.1.2021.2.1.101.2 --> UCD-SNMP-MIB::prErrMessage.2
49 # .1.3.6.1.4.1.2021.2.1.101.3 --> UCD-SNMP-MIB::prErrMessage.3
50 # .1.3.6.1.4.1.2021.2.1.101.4 --> UCD-SNMP-MIB::prErrMessage.4
53 def inventory_ucd_processes(info):
54 return [(line[0].replace("-Processes", ""), None) for line in info]
57 def check_ucd_processes(item, _no_params, info):
58 for pr_name, pr_min_str, pr_max_str, pr_count_str, pr_err_flag, pr_err_msg in info:
59 if pr_name.replace("-Processes", "") == item:
60 state = 0
61 infotext = "Total: %s" % pr_count_str
62 if int(pr_err_flag) == 0:
63 state = 0
64 else:
65 state = 2
66 if pr_err_msg:
67 infotext += ", %s" % pr_err_msg
68 infotext += " (lower/upper crit at %s/%s)" % (pr_min_str, pr_max_str)
70 return state, infotext, [("processes", int(pr_count_str))]
73 check_info['ucd_processes'] = {
74 'inventory_function': inventory_ucd_processes,
75 'check_function': check_ucd_processes,
76 'service_description': 'Processes %s',
77 'has_perfdata': True,
78 'snmp_info': (
79 ".1.3.6.1.4.1.2021.2.1",
81 "2", # prNames
82 "3", # prMin
83 "4", # prMax
84 "5", # prCount
85 "100", # prErrFlag
86 "101", # prErrMessage
87 ]),
88 'snmp_scan_function': prefer_hr_else_ucd,
89 'includes': ["ucd_hr.include"],