Skip to content

Commit

Permalink
drbd: new nagios plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Fournier committed Feb 15, 2010
1 parent b186fd0 commit dceb19a
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions files/check_drbd
@@ -0,0 +1,79 @@
#!/bin/awk -f

#
# Usage:
# check_drbd /proc/drbd
#

BEGIN {

OK = 000
WARN = 001
ERR = 010

status = OK
count = 0
msg = ""

}

/^[ 0-9]+: / {

# check Connection States
if ( $2 ~ /cs:Connected$/ ) {
status = or(status, OK)

} else if ( $2 ~ /cs:Verif.+/ ) {
msg = sprintf ( "verifying resource %s, %s", count, msg )
status = or(status, WARN)

} else if ( $2 ~ /cs:Sync.+/ ) {
msg = sprintf ( "synchronizing resource %s, %s", count, msg )
status = or(status, WARN)

} else {
msg = sprintf ( "resource %s has connection state \"%s\", %s", count, $2, msg )
status = or(status, ERR)
}

# check Roles
if ( $3 ~ /ro:(Primary|Secondary)\/(Primary|Secondary)$/ ) {
status = or(status, OK)

} else {
msg = sprintf ( "resource %s has role \"%s\", %s", count, $3, msg )
status = or(status, ERR)
}

# check Disk States
if ( $4 ~ /ds:UpToDate\/UpToDate$/ ) {
status = or(status, OK)

} else if ( $4 ~ /ds:.*(Consistent|Outdated).*$/ ) {
msg = sprintf ( "resource %s lost sync but should resync automatically, %s", count, msg )
status = or(status, WARN)

} else {
msg = sprintf ( "resource %s has disk state \"%s\", %s", count, $4, msg )
status = or(status, ERR)
}

count++

}

END {

if ( status == OK ) {
printf("OK: %s resource(s) successfully checked.\n", count)

} else {
# strip off ending comma and add newline.
printf ( "%s.\n", substr( msg, 0, length(msg) - 2 ))
}

if ( status >= 8) { exit 2 }
else if ( status >= 1) { exit 1 }
else { exit 0 }

}

0 comments on commit dceb19a

Please sign in to comment.