Page 1 of 2
Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 12:51 pm
by dmc0815
If we go into our /usr/local/nagios/etc/services directory and do an ls we found several duplicate file names except one of the files would have a leading blank space. Does anyone know how these got created and how do I get rid of them?
Example:
[12:44:18]root:/usr/local/nagios/etc/services]# ls
server1.cfg
server2.cfg
server2.cfg
server3.cfg
server4.cfg
server5.cfg
server5.cfg
...
Re: Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 4:10 pm
by lmiltchev
How did you add these services - via a wizard, manually in the CCM, via the REST API, etc.? Are duplicates actually identical? Did you try opening 2 of them (for example both server2.cfg files) in a text editor, and comparing the contents? Are these services added to a single host or a hostgroup? Do you get any errors when you run the "Config File Management" tool?
CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files
Re: Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 4:32 pm
by dmc0815
I came upon this. Just started a month or so ago and just doing some cleanup from current "admins". The cfg files are not identical. Services are added to a single host. Running the verification:
<Output Omitted>
Total Warnings: 1396
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
There are 416 cfg files in /usr/local/nagios/etc/services. Only 7 begin with the blank.
Re: Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 4:35 pm
by scottwilkerson
After doing what lmiltchev suggested,
lmiltchev wrote:CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files
do the files with blanks still exist?
Re: Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 4:48 pm
by dmc0815
Yes, they do. Looking at the output in CCM you don't see the duplicate file names (one with blank). You only see that through the CLI.
Re: Leading blank in services cfg file names
Posted: Tue Feb 19, 2019 5:22 pm
by scottwilkerson
lets run the following to find them
Code: Select all
echo "select id,service_description from tbl_service where service_description like ' %' group by config_name,service_description;"|mysql -pnagiosxi nagiosql
This will give you the name of the service, and the ID of those affected.
If you search in the CCM under services for the name of the service, and find the ID (on the right) you can edit these and remove the extra spaces in the config name filed.
Then after you do this you may need to again do this procedure
CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files
Re: Leading blank in services cfg file names
Posted: Wed Feb 20, 2019 11:13 am
by dmc0815
It did not return anything.
[11:12:05]root:/usr/local/nagios/etc]# echo "select id,service_description from tbl_service where service_description like ' %' group by config_name,service_description;"|mysql -pnagiosxi nagiosql
[11:12:06]root:/usr/local/nagios/etc]#
Re: Leading blank in services cfg file names
Posted: Wed Feb 20, 2019 11:19 am
by scottwilkerson
Hmm, if you go to CCM -> Services
and click the "Config Name" dropdown, can you see the one with the space there?
Re: Leading blank in services cfg file names
Posted: Wed Feb 20, 2019 11:35 am
by dmc0815
I noticed that it is writing the services configuration file twice, but one is coming up with a blank as the first character. You don't see the blank in the GUI, only in the CLI.
I tried deleting the one with the blank since it is out of date with the information in there. It writes it back and with the blank.
Re: Leading blank in services cfg file names
Posted: Wed Feb 20, 2019 11:49 am
by scottwilkerson
if you go to CCM -> Services
and click the "Config Name" dropdown do you see 2 items with the same name as the config name in question?
One might be at the top or bottom because of sorting with the space