2

We have a strange issue with our setup of icinga / nagios and mrtg.

Icinga is working great and has no problem, it can monitor basically everything without issues.

We setup mrtg to gather bandwith data from our routers and switches. MRTG is working fine: it stores the log data in the /var/www/mrtg/ directory and displays the graph data via web. We assume so MRTG is doing great.

We tried to setup bandwidth checks in nagios:

define service{
        use                     generic-service ; Inherit values from a template
        host_name               zywall-agora
        service_description     ZYWALL AGORA TRAFFICO
        check_command           check_local_mrtgtraf!/var/www/mrtg/x.x.x.x_2.log!AVG!1000000,2000000!5000000,5000000!1000
        check_interval          1       ; Check the service every 1 minute under normal conditions
        retry_interval          1       ; Re-check every minute until its final/hard state is determined

}

Where /var/www/mrtg/x.x.x.x_2.log is the correct log path file.

We keep on getting Unable to open MRTG log file error in the test result in icinga web interface.

We tried everything:

  • give ownership to user nagios or icinga to the log file
  • give chmod 777 to the file
  • try to copy the file in another directory and give it full permission

Same error. The strange thing is that if we use the command that nagios generate in a bash session the command works like a charm:

/usr/lib64/nagios/plugins/check_mrtgtraf  -F /var/www/mrtg/x.x.x.x_2.log -a AVG -w 10,20 -c 5000000,5000000 -e 10

Result:

Traffic WARNING - Avg. In = 17.9 KB/s, Avg. Out = 5.0 KB/s|in=17.877930KB/s;10.000000;5000000.000000;0.000000 out=5.000000KB/s;20.000000;5000000.000000;0.000000

We ran that command line as root, as user nagios and as user icinga and all three worked ok. We thought that the command that nagios perform maybe has something wrong in it, so we debugged nagios but we found out that the generated command from nagios is the same as above.

Searching on google for these kind of problem returns only issues of systems where mrtg is not installed or issues with the wrong path to the log file, but these seems not to be our case.

We are stuck, can somebody help?

Kev
  • 7,777
  • 17
  • 78
  • 108
  • 2
    Please don't edit the question or the title, just add your answer like any other user would and then accept it as the answer. – pauska Dec 16 '11 at 13:37
  • I agree - post your solution as an answer and people will vote it up, you get points, and the questions can be marked as answered properly. – dunxd Dec 16 '11 at 14:44

2 Answers2

1

I solved problem configuring command like this:

define command{

        command_name check_local_mrtgtraf
        command_line $USER1$/check_mrtgtraf $ARG1$ 10 AVG $ARG2$ $ARG3$ $ARG4$ 

}

and defining service like this:

define service {
        use ...
        host_name ....
        ...
        check_command        check_local_mrtgtraf!path_to_logfile!30,40!100,200!10
}
voretaq7
  • 79,345
  • 17
  • 128
  • 213
jackarian
  • 11
  • 2
0

Show us your command definition for the "check_local_mrtgtraf" command. It's possible that it doesn't match what you're passing it as ARGs.

Also, you might want to try running it through 'env -i', to simulate how nagios/icinga runs it (without ENV).

Keith
  • 4,627
  • 14
  • 25