Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Configure Nagios with MySQL and Apache2
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
njcwotx
Guru
Guru


Joined: 25 Feb 2005
Posts: 564
Location: Texas

PostPosted: Tue Aug 09, 2005 6:43 pm    Post subject: Reply with quote

when I try to execute a command from the web interface, I get
Quote:
"Error: Could not open command file '/var/nagios/rw/nagios.cmd' for update!"


Playing with permissions, I found as a test I could
Code:
'chmod 777 /var/nagios/rw/nagios.cmd'

and get it to work. however eventually it will change back to this...
Code:
prw-rw----  1 nagios nagios     0 Aug 9 13:30 nagios.cmd


So, I am having some form of permissions problem.

---added later --
apparently if I set rw to all others, it will work, so I must not be settings a user setup correctly..

[Solved]
added apache user to nagios group. sounds like a security hole to me...if anyone has anything better.
_________________
Drinking from the fountain of knowldege.
Sometimes sipping.
Sometimes gulping.
Always thirsting.
Back to top
View user's profile Send private message
jmarcus
Apprentice
Apprentice


Joined: 12 Jun 2004
Posts: 197

PostPosted: Wed Aug 10, 2005 2:34 pm    Post subject: Reply with quote

Not sure if I missed this information in the thread but here is the stuff I needed to put in commonapache2.conf

Code:
###
### Nagios Stuff
###
ScriptAlias /nagios/cgi-bin/ /usr/nagios/sbin/
<Directory "/usr/nagios/sbin">
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

Alias /nagios /usr/nagios/share
<Directory "/usr/nagios/share">
    Options NOne
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
</Directory>


Code:
/etc/init.d/apache2 restart
Back to top
View user's profile Send private message
morlix
n00b
n00b


Joined: 14 Feb 2004
Posts: 59
Location: Germany

PostPosted: Wed Aug 24, 2005 7:50 pm    Post subject: Reply with quote

i have exactly the same problem as Tuttle.

if i executed the nagios_check_command on the shell i get

Code:
Nagios ok: located 1 process, status log updated 15 seconds ago


i searched and searched and searched, but i didn´t find a error...

does someone know how to get this fixed?

grZ morlix

*** Update ***

if i disable the nagios_check_commnd everything is working fine, except that i become the following message

Check Command Output: No process check command has been defined in your CGI configuration file.
Nagios process is assumed to be running properly.
Back to top
View user's profile Send private message
richard.scott
Veteran
Veteran


Joined: 19 May 2003
Posts: 1497
Location: Oxfordshire, UK

PostPosted: Wed Oct 05, 2005 1:19 pm    Post subject: Reply with quote

I had the same problem and this fixed it for me:

Code:
#chmod +rx -R /usr/nagios/libexec/


it seems that the execution rights for the plugins are restricted to just the group and owner of nagios.

so another way to fix it is to add apache to the nagios group with the following if you want to keep the restrictive execution rights on the plugins:

Code:
usermod -g apache -G nagios apache
Back to top
View user's profile Send private message
JofCore
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2004
Posts: 116

PostPosted: Tue Oct 18, 2005 9:31 pm    Post subject: Nagios 2.0b4 doesn't stat at boot on Gentoo Reply with quote

Hello,

I have manually installed Nagios 2.0b4 on my Gentoo box (2.0 wasn't in portage...). Everything is configured and working great, but I have one problem: Nagios won't start on boot.

when the machine boots, I see all the services being started fine, but when it gets to nagios, all I get is the syntax of the startup script:
Code:
Usage: nagios {start|stop|restart|reload|force-reload|status}

instead of the normal "ok" or "!!" indicator.

After the machine boots, I checked it out and sure enough nagios wasn't running. The /etc/init.d/nagios startup script runs fine if I run it as root from the CLI though...

Upon further investigation, I believe I know why it's not starting on boot, but I don't know how to fix it. I looked @ the top of the nagios init script and noticed that the bang line is using #!/bin/sh instead of #!/sbin/runscript like most of the gentoo startup scripts do. If I change the bang line to #!/sbin/runscript, then I get the same behaviour out of the script that I'm seeing on boot (only displays the syntax).

Also, I have noticed that the "rc-status" command on gentoo never shows nagios running, even if it is:
Code:
sendmail                                                            [ started ]
snmpd                                                               [ started ]
named                                                               [ started ]
tomcat5                                                             [ started ]
distccd                                                             [ started ]
gkrellmd                                                            [ started ]
ntpd                                                                [ started ]
lm_sensors                                                          [ started ]
nagios                                                                [   off ]


And nagios is definately running:
Code:
/etc/init.d/nagios status
  PID TTY          TIME CMD
 9415 ?        00:01:53 nagios


So I guess what I'm wondering is what needs to be changed in the init script to make it work better w/gentoo. As I said, I tried changing the bang line to #!/sbin/runscript, but that just makes the script not run at all... I'm assuming that the ebuild (1.0) version of Nagios doesn't exhibit these problems that I'm seeing(?)

I can post the init script too if need be, just didn't want to make this too big if it wasn't needed.

Thanx!

k
Back to top
View user's profile Send private message
grimm26
Guru
Guru


Joined: 23 May 2004
Posts: 313
Location: Chicagoland, IL

PostPosted: Tue Oct 18, 2005 10:02 pm    Post subject: Reply with quote

Check out the Gentoo doc on init scripts for info on writing a proper init script. Check out the 1.x init script at /usr/portage/net-analyzer/nagios-core/files/nagios. You may be able to pretty much copy that one. I haven't tried 2.0, so I don't know.
_________________
"Blessed is he who finds happiness in his own foolishness, for he will always be happy".
Back to top
View user's profile Send private message
JofCore
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2004
Posts: 116

PostPosted: Wed Oct 19, 2005 4:49 pm    Post subject: Reply with quote

grimm26 wrote:
Check out the Gentoo doc on init scripts for info on writing a proper init script. Check out the 1.x init script at /usr/portage/net-analyzer/nagios-core/files/nagios. You may be able to pretty much copy that one. I haven't tried 2.0, so I don't know.


Thanks for the good info. I knew there was an init script for v1, but I didn't know where it was kept.

I have modified the init script for nagios, using the v1 init script as a guide. I believe that I now have a working nagios v2 gentoo init script.

Here it is if anyone else is interested:
(you'll probably want to modify the "prefix" var to match wherever u have nagios installed... I have it installed in a vhost dir which isn't exactly the "standard" :) )

Code:
#!/sbin/runscript
#
# chkconfig: 345 99 01
# description: Nagios network monitor
#
# File : nagios
#
# Author : Jorge Sanchez Aymar (jsanchez@lanchile.cl)
#   modified for Gentoo 20051019 kmh
#
# Changelog :
#
# 1999-07-09 Karl DeBisschop <kdebisschop@infoplease.com>
#  - setup for autoconf
#  - add reload function
# 1999-08-06 Ethan Galstad <nagios@nagios.org>
#  - Added configuration info for use with RedHat's chkconfig tool
#    per Fran Boon's suggestion
# 1999-08-13 Jim Popovitch <jimpop@rocketship.com>
#  - added variable for nagios/var directory
#  - cd into nagios/var directory before creating tmp files on startup
# 1999-08-16 Ethan Galstad <nagios@nagios.org>
#  - Added test for rc.d directory as suggested by Karl DeBisschop
# 2000-07-23 Karl DeBisschop <kdebisschop@users.sourceforge.net>
#  - Clean out redhat macros and other dependencies
# 2003-01-11 Ethan Galstad <nagios@nagios.org>
#  - Updated su syntax (Gary Miller)
# 2005-10-19 Kevin Hanser <gentoo@hanser.org>
#  - Modified script for use on Gentoo, based on original nagios v2
#   init script, and nagios v1 Gentoo init script
#
# Description: Starts and stops the Nagios monitor
#              used to provide network services status.
#

opts="${opts} reload checkconfig"

depend() {
   need net
}
 
prefix=/var/www/vhosts/nagios
exec_prefix=${prefix}
NagiosBin=${exec_prefix}/bin/nagios
NagiosCfgFile=${prefix}/etc/nagios.cfg
NagiosStatusFile=${prefix}/var/status.dat
NagiosTempFile=${prefix}/var/nagios.tmp
NagiosRetentionFile=${prefix}/var/retention.dat
NagiosCommandFile=${prefix}/var/rw/nagios.cmd
NagiosVarDir=${prefix}/var
NagiosRunFile=${prefix}/var/nagios.lock
NagiosLockDir=/var/lock/subsys
NagiosLockFile=nagios
NagiosCGIDir=${exec_prefix}/sbin
NagiosUser=nagios
NagiosGroup=nagios
         
reload()
{
   checkconfig || return 1
   ebegin "Reloading configuration"
   killall -HUP nagios &>/dev/null
   eend $?
}

checkconfig() {
   # copied from Gentoo's init script for nagios v1 and modified
   # Silent Check
   $NagiosBin -v $NagiosCfgFile &>/dev/null && return 0

   # Now we know there's problem - run again and display errors
   $NagiosBin -v $NagiosCfgFile
   eend $? "Configuration Error. Please fix your configfile"
}


start() {
   checkconfig || return 1
   ebegin "Starting network monitor: nagios"
   su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
   #chown $NagiosUser:$NagiosGroup $NagiosRunFile
   rm -f $NagiosCommandFile
   start-stop-daemon --quiet --start \
      --startas $NagiosBin \
      --pidfile $NagiosRunFile \
      -- -d $NagiosCfgFile
   eend $?
}

stop() {
   ebegin "Stopping network monitor: nagios"
   start-stop-daemon --quiet --stop \
      --pidfile $NagiosRunFile
   rm -f $NagiosStatusFile $NagiosTempFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile
   eend $?
}


svc_restart() {
   checkconfig || return 1
   ebegin "Restarting nagios"
   svc_stop
   svc_start
   eend $?
}

# End of this script
Back to top
View user's profile Send private message
wan-geek
n00b
n00b


Joined: 03 Apr 2003
Posts: 66
Location: knee-deep in the ether

PostPosted: Tue Nov 15, 2005 8:37 am    Post subject: nagios DB create fails Reply with quote

I've noticed this behavior on recent builds. Seems that something has changed w. mysql that it no longer accepts the "default value" that is set in the db create script.

Code:

CREATE TABLE hostcomments (
   hostcomment_id int(11) DEFAULT '0' NOT NULL auto_increment, <--- problem line ---
   host_name varchar(75) NOT NULL,
   entry_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
   persistent tinyint(4) DEFAULT '0' NOT NULL,
   author_name varchar(75) NOT NULL,
   comment_data blob NOT NULL,
   PRIMARY KEY (hostcomment_id)
);


When I edit the create_mysql script to the following, everything works ok again.
Code:

hostcomment_id int(11) NOT NULL auto_increment,

(obviously for all other code stanzas as well)

Anyone else seeing this or know the cause? This system is less than 2 weeks old.

Cheers,
-Chris
Back to top
View user's profile Send private message
jasewong
n00b
n00b


Joined: 16 Sep 2003
Posts: 11
Location: Hong Kong

PostPosted: Wed Dec 28, 2005 8:21 am    Post subject: problem resolved Reply with quote

hi all,

i have a similar problem.... nagios is running fine... except on the web page, it says nagios is not running. then i noticed that, when i start apache2, it complains about fqdn. then i modify my hosts file to include my fqdn. finally, all working properly. thanks.
Back to top
View user's profile Send private message
demonpengu
n00b
n00b


Joined: 12 Jan 2005
Posts: 6

PostPosted: Fri Jan 13, 2006 1:07 pm    Post subject: Reply with quote

Hi all,

I have been running nagios-1.2-r4 fine for months now, however did an update the other day which upgraded to 1.3, and suddenly all the hostextinfo stopped working. It is all setup in the database. Any ideas?

Thanks

Andy
Back to top
View user's profile Send private message
f0llia
l33t
l33t


Joined: 22 Apr 2003
Posts: 873

PostPosted: Thu Jan 19, 2006 5:11 pm    Post subject: Reply with quote

hi,
i've installed and configured nagios as in the how to but when i go to the web interface (http://localhost/nagios) and i select devide details or something else in the menu in the left it requires autentication, i put my user: nagiosadmin and passwd but it don't autenticate me.. it requires another time user and pass...
what's wrong ?? :cry:
Back to top
View user's profile Send private message
xenoscr
Tux's lil' helper
Tux's lil' helper


Joined: 08 Dec 2003
Posts: 123
Location: Indianapolis, IN

PostPosted: Fri Feb 24, 2006 2:49 pm    Post subject: hostextinfo Reply with quote

Hey,

I just got everything up and running with the exception of the hostextinfo. I added entries for my servers in the hostextinfo table and when I run a query to display it, it looks fine. I have added gif, png, and gd2 images. The logo files are located in /usr/nagios/share/images/logos and are owned by apache:apache and have permissions set to 644.

I do not see any errors in the Apache or Nagios log files in /var/log. Is there another place in the database that I need to look for errors now that I am using MySQL as opposed to the flat file method that I was more familiar with?

I'm at work now and can not access my Nagios server to get any specific information from it now but, if there are any configs or information that I can provide to help you help me I would be happy to provide it as soon as I am back home.

XeNoS
Back to top
View user's profile Send private message
xenoscr
Tux's lil' helper
Tux's lil' helper


Joined: 08 Dec 2003
Posts: 123
Location: Indianapolis, IN

PostPosted: Wed Mar 01, 2006 11:09 pm    Post subject: Re: hostextinfo Reply with quote

xenoscr wrote:
Hey,

I just got everything up and running with the exception of the hostextinfo. I added entries for my servers in the hostextinfo table and when I run a query to display it, it looks fine. I have added gif, png, and gd2 images. The logo files are located in /usr/nagios/share/images/logos and are owned by apache:apache and have permissions set to 644.

I do not see any errors in the Apache or Nagios log files in /var/log. Is there another place in the database that I need to look for errors now that I am using MySQL as opposed to the flat file method that I was more familiar with?

I'm at work now and can not access my Nagios server to get any specific information from it now but, if there are any configs or information that I can provide to help you help me I would be happy to provide it as soon as I am back home.

XeNoS


I was able to work around this. After doing some digging, it seems that the 1.x versions have trouble reading the "hostextinfo" from the mysql database. I used the "xedtemplate_config_file" method of adding a hostextinfo.cfg file to my cgi.cfg file and all was right again.

XeNoS
Back to top
View user's profile Send private message
bluland
n00b
n00b


Joined: 20 Apr 2006
Posts: 3

PostPosted: Thu Apr 20, 2006 2:50 pm    Post subject: nagios: problem with service command Reply with quote

thats my problem my nagios running (almost) normally but the service command says: "It appears as though Nagios is not running, so commands are temporarily unavailable..."
Anybody has some ideas??
thanks for all advices...
best regard
ENzo
Back to top
View user's profile Send private message
BrassMan83
n00b
n00b


Joined: 27 Apr 2006
Posts: 1
Location: Cleveland, OH

PostPosted: Thu Apr 27, 2006 12:58 pm    Post subject: Reply with quote

/usr/nagios/contrib/database/create_mysql does not exist on the latest version of Nagios. There isn't even a contrib directory. I know all that does is create the tables for Nagios to use, so is there a script or file I could download that will do the equivalent? My knowledge of SQL syntax is minimal at best. Even if all you do is cat /usr/nagios/contrib/database/create_mysql and paste it here, any help is appreciated.
Back to top
View user's profile Send private message
bluland
n00b
n00b


Joined: 20 Apr 2006
Posts: 3

PostPosted: Fri Apr 28, 2006 6:59 am    Post subject: nagios: problem with service command Reply with quote

thks for ur help im going to serch some info about it.
:lol:
Enzo
Back to top
View user's profile Send private message
seblonacs
n00b
n00b


Joined: 03 May 2006
Posts: 1

PostPosted: Wed May 03, 2006 9:24 pm    Post subject: SQL-Scripts Reply with quote

Hey,

you find the Scripts for SQL at /usr/doc/nagios-core-*/contrib/database/

Bye
seblonacs
Back to top
View user's profile Send private message
DigiCompI
n00b
n00b


Joined: 04 Mar 2006
Posts: 2

PostPosted: Wed May 03, 2006 10:39 pm    Post subject: Found create_mysql here Reply with quote

Based on seblonacs's suggestion above, I found create_mysql in /usr/share/doc/nagios-core-1.3/contrib/database
Back to top
View user's profile Send private message
tedj
n00b
n00b


Joined: 10 Jul 2003
Posts: 49

PostPosted: Mon Aug 28, 2006 7:06 pm    Post subject: Reply with quote

In 2.5, its missing again. There is no sql setup information in /usr/share/doc/nagios-core-2.5/
Back to top
View user's profile Send private message
njcwotx
Guru
Guru


Joined: 25 Feb 2005
Posts: 564
Location: Texas

PostPosted: Tue Aug 29, 2006 12:58 am    Post subject: Reply with quote

This comes from the Nagios FAQ for versions 2.x, I had mysql support for Ntop 1.x and migrated to 2.x recently and did not use mysql and did not notice any terrible degradation or performance problems watching around 350 services on 120 hosts and using cacti and mrtg on the same box.


from the 2.x faq
Native DB Support Dropped - Native support for storing various types of data (status, retention, comment, downtime, etc.) in MySQL and PostgreSQL has been dropped. Stop whining. I expect someone will develop an alternative using the new event broker sometime in the near future. Besides, DB support was not well implemented and dropping native DB support will make things easier for newbies to understand (one less thing to figure out).
_________________
Drinking from the fountain of knowldege.
Sometimes sipping.
Sometimes gulping.
Always thirsting.
Back to top
View user's profile Send private message
anidabi
Tux's lil' helper
Tux's lil' helper


Joined: 05 Feb 2005
Posts: 102
Location: Finland

PostPosted: Mon Sep 18, 2006 8:18 am    Post subject: Reply with quote

I was going throught nagios howto in gentoo-wiki and discovered that this line doesn't work for me:
Code:
for file in `ls *-sample`; do new=`echo $file|cut -d"-" -f1`;mv $file $new;done

It gave me this output:
Code:
mv: cannot stat `\033[00m\033[00mbigger.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mcgi.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mcheckcommands.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mminimal.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mmisccommands.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mnagios.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mresource.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[m': No such file or directory

Any ideas, how to corrent this?

Anyway, I renamed the files manually, since the oneline script didn't work.
_________________
How do you do the things you do...
Back to top
View user's profile Send private message
anidabi
Tux's lil' helper
Tux's lil' helper


Joined: 05 Feb 2005
Posts: 102
Location: Finland

PostPosted: Mon Sep 18, 2006 5:39 pm    Post subject: Reply with quote

njcwotx wrote:

from the 2.x faq
Native DB Support Dropped - Native support for storing various types of data (status, retention, comment, downtime, etc.) in MySQL and PostgreSQL has been dropped. Stop whining. I expect someone will develop an alternative using the new event broker sometime in the near future. Besides, DB support was not well implemented and dropping native DB support will make things easier for newbies to understand (one less thing to figure out).

I'm just trying to make nagios work and wiki seems to be a littlebit outdated since I'm installing nagios-2.5, so does this mean I should skip the mysql part all a long?
_________________
How do you do the things you do...
Back to top
View user's profile Send private message
anidabi
Tux's lil' helper
Tux's lil' helper


Joined: 05 Feb 2005
Posts: 102
Location: Finland

PostPosted: Wed Sep 20, 2006 11:08 am    Post subject: Reply with quote

Anyone, help!
_________________
How do you do the things you do...
Back to top
View user's profile Send private message
njcwotx
Guru
Guru


Joined: 25 Feb 2005
Posts: 564
Location: Texas

PostPosted: Mon Sep 25, 2006 7:17 am    Post subject: Reply with quote

anidabi wrote:
I was going throught nagios howto in gentoo-wiki and discovered that this line doesn't work for me:
Code:
for file in `ls *-sample`; do new=`echo $file|cut -d"-" -f1`;mv $file $new;done

It gave me this output:
Code:
mv: cannot stat `\033[00m\033[00mbigger.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mcgi.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mcheckcommands.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mminimal.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mmisccommands.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mnagios.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[00mresource.cfg-sample\033[00m': No such file or directory
mv: cannot stat `\033[m': No such file or directory

Any ideas, how to corrent this?

Anyway, I renamed the files manually, since the oneline script didn't work.


the '\033... stuff is because you are using color in your ls command.. add --color=none and the stat errors should go away.

for file in `ls --color=none *-sample `; do new=`echo $file|cut -d"-" -f1`;mv $file $new;done

I have been out of town lately, but if you still need assistance repost your questions and ill see what I can do for ya. I have 2.5 version running now. The old instructions are outdated and are more for version 1.x with sql support. 2.5 without sql seems to run just fine for me performance wise. In fact, we run mrtg and cacti on the same box and the cpu and network traffic are not too heavily taxed.
_________________
Drinking from the fountain of knowldege.
Sometimes sipping.
Sometimes gulping.
Always thirsting.
Back to top
View user's profile Send private message
anidabi
Tux's lil' helper
Tux's lil' helper


Joined: 05 Feb 2005
Posts: 102
Location: Finland

PostPosted: Thu Sep 28, 2006 10:38 pm    Post subject: Reply with quote

How about this error what I get!?

Code:

[1159482124] Nagios 2.5 starting... (PID=2339)
[1159482124] LOG VERSION: 2.0
[1159482125] You do not have permission to write to /var/run/nagios.pid
[1159482125] Bailing out due to errors encountered while attempting to daemonize... (PID=2339)

_________________
How do you do the things you do...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum