Skip to content

Commit

Permalink
Add "zpool nagios" command
Browse files Browse the repository at this point in the history
(Though it could use improvement, this feature is working.)

The "zpool nagios" command behaves as a Nagios plugin - output a
single line of status information to stdout and exit with a status
code (0=OK, 1=Warning, 2=Critical, 3=Unknown).

There are a few cases that could use improvement for multi-pool
systems, and not all failure scenarios are tested, but it's
certainly a step in the right direction.

TODO:
* Specify pools which must be present on the system
* Additional testing. I don't have a lot of broken pools to mess with.
* Deadman timer of sorts in case ioctls hang
  • Loading branch information
DeHackEd committed May 25, 2015
1 parent d9a1396 commit 484f14b
Show file tree
Hide file tree
Showing 4 changed files with 821 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/zpool/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ zpool_SOURCES = \
$(top_srcdir)/cmd/zpool/zpool_main.c \
$(top_srcdir)/cmd/zpool/zpool_util.c \
$(top_srcdir)/cmd/zpool/zpool_util.h \
$(top_srcdir)/cmd/zpool/zpool_vdev.c
$(top_srcdir)/cmd/zpool/zpool_vdev.c \
$(top_srcdir)/cmd/zpool/zpool_nagios.c

zpool_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
10 changes: 9 additions & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@

#include "statcommon.h"

/* External */
int zpool_do_nagios(int, char**);

static int zpool_do_create(int, char **);
static int zpool_do_destroy(int, char **);

Expand Down Expand Up @@ -139,7 +142,8 @@ typedef enum {
HELP_SET,
HELP_SPLIT,
HELP_REGUID,
HELP_REOPEN
HELP_REOPEN,
HELP_NAGIOS
} zpool_help_t;


Expand Down Expand Up @@ -193,6 +197,8 @@ static zpool_command_t command_table[] = {
{ NULL },
{ "get", zpool_do_get, HELP_GET },
{ "set", zpool_do_set, HELP_SET },
{ NULL },
{ "nagios", zpool_do_nagios, HELP_NAGIOS },
};

#define NCOMMAND (sizeof (command_table) / sizeof (command_table[0]))
Expand Down Expand Up @@ -276,6 +282,8 @@ get_usage(zpool_help_t idx) {
"[<device> ...]\n"));
case HELP_REGUID:
return (gettext("\treguid <pool>\n"));
case HELP_NAGIOS:
return (gettext("\tnagios [-o] [-w] [-c] [pool ...]\n"));
}

abort();
Expand Down
Loading

0 comments on commit 484f14b

Please sign in to comment.