Solved

Nagios Custom Plug-in how to install?

Posted on 2011-03-18
27
1,429 Views
Last Modified: 2012-05-11
Hi I have downloaded 'check_wbinfo' plug-in for nagios from the following website:

http://exchange.nagios.org/directory/Plugins/Uncategorized/Operating-Systems/Linux/Check-Winbind/details

I have never installed a custom plug-in before so I would like to find out how to do that?
I am using Nagios 2.x, my nagios plug in directory is located at:
/usr/lib/nagios/plugins

Thanks
0
Comment
Question by:Turbowy
  • 13
  • 8
  • 5
  • +1
27 Comments
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35166832
Place the file (check_winbind) in the Nagios libexec folder where the other plugins reside.  Then add the plugin to your configuration with the required parameters for whatever server you want to use with.
0
 

Author Comment

by:Turbowy
ID: 35168210
Ok I put in this plug in with the rest of my plugins.
then I  defined this service


define service{
        use                     generic-service
        host_name               myserver.domain.com
        service_description     WBINFO
        check_command           check_wbinfo!myserver.domain.com
        contact_groups          sysadmins
}


I get this error when checking nagios configuration:

Error: Service check command 'check_wbinfo' specified in service 'WBINFO' for host 'myhost.domain.com' not defined anywhere!

What do I need to do next?

0
 
LVL 5

Expert Comment

by:group0
ID: 35183015
You need to define the command before you define the service that references it, like so:

define command {
      command_name      sample_command
      command_line            $USER1$/check_sample_command -H $HOSTADDRESS$ -w $ARG1$ -C $ARG2$
}

define service {
      use                        generic-service
      hostname                  myserver.domain.com
      service_description      sample
      check_command      sample_command!10!20
}

The command definition tells Nagios how to actually execute the plugin.

However, looking at the check_wbinfo plugin you linked to, it looks like it doesn't take any arguments, so you'd need to run it directly off of whatever server you need, either with check_by_ssh or NRPE.
0
 
LVL 6

Expert Comment

by:mohansahu
ID: 35205317
Hi,

1.You'll need to create a command definition in one of your Nagios object configuration files in order to use the check_nrpe plugin. Open the sample commands.cfg file for editing...
vi /usr/local/nagios/etc/commands.cfg and add the following definition to the file:

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

You are now ready to start adding services that should be monitored on the remote machine to the Nagios
configuration...

2.Create host and service definitions

Next, define a new host for the remote Linux/Unix box that references the newly created linux-box host template.

define host{
use linux-box ; Inherit default values from a template
host_name remotehost ; The name we're giving to this server
alias Fedora Core 6 ; A longer name for the server
address 192.168.0.1 ; IP address of the server
}

The following service will monitor the the number of currently logged in users on the remote host.
define service{
use generic-service
host_name remotehost
service_description Current Users
check_command check_nrpe!check_users
}

3.Restart the nagios

Verify your Nagios configuration files.
MS



0
 

Author Comment

by:Turbowy
ID: 35209436
I went to the following directory on my Nagios server:
/etc/nagios-plugins/config

In that directory there is a following file:
check_nrpe.cfg

that has the following defined:
nagios:/etc/nagios-plugins/config# cat check_nrpe.cfg
# this command runs a program $ARG1$ with arguments $ARG2$
define command {
        command_name    check_nrpe
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

# this command runs a program $ARG1$ with no arguments
define command {
        command_name    check_nrpe_1arg
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

so it looks like I have what i need.

But I still do not understand how I can call the check_wbinfo plug-in referenced in my first
question using check_nrpe. Can you provided step on how to configure Nagios from here to use the check_wbinfo
plug in?

Thanks
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35209560
Look in the nrpe file (usually /etc/xinetd.d/nrpe) and check the location server_args file.
In that file are the definitions for nrpe checks.
Add a line for this check.  The plugin would need to be copied to the plugins folder on the box you are running the check on.
command[check_wbinfo]=/<path to plugins>/check_wbinfo <arguments>

Open in new window

0
 

Author Comment

by:Turbowy
ID: 35210288
Hi seth, I checked in /etc/xinetd.d but there is nothing there, any ohter ideas?
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35210530
then your system is configured differently...what linux distribution are you using and how did you install?
0
 

Author Comment

by:Turbowy
ID: 35210734
This is Debian, I did not install it it was already here when I came on board!
0
 
LVL 5

Expert Comment

by:group0
ID: 35211699
Just to clarify, NRPE is a remote execution service.  seth2740 is asking you to check the NRPE client configuration on the host you wish to run check_wbinfo against, not on the main nagios server.  However, different distros may have the NRPE client configuration in different places.

If all of the hosts (nagios server and the one to be checked) are running debian, this page may help:
http://debianclusters.org/index.php/Nagios_NRPE_Addon_Installation_and_Configuration

Note that you will need to copy check_wbinfo to the target server and ensure that the script is executable by whatever user the NRPE client runs under.
0
 

Author Comment

by:Turbowy
ID: 35215532
Hi group0, thank you for the clarification. The host that I want to run the check against is a RedHat Enterprise 6. I run rpm -qa | grep -i nrpe and this package is not installed. Where can i download nrpe package for redhat?
0
 
LVL 5

Expert Comment

by:group0
ID: 35217177
If "yum install nagios-nrpe" doesn't work, you can download and install the RPMs manually using the instructions here:
http://nagioswiki.com/wiki/index.php/Installing_NPRE_via_RPM

0
 

Author Comment

by:Turbowy
ID: 35234916
Ok, I have installed NRPE and Nagios plug-ins on my RedHat machine. I have copied the ' wbinfo ' script to the nagios plug in directory in:

/usr/lib64/nagios/plugins

and added check command to my nrpe configuration in:

/etc/xinetd.d/nrpe

Here is the configuration:

# default: off
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
    type        = UNLISTED
    port        = 5666
        socket_type     = stream
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/sbin/nrpe
        server_args     = -c /etc/nagios/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = yes
        only_from       = 127.0.0.1
}

# this command runs a program $ARG1$ with no arguments
define command {
        command_name    check_wbinfo
                command_line    /usr/lib64/nagios/plugins/check_wbinfo
                }


Can someone tell me if this is good and what do I do next?

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35235430
You need to change the only_from to the ip address of the nagios server; by default it's only accepting from localhost.  After that change, restart xinetd.

the define command goes in your nagios configuration file, not the nrpe file for xinetd.
0
 

Author Comment

by:Turbowy
ID: 35235577
Ok This is what I did:
On my RedHat machine in /etc/xinetd.d/nrpe I have the following configuration:



 
# default: off
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
    type        = UNLISTED
    port        = 5666
        socket_type     = stream
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/sbin/nrpe
        server_args     = -c /etc/nagios/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = yes
        only_from       = 172.20.25.2
}

Open in new window



On my RedHat machine in /etc/nagios/nrpe.cfg I have the following configuration:

 
#############################################################################
# Sample NRPE Config File
# Written by: Ethan Galstad (nagios@nagios.org)
#
# Last Modified: 11-23-2007
#
# NOTES:
# This is a sample configuration file for the NRPE daemon.  It needs to be
# located on the remote host that is running the NRPE daemon, not the host
# from which the check_nrpe client is being executed.
#############################################################################


# LOG FACILITY
# The syslog facility that should be used for logging purposes.

log_facility=daemon



# PID FILE
# The name of the file in which the NRPE daemon should write it's process ID
# number.  The file is only written if the NRPE daemon is started by the root
# user and is running in standalone mode.

pid_file=/var/run/nrpe.pid



# PORT NUMBER
# Port number we should wait for connections on.
# NOTE: This must be a non-priviledged port (i.e. > 1024).
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

server_port=5666

# SERVER ADDRESS
# Address that nrpe should bind to in case there are more than one interface
# and you do not want nrpe to bind on all interfaces.
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

server_address=172.20.25.2



# NRPE USER
# This determines the effective user that the NRPE daemon should run as.
# You can either supply a username or a UID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_user=nagios



# NRPE GROUP
# This determines the effective group that the NRPE daemon should run as.
# You can either supply a group name or a GID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_group=nagios



# ALLOWED HOST ADDRESSES
# This is an optional comma-delimited list of IP address or hostnames
# that are allowed to talk to the NRPE daemon.
#
# Note: The daemon only does rudimentary checking of the client's IP
# address.  I would highly recommend adding entries in your /etc/hosts.allow
# file to allow only the specified host to connect to the port
# you are running this daemon on.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

#allowed_hosts=172.20.65.99



# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients
# to specify arguments to commands that are executed.  This option only works
# if the daemon was configured with the --enable-command-args configure script
# option.
#
# *** ENABLING THIS OPTION IS A SECURITY RISK! ***
# Read the SECURITY file for information on some of the security implications
# of enabling this variable.
#
# Values: 0=do not allow arguments, 1=allow command arguments

dont_blame_nrpe=1



# COMMAND PREFIX
# This option allows you to prefix all commands with a user-defined string.
# A space is automatically added between the specified prefix string and the
# command line from the command definition.
#
# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! ***
# Usage scenario:
# Execute restricted commmands using sudo.  For this to work, you need to add
# the nagios user to your /etc/sudoers.  An example entry for alllowing
# execution of the plugins from might be:
#
# nagios          ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/
#
# This lets the nagios user run all commands in that directory (and only them)
# without asking for a password.  If you do this, make sure you don't give
# random users write access to that directory or its contents!

# command_prefix=/usr/bin/sudo

# DEBUGGING OPTION
# This option determines whether or not debugging messages are logged to the
# syslog facility.
# Values: 0=debugging off, 1=debugging on

debug=0



# COMMAND TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will
# allow plugins to finish executing before killing them off.

command_timeout=60



# CONNECTION TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will
# wait for a connection to be established before exiting. This is sometimes
# seen where a network problem stops the SSL being established even though
# all network sessions are connected. This causes the nrpe daemons to
# accumulate, eating system resources. Do not set this too low.

connection_timeout=300



# WEEK RANDOM SEED OPTION
# This directive allows you to use SSL even if your system does not have
# a /dev/random or /dev/urandom (on purpose or because the necessary patches
# were not applied). The random number generator will be seeded from a file
# which is either a file pointed to by the environment valiable $RANDFILE
# or $HOME/.rnd. If neither exists, the pseudo random number generator will
# be initialized and a warning will be issued.
# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness

#allow_weak_random_seed=1
# INCLUDE CONFIG FILE
# This directive allows you to include definitions from an external config file.

#include=<somefile.cfg>



# INCLUDE CONFIG DIRECTORY
# This directive allows you to include definitions from config files (with a
# .cfg extension) in one or more directories (with recursion).

#include_dir=<somedirectory>
#include_dir=<someotherdirectory>



# COMMAND DEFINITIONS
# Command definitions that this daemon will run.  Definitions
# are in the following format:
#
# command[<command_name>]=<command_line>
#
# When the daemon receives a request to return the results of <command_name>
# it will execute the command specified by the <command_line> argument.
#
# Unlike Nagios, the command line cannot contain macros - it must be
# typed exactly as it should be executed.
#
# Note: Any plugins that are used in the command lines must reside
# on the machine that this daemon is running on!  The examples below
# assume that you have plugins installed in a /usr/local/nagios/libexec
# directory.  Also note that you will have to modify the definitions below
# to match the argument format the plugins expect.  Remember, these are
# examples only!


# The following examples use hardcoded command arguments...

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200
command[check_wbinfo]=/usr/lib64/nagios/plugins/check_wbinfo


# The following examples allow user-supplied arguments and can
# only be used if the NRPE daemon was compiled with support for
# command arguments *AND* the dont_blame_nrpe directive in this
# config file is set to '1'.  This poses a potential security risk, so
# make sure you read the SECURITY file before doing this.

#command[check_users]=/usr/lib64/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
#command[check_load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
#command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
#command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

Open in new window



On my Nagios machine I have set up the following service:

 
define service{
        use                    generic-service
        host_name              myhost.com
        service_description    WBINFO
        check_command          check_nrpe!myhost.com
        contact_groups         sysadmins
}

Open in new window


But im getting this in the Nagios web admin:

WBINFO    
 
 UNKNOWN 2011-03-28 15:55:46 0d 0h 55m 15s 3/3 (No output returned from plugin)  

any other ideas?
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35235881
in your service definition, it should be check_nrpe!check_wbinfo (needs to match what you have in your nrpe.cfg)

you have it listed as check_nrpe!myhost.com which is telling Nagios to look for a command called myhost.com

0
 

Author Comment

by:Turbowy
ID: 35235941
Same problem persists... I have also tried running the following command from the nagios server and got this out put

./check_nrpe -H home.akn.ca -c check_wbinfo

[wbinfo -t] Failed Winbind

So it looks at it is talking with the nrpe daemon on the redhat server but not working right... do you know what else I can check?
0
 
LVL 5

Expert Comment

by:group0
ID: 35236679
No it's working properly, if you check the contents of check_wbinfo that string indicates the test itself failed (run command "wbinfo -t", return critical if it exited with a non-zero return code).
0
 

Author Comment

by:Turbowy
ID: 35236740
Ok I see some improvement, now I have the following error message in my nagios web admin:

WBINFO
   
 
 CRITICAL 2011-03-28 18:31:46 0d 1h 43m 15s 3/3 CHECK_NRPE: Error - Could not complete SSL handshake.  

any ideas how I can fix that?
0
 
LVL 5

Expert Comment

by:group0
ID: 35237249
Check the macro in your nrpe command definition to verify that you're passing it $HOSTADDRESS$, and that the host you have the service associated with has the correct address defined.  This should match the IP from your earlier successful command-line test.
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35237524
look in your commands.cfg file and find the definition for check_nrpe.  On that command line, include -n so check_nrpe doesn't try to use SSL.
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 35237541
This is what your command would look like.
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -n
        }

Open in new window

0
 

Author Comment

by:Turbowy
ID: 35237585
ok now it says

nagios:/usr/lib/nagios/plugins# ./check_nrpe -H aknl016 -c check_wbinfo
[wbinfo -t] Failed Winbind
0
 

Author Comment

by:Turbowy
ID: 35237607
Ok now it says

Current Status:   UNKNOWN  (Has been acknowledged)  
Status Information: (No output returned from plugin)

im loosing my patience slowly with this nagios crap!
0
 
LVL 34

Accepted Solution

by:
Seth Simmons earned 500 total points
ID: 35237705
When you made those changes to the configuration files, did you restart or reload nagios?
0
 

Author Comment

by:Turbowy
ID: 35237715
Yes, i reloaded nagios, im totally puzzled here...
0
 

Author Comment

by:Turbowy
ID: 35240986
Guys, I was wandering if these errors have anything to do with my problem?

Mar 29 09:16:11 aknl016 xinetd[9453]: bind failed (Address already in use (errno = 98)). service = nrpe
Mar 29 09:16:11 aknl016 xinetd[9453]: Service nrpe failed to start and is deactivated.
Mar 29 09:16:11 aknl016 xinetd[9453]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
Mar 29 09:16:11 aknl016 xinetd[9453]: Started working: 2 available services
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now