Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nagios-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
nagios-plugin
Commits
02528416
Commit
02528416
authored
6 years ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
Added check_mountpoints script
parent
efec9792
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_mountpoints.sh
+104
-0
104 additions, 0 deletions
check_mountpoints.sh
with
104 additions
and
0 deletions
check_mountpoints.sh
0 → 100755
+
104
−
0
View file @
02528416
#!/bin/bash
PROGNAME
=
$(
basename
$0
)
STATE_OK
=
0
STATE_WARNING
=
1
STATE_CRITICAL
=
2
INVERSE
=
0
FSTAB_STATUS
=
0
MOUNTED_STATUS
=
0
MOUNTS
=
/proc/mounts
MTAB
=
/etc/mtab
FSTAB
=
/etc/fstab
function
usage
()
{
echo
"Usage:
$PROGNAME
\$
mountpoint [
\$
mountpoint2 ...]"
echo
"Usage:
$PROGNAME
-h,--help"
echo
"Options:"
echo
" -I Inverse results (OK if not mounted, WARNING if mounted)"
echo
" MOUNTPOINT list of mountpoint to check. MANDATORY"
}
function
print_help
()
{
echo
""
echo
"This module checks if a mountpoint is defined in
${
FSTAB
}
, and whether it is mounted"
echo
"by checking
${
MTAB
}
,
${
MOUNTS
}
and mountpoint program"
echo
""
usage
echo
""
}
# --------------------------------------------------------------------
# startup checks
# --------------------------------------------------------------------
if
[
$#
-eq
0
]
;
then
usage
exit
$STATE_CRITICAL
fi
while
[
"
$1
"
!=
""
]
do
case
"
$1
"
in
-I
)
INVERSE
=
1
;
shift
;;
/
*
)
MP
=
"
$1
"
;
shift
;;
*
)
usage
;
exit
$STATE_UNKNOWN
;;
esac
done
if
[
-z
"
${
MP
}
"
]
;
then
echo
"ERROR: no mountpoint given!"
usage
exit
$STATE_UNKNOWN
fi
## check FSTAB mounts
if
[
!
-z
"
$(
grep
${
MP
}
${
FSTAB
}
)
"
]
then
FSTAB_STATUS
=
1
fi
# check MOUNTS mounts
if
[
!
-z
"
$(
grep
${
MP
}
${
MOUNTS
}
)
"
]
then
# check MTAB mounts
if
[
!
-z
"
$(
grep
${
MP
}
${
MTAB
}
)
"
]
then
## check mountpoint
if
[
$(
mountpoint
-q
${
MP
}
;
echo
$?
)
-eq
0
]
then
MOUNTED_STATUS
=
1
fi
fi
fi
if
[
$MOUNTED_STATUS
-eq
0
]
then
if
[
$INVERSE
-eq
0
]
then
echo
"CRITICAL:
${
MP
}
not mounted"
exit
$STATE_CRITICAL
else
echo
"OK:
${
MP
}
not mounted"
exit
$STATE_OK
fi
else
if
[
$FSTAB_STATUS
-eq
0
]
then
echo
"WARNING:
${
MP
}
mounted but not defined in fstab"
exit
$STATE_WARNING
else
if
[
$INVERSE
-eq
0
]
then
echo
"OK:
${
MP
}
mounted"
exit
$STATE_OK
else
echo
"WARNING:
${
MP
}
mounted"
exit
$STATE_WARNING
fi
fi
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment