Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:ioguix:check_pgactivity
monitoring-plugins-symlinks
check_symlinks
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File check_symlinks of Package monitoring-plugins-symlinks
#!/bin/bash VERSION="1.0" PATHNAME="/srv" DEBUG=0 LINKCOUNT=0 FAILEDLINK=0 if [ -r '/usr/lib/nagios/plugins/utils.sh' ]; then . /usr/lib/nagios/plugins/utils.sh else echo "UNKOWN: could not read /usr/lib/nagios/plugins/utils.sh" exit 3 fi function print_help(){ echo "Usage: $(basename $0) -p <path>" echo " checks symlinks in <path> for correctness" echo print_revision "$(basename $0)" "$VERSION" support exit $STATE_OK } while getopts "hp:dv" OPTION; do case $OPTION in h) print_help ;; v) print_revision "$(basename $0)" "$VERSION" exit "$STATE_OK" ;; p) PATHNAME="$OPTARG" ;; d) DEBUG=1 ;; esac done if [ ! -d "$PATHNAME" ]; then echo "UNKOWN: path '$PATHNAME' not found or not exist" exit $STATE_UNKNOWN fi pushd "$PATHNAME" >/dev/null for dir in $(/bin/ls -d "$PATHNAME"/*); do if [ "$DEBUG" == "1" ]; then echo "Testing: $dir"; fi for link in $(readlink -s "$dir"); do if [ "$DEBUG" == "1" ]; then echo "$dir is link, checking for referenced $link"; fi let LINKCOUNT=$LINKCOUNT+1 if [ ! -d "$link" ]; then if [ ! -f "$link" ]; then let FAILEDLINK=$FAILEDLINK+1 OUTPUT="'$PATHNAME/$link' broken; $OUTPUT" fi fi done done popd >/dev/null if [ -z "$OUTPUT" ]; then echo "OK: $LINKCOUNT links checked without error" exit $STATE_OK else echo "CRITICAL: $FAILEDLINK/$LINKCOUNT link(s) broken -> $OUTPUT" exit $STATE_CRITICAL fi
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor