Cleanup config.nodes_of
[check_mk.git] / checks / libelle_business_shadow
blob195d1df2278ab3e32dd0d457cbad5658ac289585
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 from agent-------------------------------------------.
28 # <<<libelle_business_shadow:sep(58)>>>
29 # DBShadow Oracle Libelle AG
30 # trd : Shared Memory
31 # Release: 5.7.6.0.053 (31003)
33 # Process-Id : 7929872
34 # Start-Time : 12.05.2014 16:55
35 # Shm-Id : 2097154
36 # Sem-Id : 23068672
37 # Number DB : 2
38 # Company : khkirchheim
39 # DB Size : 999
40 # Business : 2
41 # Long-Distance : 0
42 # Raw-Device : 0
43 # Flat-Files : 0
44 # Trace : OFF
45 # Host : kkn-dbnode1-2351
46 # System : aix.61
47 # Status : RUN
48 # Authentication Type : none
50 # -------------- TRD-Parameter --------------
51 # TRD_ARCHDIR_REPEAT : 30
52 # TRD_ARCHIVER_TYPE : turbo
53 # TRD_AUDIT_TRAIL : FALSE
54 # TRD_CHECK_RELEASE : TRUE
55 # TRD_COPYWAIT : 0/0
56 # TRD_COPY_DELETE_BACKUPFILES : NONE
57 # TRD_DISKSPACE : 70/90
58 # TRD_FFARCHIVEFILE_SIZE : 10
59 # TRD_FFBACKUPBLOCK_SIZE : 10
60 # TRD_FFBACKUPFILE_SIZE : 100
61 # TRD_FFCHECK_PERM : TRUE
62 # TRD_FFLOGFORMAT : ff__.ars
63 # TRD_FILE_ACCESS : FILE_POINTER
64 # TRD_FILE_BUFFER_SIZE : 1
65 # TRD_FI_OWNER_ERRORLEVEL : warning
66 # TRD_FI_PERM_ERRORLEVEL : warning
67 # TRD_FI_TIME_ERRORLEVEL : warning
68 # TRD_HOME : /opt/libelle
69 # TRD_HOME_SIZE_REQUIRED : 1000
70 # TRD_HOSTNAME : kkn-dbnode1-2351
71 # TRD_LANGUAGE : english
72 # TRD_MAIL_LOCALINTERFACE :
73 # TRD_MAX_CONNECTIONS : 100
74 # TRD_MAX_FF_ENTRIES : 200
75 # TRD_MAX_MAPPINGS : 200
76 # TRD_MAX_USER_MAPPINGS : 200
77 # TRD_PARALLEL_TRANS_PORTS :
78 # TRD_PORT : 7200
79 # TRD_POWERUP : 0
80 # TRD_RECOVERTIMEOUT : 1500
81 # TRD_ROOT_ALLOW : FALSE
82 # TRD_SAVE_DELETE : 7
83 # TRD_SAVE_SIZE : 5
84 # TRD_SIGCLD_RESET : FALSE
85 # TRD_SOCKETLEN : 32
86 # TRD_SOCKETTIMEOUT : 120
87 # TRD_SOCKET_BLOCKING : FALSE
88 # TRD_SPFILE_PATH : DEFAULT
89 # TRD_TIMEOUT : 60
90 # TRD_TRACELEVEL : 30
91 # TRD_UI_NUM : 20
92 # TRD_USE_ACCOUNT_TYPE : local
94 # -------------- Process List --------------
95 # Pid : 7929872 -1 Timestamp : 22.05.2014 17:36:38 Type : main
96 # Pid : 7929872 -258 Timestamp : 22.05.2014 17:36:38 Type : listen
97 # Pid : 2556268 -1 Timestamp : 22.05.2014 17:36:37 Type : recover KHVN1
99 # ============== Configuration KHVN1 ===============
101 # -------------- Parameter -----------------
102 # APPLICATION_SYSTEM =
103 # ARCHIVE_ALTERNATE_PATH = /u02/oradata/khvn/archive_stby
104 # ARCHIVE_CHECK_DB = 1
105 # ARCHIVE_COLD = FALSE
106 # ARCHIVE_DELETE = TRUE
107 # ARCHIVE_MAX_SWITCH = 20
108 # ARCHIVE_NUM = 131511
109 # ARCHIVE_PATH = /u02/oradata/khvn/archive
110 # ARCHIVE_PIPE = TRUE
111 # ARCHIVE_SHIP_LOGFILES = TRUE
112 # ARCHIVE_STATUS = RUN
113 # CHECK_DISKSPACE = TRUE
114 # COMPRESSED_COPY = TRUE
115 # COPY_BACK = FALSE
116 # COPY_BACKUP_DIRECTORY =
117 # COPY_CHECK_MIRROR = TRUE
118 # COPY_COLD = FALSE
119 # COPY_CONTINUE = FALSE
120 # COPY_FROM_COPY =
121 # COPY_START_ARCHIVER = TRUE
122 # COPY_START_RECOVER = TRUE
123 # COPY_STATUS = STOP
124 # CREATE_DIRECTORY = FALSE
125 # CREATE_FULL_DIRECTORY = TRUE
126 # CURRENT_FUNCTION = recover
127 # CURRENT_STATUS = 20140522 17:36:17;normal;archiver:131511;recover:131492;
128 # CUSTOM1 =
129 # CUSTOM2 =
130 # DBS_PATH =
131 # DB_USER =
132 # DEFINED_SWITCH = FALSE
133 # DESCRIPTION = KHVN1
134 # EMERGENCY_AUTOMATIC = FALSE
135 # EMERGENCY_SID =
136 # EMERGENCY_WAIT_TIME = 0
137 # EXTERNAL_BACKUP = FALSE
138 # EXTERNAL_COPY = FALSE
139 # EXTERNAL_RESTORE = FALSE
140 # FAST_RECOVER = 0
141 # FF_ARCHIVE_NUM = 1
142 # FF_BACKUP_ID = 31.12.2037 23:59:00
143 # FF_RECOVER_NUM = 1
144 # FF_SWITCH_NUM = 1
145 # HIGH_COMPRESSION = FALSE
146 # INTERNAL_PASSWORD =
147 # LOGFORMAT = logarcKHVN.743803837.|.0f.1
148 # MAKE_DB = FALSE
149 # MIRROR_ARCHIVE_PATH = /u02/oradata/khvn/archive
150 # MIRROR_A_INTERFACE = kkn-dbnode1-2351
151 # MIRROR_B_INTERFACE = kkn-dbnode1-2351
152 # MIRROR_DBS_PATH =
153 # MIRROR_HOME = /u01/app/ora10/product/10.2.0/db_1
154 # MIRROR_HOST = kkn-dbnode1-2351
155 # MIRROR_INSTANCE =
156 # MIRROR_PASSWORD =
157 # MIRROR_RELEASE = 10.2.0.4.0
158 # MIRROR_SID = KHVNS
159 # MIRROR_USER =
160 # NAME = KHVN1
161 # ORACLE_HOME = /u01/app/ora10/product/10.2.0/db_1
162 # ORACLE_RELEASE = 10.2.0.4.0
163 # ORACLE_SID = KHVN
164 # PARALLEL_ARCHIVER = 0
165 # PARALLEL_COPY = 4
166 # RAW_DEVICE = FALSE
167 # REAL_A_INTERFACE = kkn-dbnode3-2351
168 # REAL_B_INTERFACE = kkn-dbnode3-2351
169 # REAL_HOST = kkn-dbnode3-2351
170 # RECOVER_CHECK_FILES = 30
171 # RECOVER_CONTINUE = FALSE
172 # RECOVER_DELAY = 240
173 # RECOVER_DELETE = TRUE
174 # RECOVER_LOSSLESS = FALSE
175 # RECOVER_MODE = TIME_DELAY
176 # RECOVER_NUM = 131493
177 # RECOVER_OPEN_READONLY = FALSE
178 # RECOVER_REDO_LOG_PATH =
179 # RECOVER_ROLLBACK = FALSE
180 # RECOVER_ROLLBACK_PATH =
181 # RECOVER_ROLLBACK_SIZE =
182 # RECOVER_START_CLEAR_LOGFILES = FALSE
183 # RECOVER_START_MAKE_DB = FALSE
184 # RECOVER_STATUS = RUN
185 # RECOVER_STOP_COMPLETE = TRUE
186 # RECOVER_STOP_LOSSLESS = FALSE
187 # RECOVER_TO = 31.12.2099 23:59:00
188 # RECOVER_TO_NUMBER = 41284
189 # RECOVER_VERIFY_STATUS = STOP
190 # RECOVER_VERIFY_SYNC =
191 # SAME_FS_PARALLEL = TRUE
192 # STANDBY = TRUE
193 # STRUCTURE_CHANGE = TRUE
194 # STRUCTURE_CHECK_INTERVAL = 60
195 # STRUCTURE_CHECK_NOLOGGING = TRUE
196 # STRUCTURE_STATUS = STOP
197 # TRD_PASSWORD =
199 # --------- CRON Check Mirror Files ----------
200 # CRON[ 0] : 1000010 010000000000
202 # -------------- Active Processes ----------
203 # trdcopy :
204 # trdarchiver :
205 # trdrecover : 2556268 22.05.2014 17:36:34 RUN
206 # trdstructure :
208 # -------------- Statistic of Recover ------
209 # Last update : 22.05.2014 17:36:34
210 # Archive-Dir total : 150 GB
211 # Archive-Dir free : 143 GB
212 # Archive-Dir limit warning : 70
213 # Arshive-Dir limit error : 90
214 # Number of total files : 18
215 # Number logfiles recovered : 1034
216 # logfile-size recovered : 123 GB
217 # Average : 5 files/h
218 # Average : 608 MB/h
219 # Maximum : 14 files/h
220 # Maximum : 2.4 GB/h
221 # Current : 6 files/h
222 # Current : 1.1 GB/h
223 # Min. Rollback :
224 # State of mirror : 22.05.2014 13:26:50
225 # Max. Rollforward :
227 # -------------- Last Message --------------
228 # recover 20140522172734OK 1212Recover of /u02/oradata/khvn/archive/logarcKHVN.743803837.131493.1 at 17:40 22.05.2014.
234 def check_libelle_business_shadow_to_mb(size):
235 if size.endswith("MB"):
236 size = int(float(size.replace("MB", "")))
237 elif size.endswith("GB"):
238 size = int(float(size.replace("GB", ""))) * 1024
239 elif size.endswith("TB"):
240 size = int(float(size.replace("TB", ""))) * 1024 * 1024
241 elif size.endswith("PB"):
242 size = int(float(size.replace("PB", ""))) * 1024 * 1024 * 1024
243 elif size.endswith("EB"):
244 size = int(float(size.replace("EB", ""))) * 1024 * 1024 * 1024 * 1024
245 else:
246 size = int(float(size))
247 return size
250 # parses agent output into a dict
251 def check_libelle_business_shadow_parse(info):
252 parsed = {}
253 for line in info:
254 if len(line) > 1 and line[0].startswith("Host "):
255 parsed["host"] = re.sub("^ +", "", line[1])
256 elif len(line) > 2 and line[0].startswith("Start-Time "):
257 parsed["start_time"] = re.sub("^ +", "", line[1]) + ":" + line[2]
258 elif len(line) > 1 and line[0] == "Release":
259 parsed["release"] = re.sub("^ +", "", line[1])
260 elif len(line) > 1 and line[0].startswith("Status "):
261 parsed["libelle_status"] = re.sub("^ +", "", line[1])
262 elif len(line) > 3 and ( line[0].startswith("trdrecover ") or \
263 line[0].startswith("trdarchiver ") ):
264 parsed["process"] = re.sub(" +$", "", line[0])
265 parsed["process_status"] = re.sub("^[0-9]+ +", "", line[3])
266 elif len(line) > 1 and line[0].startswith("Archive-Dir total "):
267 parsed["arch_total_mb"] = check_libelle_business_shadow_to_mb(re.sub(" ", "", line[1]))
268 elif len(line) > 1 and line[0].startswith("Archive-Dir free "):
269 parsed["arch_free_mb"] = check_libelle_business_shadow_to_mb(re.sub(" ", "", line[1]))
270 return parsed
273 # .--info----------------------------------------------------------------.
274 # | _ __ |
275 # | (_)_ __ / _| ___ |
276 # | | | '_ \| |_ / _ \ |
277 # | | | | | | _| (_) | |
278 # | |_|_| |_|_| \___/ |
279 # | |
280 # '----------------------------------------------------------------------'
283 def inventory_libelle_business_shadow_info(info):
284 return [(None, None)]
287 def check_libelle_business_shadow_info(_no_item, _no_params, info):
288 parsed = check_libelle_business_shadow_parse(info)
289 message = "Libelle Business Shadow"
290 if "host" in parsed.keys():
291 message += ", Host: %s" % parsed["host"]
292 if "release" in parsed.keys():
293 message += ", Release: %s" % parsed["release"]
294 if "start_time" in parsed.keys():
295 message += ", Start Time: %s" % parsed["start_time"]
297 return 0, message
300 check_info["libelle_business_shadow.info"] = {
301 "check_function": check_libelle_business_shadow_info,
302 "inventory_function": inventory_libelle_business_shadow_info,
303 "service_description": "Libelle Business Shadow Info",
307 # .--status--------------------------------------------------------------.
308 # | _ _ |
309 # | ___| |_ __ _| |_ _ _ ___ |
310 # | / __| __/ _` | __| | | / __| |
311 # | \__ \ || (_| | |_| |_| \__ \ |
312 # | |___/\__\__,_|\__|\__,_|___/ |
313 # | |
314 # '----------------------------------------------------------------------'
317 def inventory_libelle_business_shadow_status(info):
318 parsed = check_libelle_business_shadow_parse(info)
319 if "libelle_status" in parsed.keys():
320 return [(None, None)]
321 return []
324 def check_libelle_business_shadow_status(_no_item, _no_params, info):
325 parsed = check_libelle_business_shadow_parse(info)
326 status = 0
327 if "libelle_status" in parsed.keys():
328 message = "Status is: %s" % parsed["libelle_status"]
329 if parsed["libelle_status"] != "RUN":
330 status = 2
331 else:
332 message = "No information about libelle status found in agent output"
333 status = 3
335 return status, message
338 check_info["libelle_business_shadow.status"] = {
339 "check_function": check_libelle_business_shadow_status,
340 "inventory_function": inventory_libelle_business_shadow_status,
341 "service_description": "Libelle Business Shadow Status",
345 # .--process-------------------------------------------------------------.
346 # | |
347 # | _ __ _ __ ___ ___ ___ ___ ___ |
348 # | | '_ \| '__/ _ \ / __/ _ \/ __/ __| |
349 # | | |_) | | | (_) | (_| __/\__ \__ \ |
350 # | | .__/|_| \___/ \___\___||___/___/ |
351 # | |_| |
352 # '----------------------------------------------------------------------'
355 def inventory_libelle_business_shadow_process(info):
356 parsed = check_libelle_business_shadow_parse(info)
357 if "process" in parsed.keys():
358 return [(None, None)]
359 return []
362 def check_libelle_business_shadow_process(_no_item, _no_params, info):
363 parsed = check_libelle_business_shadow_parse(info)
364 status = 0
365 if "process" in parsed.keys():
366 message = "Active Process is: %s, Status: %s" % \
367 (parsed["process"], parsed["process_status"])
368 if parsed["process_status"] != "RUN":
369 status = 2
370 else:
371 message = "No Active Process found!"
372 status = 2
374 return status, message
377 check_info["libelle_business_shadow.process"] = {
378 "check_function": check_libelle_business_shadow_process,
379 "inventory_function": inventory_libelle_business_shadow_process,
380 "service_description": "Libelle Business Shadow Process",
384 # .--archive dir---------------------------------------------------------.
385 # | _ _ _ _ |
386 # | __ _ _ __ ___| |__ (_)_ _____ __| (_)_ __ |
387 # | / _` | '__/ __| '_ \| \ \ / / _ \ / _` | | '__| |
388 # | | (_| | | | (__| | | | |\ V / __/ | (_| | | | |
389 # | \__,_|_| \___|_| |_|_| \_/ \___| \__,_|_|_| |
390 # | |
391 # '----------------------------------------------------------------------'
394 def inventory_libelle_business_shadow_archive_dir(info):
395 parsed = check_libelle_business_shadow_parse(info)
396 if "arch_total_mb" in parsed.keys() and "arch_free_mb" in parsed.keys():
397 return [("Archive Dir", {})]
398 return []
401 def check_libelle_business_shadow_archive_dir(item, params, info):
402 parsed = check_libelle_business_shadow_parse(info)
403 fslist = []
404 fslist.append((item, parsed["arch_total_mb"], parsed["arch_free_mb"], 0))
406 return df_check_filesystem_list(item, params, fslist)
409 check_info["libelle_business_shadow.archive_dir"] = {
410 "check_function": check_libelle_business_shadow_archive_dir,
411 "inventory_function": inventory_libelle_business_shadow_archive_dir,
412 "service_description": "Libelle Business Shadow %s",
413 "has_perfdata": True,
414 "group": "filesystem",
415 "includes": ["size_trend.include", "df.include"],