38 lines
984 B
Python
Executable file
38 lines
984 B
Python
Executable file
#!/usr/bin/env python3
|
|
import os
|
|
import argparse
|
|
import sys
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-p','--path',
|
|
help='Path to work on',
|
|
required=True)
|
|
parser.add_argument('-w', '--warning',
|
|
help='Warning threashold',
|
|
required=True)
|
|
parser.add_argument('-c', '--critical',
|
|
help='Critical threashold',
|
|
required=True)
|
|
|
|
args = parser.parse_args()
|
|
path = args.path
|
|
warning = float(args.warning)
|
|
critical = float(args.critical)
|
|
|
|
st = os.statvfs(path)
|
|
total_inode = st.f_files # total inodes
|
|
free_inode = st.f_ffree # free inodes
|
|
percent = (free_inode / total_inode) * 100
|
|
|
|
status = "OK"
|
|
exit = 0
|
|
if percent < warning:
|
|
status = "WARNING"
|
|
exit = 1
|
|
if percent < critical:
|
|
status = "critical"
|
|
exit = 2
|
|
|
|
print("{0}: {1} {2:.2f}% free | free_inodes_percent={2:.2f}%;{3};{4};".format(status, path, percent,warning,critical))
|
|
sys.exit(exit)
|