#!/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: # # <<>> # Appliance Name HPCT15732RTD # Network Name 10.0.0.240 # Serial Number CT15732RTD # Software Version 3.15.1-1636.1 # Product Class HPE StoreOnce 4700 Backup # Total Capacity 75952.808613643 # Free Space 53819.324528395 # User Data Stored 305835.97014174 # Size On Disk 19180.587585836 # Total Capacity (bytes) 75952808613643 # Free Space (bytes) 53819324528395 # User Data Stored (bytes) 305835970141743 # Size On Disk (bytes) 19180587585836 # Dedupe Ratio 15.945078260667367 # Cluster Health Level 1 # Cluster Health OK # Cluster Status Running # Replication Health Level 1 # Replication Health OK # Replication Status Running # Uptime Seconds 4305030 # sysContact None # sysLocation None # isMixedCluster false #. # .--general-------------------------------------------------------------. # | _ | # | __ _ ___ _ __ ___ _ __ __ _| | | # | / _` |/ _ \ '_ \ / _ \ '__/ _` | | | # | | (_| | __/ | | | __/ | | (_| | | | # | \__, |\___|_| |_|\___|_| \__,_|_| | # | |___/ | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' #def parse_storeonce_clusterinfo(info): # parsed = {} # for line in info: # parsed[line[0]] = line[1] # return parsed def inventory_storeonce_clusterinfo(parsed): if "Product Class" in parsed: return [ (parsed['Product Class'], None) ] def check_storeonce_clusterinfo(item, _no_params, parsed): return 0, "Name: %s, Serial Number: %s, Version: %s" % \ (parsed['Appliance Name'], parsed['Serial Number'], parsed['Software Version']) check_info['storeonce_clusterinfo'] = { 'parse_function' : parse_storeonce_clusterinfo, 'inventory_function' : inventory_storeonce_clusterinfo, 'check_function' : check_storeonce_clusterinfo, 'service_description' : '%s', 'includes' : [ 'storeonce.include' ], } #. # .--cluster-------------------------------------------------------------. # | _ _ | # | ___| |_ _ ___| |_ ___ _ __ | # | / __| | | | / __| __/ _ \ '__| | # | | (__| | |_| \__ \ || __/ | | # | \___|_|\__,_|___/\__\___|_| | # | | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' def inventory_storeonce_clusterinfo_cluster(parsed): if "Cluster Health" in parsed: return [ (None, {}) ] def check_storeonce_clusterinfo_cluster(item, params, parsed): yield 0, "Cluster Status: %s, Replication Status: %s" % \ (parsed['Cluster Status'], parsed['Replication Status']) # Check state of components for component in ['Cluster Health', 'Replication Health']: state = translate_storeonce_status(parsed['%s Level' % component]) state_readable = "%s: %s" % (component, parsed[component]) if state > 0: yield state, state_readable check_info['storeonce_clusterinfo.cluster'] = { 'inventory_function' : inventory_storeonce_clusterinfo_cluster, 'check_function' : check_storeonce_clusterinfo_cluster, 'service_description' : 'Appliance Status', } #. # .--cluster space-------------------------------------------------------. # | _ _ | # | ___| |_ _ ___| |_ ___ _ __ ___ _ __ __ _ ___ ___ | # | / __| | | | / __| __/ _ \ '__| / __| '_ \ / _` |/ __/ _ \ | # | | (__| | |_| \__ \ || __/ | \__ \ |_) | (_| | (_| __/ | # | \___|_|\__,_|___/\__\___|_| |___/ .__/ \__,_|\___\___| | # | |_| | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' def inventory_storeonce_clusterinfo_space(parsed): return [ ('Total Capacity', {}) ] def check_storeonce_clusterinfo_space(item, params, parsed): total_mb = float(parsed['Total Capacity (bytes)'])/1024/1024 free_mb = float(parsed['Free Space (bytes)'])/1024/1024 yield df_check_filesystem_list(item, params, [ (item, total_mb, free_mb, 0) ]) dedup = float(parsed['Dedupe Ratio']) yield 0, "Dedup: %.2f" % dedup check_info['storeonce_clusterinfo.space'] = { 'inventory_function' : inventory_storeonce_clusterinfo_space, 'check_function' : check_storeonce_clusterinfo_space, 'service_description' : "%s", 'has_perfdata' : True, 'includes' : [ "size_trend.include", "df.include"], 'group' : "filesystem", 'default_levels_variable' : "filesystem_Default_levels", } #. # .--uptime--------------------------------------------------------------. # | _ _ | # | _ _ _ __ | |_(_)_ __ ___ ___ | # | | | | | '_ \| __| | '_ ` _ \ / _ \ | # | | |_| | |_) | |_| | | | | | | __/ | # | \__,_| .__/ \__|_|_| |_| |_|\___| | # | |_| | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' def inventory_storeonce_clusterinfo_uptime(parsed): return [ (None, {}) ] def check_storeonce_clusterinfo_uptime(item, params, parsed): uptime = float(parsed['Uptime Seconds']) return check_uptime_seconds(params, uptime) check_info['storeonce_clusterinfo.uptime'] = { 'inventory_function' : inventory_storeonce_clusterinfo_uptime, 'check_function' : check_storeonce_clusterinfo_uptime, 'service_description' : "Uptime", 'has_perfdata' : True, 'includes' : [ "uptime.include"], 'group' : "uptime", }