Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / msexch_dag
blob0e594a99107e62fa93ccbf219acf437706856898
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 # Example Output:
28 # <<<msexch_dag:sep(58)>>>
29 # RunspaceId : d58353f4-f868-43b2-8404-25875841a47b
30 # Identity : Mailbox Database 1\S0141KL
31 # Name : Mailbox Database 1\S0141KL
32 # DatabaseName : Mailbox Database 1
33 # Status : Mounted
34 # MailboxServer : S0141KL
35 # ActiveDatabaseCopy : s0141kl
36 # ActivationSuspended : False
37 # ActionInitiator : Unknown
38 # ErrorMessage :
39 # ErrorEventId :
40 # ExtendedErrorInfo :
41 # SuspendComment :
42 # SinglePageRestore : 0
43 # ContentIndexState : Healthy
44 # ContentIndexErrorMessage :
45 # CopyQueueLength : 0
46 # ReplayQueueLength : 0
47 # LatestAvailableLogTime :
48 # LastCopyNotificationedLogTime :
49 # LastCopiedLogTime :
50 # LastInspectedLogTime :
51 # LastReplayedLogTime :
52 # LastLogGenerated : 0
53 # LastLogCopyNotified : 0
54 # LastLogCopied : 0
55 # LastLogInspected : 0
56 # LastLogReplayed : 0
57 # LogsReplayedSinceInstanceStart : 0
58 # LogsCopiedSinceInstanceStart : 0
59 # LatestFullBackupTime : 22.10.2014 21:55:12
60 # LatestIncrementalBackupTime :
61 # LatestDifferentialBackupTime :
62 # LatestCopyBackupTime :
63 # SnapshotBackup : True
64 # SnapshotLatestFullBackup : True
65 # SnapshotLatestIncrementalBackup :
66 # SnapshotLatestDifferentialBackup :
67 # SnapshotLatestCopyBackup :
68 # LogReplayQueueIncreasing : False
69 # LogCopyQueueIncreasing : False
70 # OutstandingDumpsterRequests : {}
71 # OutgoingConnections :
72 # IncomingLogCopyingNetwork :
73 # SeedingNetwork :
74 # ActiveCopy : True
76 # RunspaceId : d58353f4-f868-43b2-8404-25875841a47b
77 # Identity : Mailbox Database 2\S0141KL
78 # Name : Mailbox Database 2\S0141KL
79 # DatabaseName : Mailbox Database 2
80 # Status : Healthy
81 # MailboxServer : S0141KL
82 # ActiveDatabaseCopy : s0142kl
83 # ActivationSuspended : False
84 # ActionInitiator : Unknown
85 # ErrorMessage :
86 # ErrorEventId :
87 # ExtendedErrorInfo :
88 # SuspendComment :
89 # SinglePageRestore : 0
90 # ContentIndexState : Healthy
91 # ContentIndexErrorMessage :
92 # CopyQueueLength : 0
93 # ReplayQueueLength : 0
94 # LatestAvailableLogTime : 15.12.2014 13:26:34
95 # LastCopyNotificationedLogTime : 15.12.2014 13:26:34
96 # LastCopiedLogTime : 15.12.2014 13:26:34
97 # LastInspectedLogTime : 15.12.2014 13:26:34
98 # LastReplayedLogTime : 15.12.2014 13:26:34
99 # LastLogGenerated : 2527253
100 # LastLogCopyNotified : 2527253
101 # LastLogCopied : 2527253
102 # LastLogInspected : 2527253
103 # LastLogReplayed : 2527253
104 # LogsReplayedSinceInstanceStart : 15949
105 # LogsCopiedSinceInstanceStart : 15945
106 # LatestFullBackupTime : 13.12.2014 19:06:54
107 # LatestIncrementalBackupTime :
108 # LatestDifferentialBackupTime :
109 # LatestCopyBackupTime :
110 # SnapshotBackup : True
111 # SnapshotLatestFullBackup : True
112 # SnapshotLatestIncrementalBackup :
113 # SnapshotLatestDifferentialBackup :
114 # SnapshotLatestCopyBackup :
115 # LogReplayQueueIncreasing : False
116 # LogCopyQueueIncreasing : False
117 # OutstandingDumpsterRequests : {}
118 # OutgoingConnections :
119 # IncomingLogCopyingNetwork :
120 # SeedingNetwork :
121 # ActiveCopy : False
123 # .--dbcopy--------------------------------------------------------------.
124 # | _ _ |
125 # | __| | |__ ___ ___ _ __ _ _ |
126 # | / _` | '_ \ / __/ _ \| '_ \| | | | |
127 # | | (_| | |_) | (_| (_) | |_) | |_| | |
128 # | \__,_|_.__/ \___\___/| .__/ \__, | |
129 # | |_| |___/ |
130 # +----------------------------------------------------------------------+
133 def inventory_msexch_dag_dbcopy(info):
134 getit = False
135 key = "Status"
136 for line in info:
137 if len(line) == 2:
138 if line[0].strip() == "DatabaseName":
139 dbname = line[1].strip()
140 getit = True
141 elif getit and line[0].strip() == key:
142 yield dbname, (key, line[1].strip())
143 getit = False
146 def check_msexch_dag_dbcopy(item, params, info):
147 getit = False
148 inv_key, inv_val = params
149 for line in info:
150 if len(line) == 2:
151 key, val = [i.strip() for i in line]
152 if key == "DatabaseName" and val == item:
153 getit = True
154 elif getit and key == inv_key:
155 if val == inv_val:
156 state = 0
157 infotxt = "%s is %s" % (inv_key, val)
158 else:
159 state = 1
160 infotxt = "%s changed from %s to %s" % (inv_key, inv_val, val)
161 return state, infotxt
164 check_info['msexch_dag.dbcopy'] = {
165 "inventory_function": inventory_msexch_dag_dbcopy,
166 "check_function": check_msexch_dag_dbcopy,
167 "service_description": "Exchange DAG DBCopy for %s",
171 # .--contentindex--------------------------------------------------------.
172 # | _ _ _ _ |
173 # | ___ ___ _ __ | |_ ___ _ __ | |_(_)_ __ __| | _____ __ |
174 # | / __/ _ \| '_ \| __/ _ \ '_ \| __| | '_ \ / _` |/ _ \ \/ / |
175 # | | (_| (_) | | | | || __/ | | | |_| | | | | (_| | __/> < |
176 # | \___\___/|_| |_|\__\___|_| |_|\__|_|_| |_|\__,_|\___/_/\_\ |
177 # | |
178 # +----------------------------------------------------------------------+
181 def inventory_msexch_dag_contentindex(info):
182 for line in info:
183 if line[0].strip() == "DatabaseName":
184 yield line[1].strip(), None
187 def check_msexch_dag_contentindex(item, _no_params, info):
188 getit = False
189 for line in info:
190 if len(line) == 2:
191 key, val = [i.strip() for i in line]
192 if key == "DatabaseName" and val == item:
193 getit = True
194 elif getit and key == "ContentIndexState":
195 if val == "Healthy":
196 state = 0
197 else:
198 state = 1
199 return state, "Status: %s" % val
202 check_info['msexch_dag.contentindex'] = {
203 "inventory_function": inventory_msexch_dag_contentindex,
204 "check_function": check_msexch_dag_contentindex,
205 "service_description": "Exchange DAG ContentIndex of %s",
209 # .--copyqueue-----------------------------------------------------------.
210 # | |
211 # | ___ ___ _ __ _ _ __ _ _ _ ___ _ _ ___ |
212 # | / __/ _ \| '_ \| | | |/ _` | | | |/ _ \ | | |/ _ \ |
213 # | | (_| (_) | |_) | |_| | (_| | |_| | __/ |_| | __/ |
214 # | \___\___/| .__/ \__, |\__, |\__,_|\___|\__,_|\___| |
215 # | |_| |___/ |_| |
216 # +----------------------------------------------------------------------+
218 msexch_dag_copyqueue_default_levels = (100, 200)
221 def inventory_msexch_dag_copyqueue(info):
222 for line in info:
223 if line[0].strip() == "DatabaseName":
224 yield line[1].strip(), 'msexch_dag_copyqueue_default_levels'
227 def check_msexch_dag_copyqueue(item, params, info):
228 warn, crit = params
229 getit = False
230 for line in info:
231 if len(line) == 2:
232 key, val = [i.strip() for i in line]
233 if key == "DatabaseName" and val == item:
234 getit = True
235 elif getit and key == "CopyQueueLength":
236 infotxt = "Queue length is %d" % int(val)
237 if int(val) >= crit:
238 state = 2
239 elif int(val) >= warn:
240 state = 1
241 else:
242 state = 0
243 if state > 0:
244 infotxt += " (warn/crit at %d/%d)" % (warn, crit)
245 perfdata = [("length", int(val), warn, crit, 0)]
246 return state, infotxt, perfdata
249 check_info['msexch_dag.copyqueue'] = {
250 "inventory_function": inventory_msexch_dag_copyqueue,
251 "check_function": check_msexch_dag_copyqueue,
252 "service_description": "Exchange DAG CopyQueue of %s",
253 "has_perfdata": True,
254 "group": "msexch_copyqueue",