Thanks for you reply. I think the problem is not completely clear, I'll try to clarify.
An example: I have one configuration file, localhost.cfg, with this content:
Code: Select all
define host{
use linux-server
host_name localhost
alias localhost
address 127.0.0.1
}
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members localhost
}
define service{
use local-service
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service
host_name localhost
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
define service{
use local-service
host_name localhost
service_description Current Users
check_command check_local_users!20!50
}
define service{
use local-service
host_name localhost
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
define service{
use local-service
host_name localhost
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use local-service
host_name localhost
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use local-service
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 0
}
define service{
use local-service
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 0
}
Notice it has one "PING" service, among the others. If I keep importing this file more and more times, no service gets duplicated
inside the db.
I have one other configuration file: linksys-srw224p.cfg:
Code: Select all
define service{
use generic-service
service_description PING
check_command check_ping!200.0,20%!600.0,60%
normal_check_interval 5
retry_check_interval 1
}
define service{
use generic-service
host_name linksys-srw224p
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0
}
define service{
use generic-service
host_name linksys-srw224p
service_description Port 1 Link Status
check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
define service{
use generic-service
host_name linksys-srw224p
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,1000000!5000000,5000000!10
}
It has one "PING" service, like localhost, but the check command is different.
I understand that the two different
checks must be inserted in DB, so I must find one line for each service: one for localhost, the other for linksys-srw224p.
BUT, if I keep importing the linksys-srw224p.cfg, each time I get ANOTHER line for the PING service
(and JUST for that: the other three services are not duplicated).
To be clear, this happened after I imported the file 3 times, but just for the PING service:
Code: Select all
MariaDB [nagiosql]> select id, config_name, host_name, hostgroup_name, service_description, check_command, last_modified from tbl_service where service_description = 'PING';
+----+-----------------+-----------+----------------+---------------------+---------------------------+---------------------+
| id | config_name | host_name | hostgroup_name | service_description | check_command | last_modified |
+----+-----------------+-----------+----------------+---------------------+---------------------------+---------------------+
| 1 | localhost | 1 | 0 | PING | 17!100.0,20%!500.0,60% | 2017-08-24 13:39:59 |
| 68 | linksys-srw224p | 0 | 0 | PING | 17!200.0,20%!600.0,60% | 2017-08-24 13:39:21 |
| 87 | linksys-srw224p | 0 | 0 | PING | 17!200.0,20%!600.0,60% | 2017-08-24 13:39:59 |
| 89 | linksys-srw224p | 0 | 0 | PING | 17!200.0,20%!600.0,60% | 2017-08-24 13:48:26 |
+----+-----------------+-----------+----------------+---------------------+---------------------------+---------------------+
As you can see, localhost appears just once (even if keep importing localhost.cfg more and more and more...)
while linksys-srw224p is there 3 times.
The result is that, when generating configuration files, the service is inserted 3 times in the configuration file:
Code: Select all
###############################################################################
#
# Service configuration file
#
# Created by: Nagios Core Config Manager 2.6.8
# Date: 2017-08-24 14:11:02
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define service {
service_description PING
use generic-service
check_command check_ping!200.0,20%!600.0,60%
check_interval 5
retry_interval 1
register 1
}
define service {
service_description PING
use generic-service
check_command check_ping!200.0,20%!600.0,60%
check_interval 5
retry_interval 1
register 1
}
define service {
service_description PING
use generic-service
check_command check_ping!200.0,20%!600.0,60%
check_interval 5
retry_interval 1
register 1
}
define service {
host_name linksys-srw224p
service_description Port 1 Bandwidth Usage
use generic-service
check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,1000000!5000000,5000000!10
register 1
}
define service {
host_name linksys-srw224p
service_description Port 1 Link Status
use generic-service
check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
register 1
}
define service {
host_name linksys-srw224p
service_description Uptime
use generic-service
check_command check_snmp!-C public -o sysUpTime.0
register 1
}
###############################################################################
#
# Service configuration file
#
# END OF FILE
#
###############################################################################
I'm puzzled, because I don't see what could possibly mess with the configuration.