Problem solving for Nagios use

Source: Internet
Author: User

Problem solving for Nagios use

1. Modify a service times error via the Web interface

For example, if a service is temporarily scheduled for its execution time, or if it is not warned, there are settings on the Web page. However, there are often error messages as follows:

Could not open command file '/usr/local/nagios/var/rw/nagios.cmd ' for update!

The permissions on the external command file and/or directory is incorrect. Read the FAQs on what to setup proper permissions.

An error occurred while attempting to commit your command for processing.

This section has the following content in Nagios.cfg

# EXTERNAL COMMAND FILE

# This is the file, the Nagios checks for external command requests.

# It is also where the command CGI would write commands that was submitted

# by users, so it must is writeable by the user that the Web server

# is running as (usually ' nobody '). Permissions should be set at the

# directory level instead in the file, as the file is deleted every

# time its contents is processed.

The central meaning of this passage is that Apache's running users have permission to write to the file. Permissions should be set on the directory, because each time the contents of the file is processed, the file is deleted.

Command_file=/usr/local/nagios/var/rw/nagios.cmd

It should be possible to add the apache2 running user Apache to the Nagios group.

But this does not work, will be RW this directory and its sub-file permissions changed 777, so you can.

Later found Nagios.cmd's authority or automatically changed back to the RW-RW----, but the command has not been affected, no error. (Do you want to restart Nagios for it to take effect?)

2.nagios Special configuration for warning messages

Nagios Send warning message is a native SMTP service, you can view the commands.cfg in the message about the definition of the command, using the local Mail command, which requires the SMTP service to turn on the computer, in order to secure the firewall can be set to deny the other machine connected to the machine Port 25th

Now there is a mail server in our network, so it requires the use of this existing mail server, do not turn on the native SMTP service, this need to redefine the command using third-party software SendEmail.

First of all, of course we have to create a new account on the mail server to send e-mail accounts

The address of the mail server here is mail.test.com

The account used to send the email [email protected]

User name for SMTP authentication nagios password P#3isoda

Here is a brief introduction to the use of the SendEmail software.

SendEmail's homepage [Url]http://caspian.dotconf.net/menu/software/sendemail/[/url]

[Url]http://caspian.dotconf.net/menu/software/sendemail/sendemail-v1.55.tar.gz[/url]

Software is very small, is a command to send SMTP mail program. The installation is also very simple (see its readme file).

Decompression TAR–ZXVF sendemail-v1.55.tar.gz

CD sendemail-v1.55

Copy the executable program to CP Sendemail/usr/local/bin

Then give confirmation that it does have execute permissions

Ll/usr/local/bin/sendemail

-rwxr-xr-x 1 root root 77882 11-03 14:23/usr/local/bin/sendemail

This procedure is installed, and the use is very simple. Run SendEmail directly to show detailed usage

Let's look at a typical example.

/usr/local/bin/sendemail –f [email protected] –t [email protected] –s mail.test.com–u "from Nagios" –xu nagios–xp p#3isoda– M Happy

Explain:

-F means the sender's mailbox

-T indicates the recipient's mailbox

-S indicates the domain name or IP of the SMTP server

-U represents the subject of the message

-xu represents the user name for SMTP authentication

-XP represents the password for SMTP authentication (note that this password seems to be limited, for example, I cannot be correctly identified with D!5neyland)

-M indicates the contents of the message

If you don't have the-m parameter, you'll be prompted to enter it yourself.

Reading message body from STDIN because the '-m ' option is not used.

If you is manually typing in a message:

-First line must is received within seconds.

-End manual input with a ctrl-d on it own line

Use ctrl-d to end when input is complete

Of course, we can also send the contents of a file as the body of the message.

Then you can use:

Cat file name |/usr/local/bin/sendemail–f [email protected] –t [email protected] –s mail.test.com–u "from Nagios" –xu nagios–xp p#3isoda

The use of SendEmail is here.

Now that Nagios is going to use SendEmail to send a warning message, we need to modify the definition of the COMMANDS.CFG command in the e-mail, so let's modify the Notify-by-email command as follows (note the bold part)

# ' notify-by-email ' command definition

Define Command{

Command_name Notify-by-email

command_line/usr/bin/printf "%b" "* * * * Nagios 2.9 *****\n\nnotification Type: $NOTIFICATIONTYPE $\n\nservice: $SERVICE Desc$\nhost: $HOSTALIAS $\naddress: $HOSTADDRESS $\nstate: $SERVICESTATE $\n\ndate/time: $LONGDATETIME $\n\nadditional info:\n\n$serviceoutput$ "| /usr/local/bin/sendemail-f [email protected] - T $CONTACTEMAIL $-S Mail.test.com-u "* * $NOTIFICATIONTYPE $ alert-$HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ * *"-xu nagios-xp p#3isoda

}

Note: In fact, SendEmail is a very useful program, we use it in this place, in fact, other places can also be used, the typical advantage is that you do not need each machine is installed SendMail, open the SMTP service. Just use a ready-made mail server, This undoubtedly greatly strengthens the system security, but also saves the resources.

Problem solving for Nagios use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.