def _check_inodes(levels, inodes_total, inodes_avail): if not inodes_total: return inodes_warn_variant, inodes_crit_variant = levels["inodes_levels"] inodes_warn_abs, inodes_crit_abs, human_readable_func = ( # Levels in absolute numbers ( inodes_total - inodes_warn_variant, inodes_total - inodes_crit_variant, get_number_with_precision, ) if isinstance(inodes_warn_variant, int) else # Levels in percent ( (100 - inodes_warn_variant) / 100.0 * inodes_total, (100 - inodes_crit_variant) / 100.0 * inodes_total, lambda x: get_percent_human_readable(100.0 * x / inodes_total), ) if isinstance(inodes_warn_variant, float) else # (None, None, get_number_with_precision)) inode_status, inode_text, inode_perf = check_levels( inodes_total - inodes_avail, 'inodes_used', (inodes_warn_abs, inodes_crit_abs), boundaries=(0, inodes_total), human_readable_func=human_readable_func, infoname="Inodes Used", ) # Only show inodes if they are at less then 50% show_inodes = levels["show_inodes"] inodes_avail_perc = 100.0 * inodes_avail / inodes_total infotext = ( "%s, inodes available: %s/%s" % ( inode_text, get_number_with_precision(inodes_avail), get_percent_human_readable(inodes_avail_perc), ) # if any(( show_inodes == "always", show_inodes == "onlow" and (inode_status or inodes_avail_perc < 50), show_inodes == "onproblem" and inode_status, )) else "") yield inode_status, infotext, inode_perf
def aws_get_float_human_readable(f, unit=""): return get_number_with_precision(f, unit=unit, precision=3)