Leading blank in services cfg file names

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dmc0815
Posts: 7
Joined: Mon Dec 17, 2018 1:55 pm

Leading blank in services cfg file names

Post 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
...
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Leading blank in services cfg file names

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
dmc0815
Posts: 7
Joined: Mon Dec 17, 2018 1:55 pm

Re: Leading blank in services cfg file names

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Leading blank in services cfg file names

Post 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?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dmc0815
Posts: 7
Joined: Mon Dec 17, 2018 1:55 pm

Re: Leading blank in services cfg file names

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Leading blank in services cfg file names

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dmc0815
Posts: 7
Joined: Mon Dec 17, 2018 1:55 pm

Re: Leading blank in services cfg file names

Post 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]#
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Leading blank in services cfg file names

Post by scottwilkerson »

Hmm, if you go to CCM -> Services
and click the "Config Name" dropdown, can you see the one with the space there?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dmc0815
Posts: 7
Joined: Mon Dec 17, 2018 1:55 pm

Re: Leading blank in services cfg file names

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Leading blank in services cfg file names

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked