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?