# nagios administration[resolved]

## muhsinzubeir

Obviously these are noob questions   :Very Happy: 

I have read the how-to even though its under construction, but it did helped me alot until now finally I can monitor my machine with nagios.

Unfortunately, on my client I get lots of this line on my logs.

1.

 *Quote:*   

> Jul 16 20:00:59 fileserver nagios: Error: Could not open check result queue directory '/var/nagios/spool/checkresults' for reading.
> 
> Jul 16 20:01:09 fileserver nagios: Error: Could not open check result queue directory '/var/nagios/spool/checkresults' for reading.
> 
> Jul 16 20:01:19 fileserver nagios: Error: Could not open check result queue directory '/var/nagios/spool/checkresults' for reading.
> ...

 

I have tried to create the dir and give it 777 mode, but it still pops up.If someone could help with this error I would really help.This programs is cool, but very unfriendly to noobs  :Laughing: 

2.

Apart from that, I am still left clueless on snmp.Which lead to the fact that my router cant be monitored.

 *Quote:*   

> [07-16-2009 20:21:23] SERVICE NOTIFICATION: nagiosadmin;router;Port 1 Link Status;UNKNOWN;notify-service-by-email;SNMP problem - No data received from host
> 
> Service Notification[07-16-2009 20:12:13] SERVICE NOTIFICATION: nagiosadmin;router;Uptime;UNKNOWN;notify-service-by-email;SNMP problem - No data received from host

 

Checking with snmpwalk:

 *Quote:*   

> >snmpwalk -v 1 -c public router
> 
> #Timeout: No Response from router

 

Anyone with a sample snmp.conf to share?

Thanks for the help....thats a lot of question in one thread, but this nagios ate the whole day here ....

Cheers

----------

## bbgermany

Hi,

for the first issue, can you post "ls -la /var/nagios/spool/checkresults" please.

for the second issue, my basic snmpd.conf:

```

com2sec readonly  default         public

group MyROSystem v1        paranoid

group MyROSystem v2c       paranoid

group MyROSystem usm       paranoid

group MyROGroup v1         readonly

group MyROGroup v2c        readonly

group MyROGroup usm        readonly

group MyRWGroup v1         readwrite

group MyRWGroup v2c        readwrite

group MyRWGroup usm        readwrite

view all    included  .1                               80

view system included  .iso.org.dod.internet.mgmt.mib-2.system

access MyROSystem ""     any       noauth    exact  system none   none

access MyROGroup ""      any       noauth    exact  all    none   none

access MyRWGroup ""      any       noauth    exact  all    all    none

syslocation Unknown (configure /etc/snmp/snmpd.local.conf)

syscontact Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)

disk /

```

bb

----------

## muhsinzubeir

 *Quote:*   

>  # ls -la /var/nagios/spool/checkresults 
> 
> -rw-r--r-- 1 root root 2 Jul 16 20:19 /var/nagios/spool/checkresults

 

I will test if i can get lucky with yr snmp.conf....by the way the dir spool and checkresults were created by me after I read my logs and see the error

Thanks mate...really appreciate...

----------

## bbgermany

Hi,

since your checkresults is a file not a directory, you should remove it and create a directory instead. Change the owner to the nagiosuser and you should be fine.

```

$ rm -rf /var/nagios/spool/checkresults

$ mkdir -p /var/nagios/spool/checkresults

$ chown nagios /var/nagios/spool/checkresults -R

```

bb

----------

## muhsinzubeir

Thanks for the tip, that worked no more more errors on my log about that Q1....its a dir instead of a file   :Smile: 

By the way, the issue of snmp I am still working on it.But I am amazed that I can only collect info from localhost only as it can be seen here.

```
>snmpget -v1 -Cf -c public localhost system.sysDescr.0

#SNMPv2-MIB::sysDescr.0 = STRING: Linux gendesktop 2.6.30-gentoo-r2 #1 SMP Thu Jul 16 12:26:32 CEST 2009 i686

```

Any other device router or gentoo box, 

```
>snmpget -v1 -Cf -c public 192.168.1.34 system.sysDescr.0

#Timeout: No Response from 192.168.1.34.
```

I think I will also play to collect Bandwidth, sounds like a pretty cool stuffs to play with   :Razz: 

Edit:

***I think clients arent correctly configured, router is giving responses via snmp now   :Wink: 

----------

## bbgermany

Do you have firewall rules running on 192.168.1.34? If yes, you need to open port 161 for lan access. If you have no firewall running on this port, check whether your snmpd is running on all interfaces or just localhost.

bb

----------

## muhsinzubeir

Sorry we were writting simultaneously....

I have responses now from my router so the uptime  and link status all good now....problem was on the router actually, that its snmp is not configured to deliver data to the central box.

Thanks I really appreciate your help....

----------

## muhsinzubeir

I am totally lost to monitor my server with nrpe, I get *Quote:*   

>  CHECK_NRPE: Socket timeout after 30 seconds. 

 

It was 10s, i have changed to 30 still same problem.I have played with my firewall on the router no luck.

On the remote gentoo box, everything is working:

 *Quote:*   

> #netstat -at |grep nrpe
> 
> tcp        0      0 *:nrpe                  *:*                     LISTEN  

 

 *Quote:*   

> #ps axuw |grep nrpe
> 
> root     11420  0.0  0.0   1928   520 pts/0    S+   17:03   0:00 grep --colour=auto nrpe
> 
> nagios   30110  0.0  0.0   1908   660 ?        Ss   Jul19   0:04 /usr/bin/nrpe -c /etc/nagios/nrpe.cfg --daemon

 

Any idea what am i missing on this.It seems like snmp from the central box to this server works perfectly as it can be seen here:

 *Quote:*   

> #snmpwalk -v 1 -c public fileserver hrSystemUptime.0
> 
> HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (75798970) 8 days, 18:33:09.70

 

May be I will spend time on this method rather than nrpe   :Laughing: 

----------

## bbgermany

You can try to run the check_nrpe command by hand. Usually it fails either coz SSL is enabled and not used or the other way around.

bb

----------

## muhsinzubeir

Testing nrpe from my monitoring machine:

I can run it from the command line as

 *Quote:*   

>  #/usr/lib/nagios/plugins/check_nrpe -H fileserver -c check_load
> 
> OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0; 

 

But not as check_nrpe:

 *Quote:*   

>  #check_nrpe -H fileserver -c check_load
> 
> bash: check_nrpe: command not found

 

Could this be the problem?

By the way thanks for the tip of ssl, I have disabled it on all my boxes as I am not using it.

----------

## muhsinzubeir

hold on...it might be working this time....ive tried to add the command in command.cfg   :Laughing: 

----------

## muhsinzubeir

Thanks bbgermany...really appreciate, this nagios needs alot of concentration to get it to work.But I think I am almost happy now, probably with few changes to come on my config...ill be monitoring this box closely.

By the way, my problem was command definition I think.So I placed this on /etc/nagios/objects/commands.cfg

 *Quote:*   

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

 

And nrpe started to work as expected....here is my to get me started on monitoring my box:

 *Quote:*   

> ###############################################################################
> 
> ###############################################################################
> 
> #
> ...

 

P:S

PLEASE DONT USE ANY INFO AGAINST ME   :Very Happy: 

Edit:

Red color isnt working yet on this sample file   :Laughing: 

----------

## bbgermany

Hi,

check_nrpe works in a different way. You have to define what you want to check this way:

On the Nagios Server (/etc/nagios3/conf.d/check_commands.cfg):

```

define command {

        command_name nrpe_check_root

        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_root -n

        }

```

On the nrpe client (/etc/nagios/nrpe.cfg):

```

command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /

```

The Nagios server sends a nrpe command to the nrpe client, where a local plugin (yes, you need the nagios plugins installed on the client) and runs it. Then the nrpe process sends the infomation grabbed via the plugin to the Nagios server.

bb

----------

## muhsinzubeir

Thanks alot bbgermany...I realized that the check_disk has to be implimented also on the client.

Well I will see tomorrow if I can have a short summery on the whole journey to save somebody else's time on this software.

Its pretty powerful tool I guess....I just wanted to explore it for while...and its for the first time i got a place for it.

Cheers...

----------

## bbgermany

Hi,

you're always welcome. It took me ages to find out how nagios works as I setup it for the first time  :Very Happy:  Until now im not really able to use snmp correctly  :Wink: 

bb

----------

## muhsinzubeir

Seting up nagios, involves central PC that monitoring software nagios is installed and couple devices that we are monitoring.

In this scenario we 2 computers and 1 router.One computer called gendesktop is the central command center that nagios is installed to monitor itself, router and 1 remote server(fileserver).

Computer names:

Central command center-gendesktop

*Router-router

*Gentoo Linux Server-fileserver

*Central command-gendesktop

Preparations:

***PREPARE THE ROUTER

Make sure you have allowed snmp on "remote management" section of the router device.

Atleast on my device this was not on by default.

***PREPARE THE REMOTE BOX-FILESERVER:

On the fileserver,Check if necessary plugins like snmp, nrpe are installed on the this box.Feel free to remove some of them.

```
#emerge -pv nagios-plugins

net-analyzer/nagios-plugins-1.4.13-r4  USE="ipv6 ldap mysql nagios-dns nagios-game nagios-ntp nagios-ping nagios-ssh radius samba snmp suid ups -postgres -ssl" 0 kB

```

Create commands on for the services that we want to monitor from this box:

Configuration file for npre lives /etc/nagios/nrpe.cfg, I ignored all other stuffs and change only the commands.

 *Quote:*   

> #Examples
> 
> command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
> 
> command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
> ...

 

Start the deamon for this nrpe, and put it in the default run-level

```
/etc/init.d/nrpe start && rc-update add nrpe default
```

I also added this on /etc/services {no idea if its needed  :Smile: }

 *Quote:*   

> nrpe            5666/tcp

 

Verify nrpe on this client is all set:

```
#ps axuw | grep nrpe

#netstat -at | grep nrpe
```

############################################COMMAND CENTER-GENDESKTOP##########################################

Objective, we want to monitor link status, ping and Uptime.There are more stuffs here can be monitored like bandwidth using mrtg, but we leave that to readers  :Smile: 

Configuration on the gendesktop:

We need nagios with all its plugin, so enable its USE flags and install it.

#emerge -av nagios

P:S

Check if necessary plugins like snmp, nrpe are installed on the plugins

```
#emerge -pv nagios-plugins

net-analyzer/nagios-plugins-1.4.13-r4  USE="ipv6 ldap mysql nagios-dns nagios-game nagios-ntp nagios-ping nagios-ssh radius samba snmp suid ups -postgres -ssl" 0 kB

```

WEB INTERFACE:

The web interface is cgi style, and it lives in on /usr/lib/nagios/cgi-bin.

Not so sure if .htaccess was there I created, but verify it, if not there create one.

#nano -w /usr/lib/nagios/cgi-bin/.htaccess

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /etc/nagios/auth.users

Require valid-user

Restrict access to your nagios /etc/apache2/modules.d/99_nagios3.conf:

 *Quote:*   

> #nano -w /etc/apache2/modules.d/99_nagios3.conf
> 
> <IfDefine NAGIOS>
> 
>         ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/
> ...

 

Create user to access your web-interface:

 *Quote:*   

> # htpasswd2 -c /etc/nagios/auth.users nagiosadmin

 

Test if web-interface is working, shoot this on your browser http://localhost/nagios

Now lets test communication to the router, if communication is working we continue to create object file for this router.

Test SNMP WITH THE ROUTER:

 *Quote:*   

> #snmpwalk -v 1 -c public router

 

You should get lots of output data here, if it doesnt work.If it doesnt work consult troubleshooting area below on the pdf file called NRPE.pdf in the resource links below.

If you do have communication there, lets create the object file for this router:

Create the dir:

```
#mkdir /etc/nagios/objects/routers
```

and create this file in there router.cfg.

 *Quote:*   

> ###############################################################################
> 
> ###############################################################################
> 
> #
> ...

 

Verify that no problem no errors in your config files:

```
#nagios -v /etc/nagios/nagios.cfg
```

If no problem restart nagios deamon.

```
#/etc/init.d/nagios restart
```

REMOTE BOX FILESERVER OBJECT FILE:

creat the directy /etc/nagios/objects/servers/ and put this file in it fileserver.cfg

 *Quote:*   

> ###############################################################################
> 
> ###############################################################################
> 
> #
> ...

 

Verify that no problem no errors in your config files:

```
#nagios -v /etc/nagios/nagios.cfg
```

If no problem restart nagios deamon.

```
#/etc/init.d/nagios restart
```

TROUBLESHOOTING

RESOURCES:

http://www.gentoo.org/doc/en/nagios-guide.xml

http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf

http://www.nagios.org/

----------

## bbgermany

Hi,

one little correction: nrpe does not need snmp. its using its own protocol to get the data!

bb

----------

## muhsinzubeir

Thats true, in my setup I mixed both 2 , router needed snmp and fileserver uses nrpe.

I think snmp is much better way, but I still need more time to learn how to snmp with my gentoo box...  :Laughing: 

----------

## muhsinzubeir

I have tried to use snmp to my gentoo server (fileserver) to get uptime and I just added this service, and it works like a charm   :Smile: 

 *Quote:*   

> #uptime
> 
> define service{
> 
> 	use			generic-service	; Inherit values from a template
> ...

 

So probably, snmp is the best approaches in that scenario because its available on both clients (router+gentoo server).....

Cheers...

----------

