Skip to content

Commit

Permalink
Add nagios plugin documentation and example files.
Browse files Browse the repository at this point in the history
  • Loading branch information
liske committed May 19, 2015
1 parent dcb1050 commit 1680da8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.nagios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
needrestart - nagios plugin mode
================================

Needrestart can be used as a nagios plugin:

```console
# needrestart -p
CRIT - Kernel: 3.16.0-4-amd64, Services: none, Containers: 1 (!), Sessions: none|Kernel=0;0;;0;2 Services=0;;0;0 Containers=1;;0;0 Sessions=0;0;;0
```

Since needrestart requires root privileges to scan processes of other
users you should use sudo. Needrestart ships some example files to run
needrestart as nagios plugin using sudo:

- `ex/nagios/check_needrestart` - calls sudo to invoke needrestart
- `ex/nagios/needrestart` - sudo(8) config allowing nagios to run needrestart as root
- `ex/nagios/check_needrestart.conf` - nagios(8) integration
18 changes: 18 additions & 0 deletions ex/nagios/check_needrestart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# needrestart - Restart daemons after library updates.
#
# Authors:
# Thomas Liske <thomas@fiasko-nw.net>
#
# Copyright Holder:
# 2013 - 2015 (C) Thomas Liske [http://fiasko-nw.net/~thomas/]
#
# License:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#

exec sudo -n -- /usr/sbin/needrestart -p
8 changes: 8 additions & 0 deletions ex/nagios/needrestart-nagios
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# needrestart nagios plugin sudoers.d config file
# -----------------------------------------------
#
# Please consider a look at /etc/sudoers.d/README howto enable this file.
#

# Allow nagios to execute the needrestart command
nagios ALL=NOPASSWD: /usr/sbin/needrestart -p
13 changes: 13 additions & 0 deletions ex/nagios/plugin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## remember: check_needrestart is a local check only
define command {
command_name check_needrestart
command_line /usr/lib/nagios/plugins/check_needrestart
}

## example service
#define service {
# host_name localhost
# service_description NEEDRESTART
# check_command check_needrestart
# use generic-service
#}

0 comments on commit 1680da8

Please sign in to comment.