def check_hp_proliant_mem(item, params, info): for line in info: if line[1] == item: # Note: mgmt_hp_proliant_mem provides exact 6 values; # hp_proliant provides 10 values because related inventory plugin # needs the last 4. board_index, module_index, module_size, module_type, \ module_status, module_condition = line[:6] yield 0, f"Board: {board_index}" yield 0, f"Num: {module_index}" type_ = MAP_TYPES_MEMORY.get(module_type, f"unknown({module_type})") yield 0, f"Type: {type_}" module_size = get_bytes_human_readable(int(module_size) * 1024) yield 0, f"Size: {module_size}" snmp_status = 'n/a' if int(module_status) in hp_proliant_mem_status_map: snmp_status = hp_proliant_mem_status_map[int(module_status)] status_output = f"Status: {snmp_status}" yield hp_proliant_mem_status2nagios_map[snmp_status], status_output condition = 'n/a' if saveint(module_condition) in hp_proliant_mem_condition_map: condition = hp_proliant_mem_condition_map[saveint( module_condition)] condition_output = f"Condition: {condition}" yield hp_proliant_mem_condition_status2nagios_map[ condition], condition_output
def check_hp_proliant_mem(item, params, info): for line in info: if line[1] == item: # Note: mgmt_hp_proliant_mem provides exact 6 values; # hp_proliant provides 10 values because related inventory plugin # needs the last 4. board_index, module_index, module_size, module_type, \ module_status, module_condition = line[:6] module_size_mb = int(module_size) // 1024 type_ = 'n/a' if int(module_type) in hp_proliant_mem_type_map: type_ = hp_proliant_mem_type_map[int(module_type)] snmp_status = 'n/a' if int(module_status) in hp_proliant_mem_status_map: snmp_status = hp_proliant_mem_status_map[int(module_status)] detail_output = ', Status: %s ' % snmp_status status = hp_proliant_mem_status2nagios_map[snmp_status] if status == 0: detail_output += '' elif status == 1: detail_output += '(!) ' elif status == 2: detail_output += '(!!) ' else: detail_output += '(?) ' condition = 'n/a' if saveint(module_condition) in hp_proliant_mem_condition_map: condition = hp_proliant_mem_condition_map[saveint( module_condition)] condition_status = hp_proliant_mem_condition_status2nagios_map[ condition] detail_output += ', Condition: %s ' % condition if condition_status == 0: detail_output += '' elif condition_status == 1: detail_output += '(!) ' elif condition_status == 2: detail_output += '(!!) ' else: detail_output += '(?) ' if condition_status > status: status = condition_status return (status, 'Board: %s, Num: %s, Type: %s, Size: %s MB%s' % (board_index, module_index, type_, module_size_mb, detail_output)) return (3, "item not found in snmp data")
def inventory_printer_io(info): for line in info: index, name, descr, status = line[:4] if descr == '': continue snmp_status, _capacity_unit, capacity_max, _level = line[3:] if capacity_max == '0': # useless continue ignore = False snmp_status = saveint(status) for state_val in sorted(printer_io_states, reverse=True): if state_val > 0 and snmp_status - state_val >= 0: snmp_status -= state_val # Skip sub units where it does not seem to make sense to monitor them if state_val in (1, 3, 5): ignore = True if ignore is True: continue # When no name is set # a) try to use the description # b) try to use the type otherwise use the index if name == "unknown" or not name: name = descr if descr else index.split('.')[-1] yield (name, {})
def inventory_df_netapp(info): mplist = [] for volume, size_kb, _used_kb in info: if saveint( size_kb ) > 0: # Exclude filesystems with zero size (some snapshots) mplist.append(volume) return df_inventory(mplist)
def inventory_df_netapp(info): mplist = [] for volume, size_kb, _used_kb in info: if saveint( size_kb ) > 0: # Exclude filesystems with zero size (some snapshots) mplist.append(volume) return df_discovery(host_extra_conf(host_name(), filesystem_groups), mplist)
def inventory_hr_fs(info): mplist = [] for hrtype, hrdescr, _hrunits, hrsize, _hrused in info: hrdescr = fix_hr_fs_mountpoint(hrdescr) # NOTE: These types are defined in the HR-TYPES-MIB. # .1.3.6.1.2.1.25.2.1 + # +-> .4 "hrStorageFixedDisk" if hrtype in [ ".1.3.6.1.2.1.25.2.1.4", # This strange value below is needed for VCenter Appliances ".1.3.6.1.2.1.25.2.3.1.2.4"] and \ hrdescr not in inventory_df_exclude_mountpoints and \ saveint(hrsize) != 0: mplist.append(hrdescr) return df_inventory(mplist)
def check_hr_fs(item, params, info): fslist = [] if "Label:" in item or "\\" in item: return 3, "check had an incompatible change, please re-discover services on this host" for _hrtype, hrdescr, hrunits, hrsize, hrused in info: hrdescr = fix_hr_fs_mountpoint(hrdescr) if "patterns" in params or item == hrdescr: unit_size = saveint(hrunits) hrsize = saveint(hrsize) if hrsize < 0: hrsize = hrsize + 2**32 size = hrsize * unit_size hrused = saveint(hrused) if hrused < 0: hrused = hrused + 2**32 used = hrused * unit_size size_mb = size / 1048576.0 used_mb = used / 1048576.0 avail_mb = size_mb - used_mb fslist.append((hrdescr, size_mb, avail_mb, 0)) return df_check_filesystem_list(item, params, fslist)
def inventory_hr_fs(info): mplist = [] for hrtype, hrdescr, _hrunits, hrsize, _hrused in info: hrdescr = fix_hr_fs_mountpoint(hrdescr) # NOTE: These types are defined in the HR-TYPES-MIB. # .1.3.6.1.2.1.25.2.1 + # +-> .4 "hrStorageFixedDisk" if (hrtype in [ ".1.3.6.1.2.1.25.2.1.4", # This strange value below is needed for VCenter Appliances ".1.3.6.1.2.1.25.2.3.1.2.4", ] and hrdescr not in inventory_df_exclude_mountpoints and saveint(hrsize) != 0): mplist.append(hrdescr) return df_discovery(host_extra_conf(host_name(), filesystem_groups), mplist)
def check_dell_poweredge_mem(item, _no_params, info): di = dict() for status, location, size, di['Speed'], di['MFR'], di['P/N'], di['S/N'] in info: di['Size'] = str(int((saveint(size) / 1024.0) / 1024.0)) + "GB" if item == location: state_table = { "1": ("other", 1), "2": ("unknown", 1), "3": ("", 0), "4": ("nonCritical", 1), "5": ("Critical", 2), "6": ("NonRecoverable", 2), } infotext, state = state_table.get(status, ("unknown state", 2)) for parameter, value in di.items(): infotext += ", %s: %s" % (parameter, value) infotext = re.sub("^, ", "", infotext) return state, infotext return 3, "Memory Device not found"
def check_printer_io(item, params, info, what): for line in info: index, name, descr = line[:3] if name == item or descr == item or index.split('.')[-1] == item: snmp_status, capacity_unit, capacity_max, level = line[3:] snmp_status, level, capacity_max = saveint(snmp_status), saveint( level), saveint(capacity_max) if capacity_unit != '': capacity_unit = ' ' + printer_io_units[capacity_unit] state_txt = [] state_state = 0 yield 0, descr if snmp_status == 0: state_txt.append(printer_io_states[0][1]) else: for state_val in sorted(printer_io_states, reverse=True): if state_val > 0 and snmp_status - state_val >= 0: mon_state, text = printer_io_states[state_val] state_state = max(mon_state, state_state) state_txt.append(text) snmp_status -= state_val yield state_state, 'Status: %s' % ', '.join(state_txt) if level in [-1, -2] or level < -3: pass # totally skip this info when level is unknown or not limited elif capacity_max in (-2, -1, 0): # -2: unknown, -1: no restriction, 0: due to saveint yield 0, 'Capacity: %s%s' % (level, capacity_unit) else: state = 0 levels_txt = '' how = 'remaining' if what == 'input' else 'filled' if level == -3: level_txt = "at least one" else: level_perc = 100.0 * level / capacity_max # to percent level_txt = '%0.2f%%' % level_perc if what == 'input': warn, crit = params[ 'capacity_levels'] # percentage levels if crit is not None and level_perc <= crit: state = 2 levels_txt = ' (<= %0.2f)' % crit elif warn is not None and level_perc <= warn: state = 1 levels_txt = ' (<= %0.2f%%)' % warn else: # output warn, crit = params[ 'capacity_levels'] # percentage levels if crit is not None and level_perc >= crit: state = 2 levels_txt = ' (>= %0.2f)' % crit elif warn is not None and level_perc >= warn: state = 1 levels_txt = ' (>= %0.2f%%)' % warn yield state, 'Capacity: %s of %s%s %s%s' % \ (level_txt, capacity_max, capacity_unit, how, levels_txt)