Leading blank in services cfg file names
Leading blank in services cfg file names
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
...
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
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
CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Leading blank in services cfg file names
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.
<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
After doing what lmiltchev suggested,
do the files with blanks still exist?lmiltchev wrote:CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files
Re: Leading blank in services cfg file names
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
lets run the following to find them
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
Code: Select all
echo "select id,service_description from tbl_service where service_description like ' %' group by config_name,service_description;"|mysql -pnagiosxi nagiosqlIf 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
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]#
[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
Hmm, if you go to CCM -> Services
and click the "Config Name" dropdown, can you see the one with the space there?
and click the "Config Name" dropdown, can you see the one with the space there?
Re: Leading blank in services cfg file names
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.
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
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
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