Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added INCLUDE_FSTYPE option #785

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions check-plugins/disk-usage/disk-usage
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ def parse_args():
default=DEFAULT_WARN,
)

parser.add_argument(
'--include-fstype',
help='Add the filesystem type you want to check'
'Implies psutil.disk_partitions(all=True)'
'If no type is supplied psutil.disk_partitions(all=False) is used'
'Includes are matched before excludes.',
dest='INCLUDE_FSTYPE',
action='append',
default=[],
)

return parser.parse_args()


Expand Down Expand Up @@ -198,7 +209,10 @@ def main():

# analyze data
try:
parts = psutil.disk_partitions(all=False)
if args.INCLUDE_FSTYPE:
parts = psutil.disk_partitions(all=True)
else:
parts = psutil.disk_partitions(all=False)
except AttributeError:
lib.base.oao(
'Did not find physical devices (e.g. hard disks, cd-rom drives, USB keys).',
Expand All @@ -214,8 +228,11 @@ def main():
# opts='ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500'
# )
# ignore `/snap`, iso mountpoints and cdroms (UDF = universal disk format)
if part.fstype in ['CDFS', 'iso9660', 'squashfs', 'UDF'] or part.opts in ['cdrom']:
if args.INCLUDE_FSTYPE and part.fstype not in args.INCLUDE_FSTYPE:
continue
else:
if part.fstype in ['CDFS', 'iso9660', 'squashfs', 'UDF'] or part.opts in ['cdrom']:
continue

# include (first) and exclude (second) specific partitions
# hint: we can't do `if not part or part.mountpoint in args.IGNORE:` because it is
Expand Down