Page 1 of 1
how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 4:29 am
by baber
dear all
Hi
i have appear a bad problem now i see all of my data in commands.cfg file has been deleted
cat /usr/local/nagios/etc/objects/commands.cfg
that is empty
is there any place in nagios that had or get a backup from that ?
how can i restore that ?
Now i did not restart nagios service because now if restart that it will not work
i don't have any backup from server
BR
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 10:38 am
by dwhitfield
What's the output of ls -la /usr/local/nagios/etc/objects/? Also, let's try find / -name commands.cfg. I'm suspecting it got moved or renamed.
While we're at it, can you PM me or post the output of history from both root and nagios users. Scrub if you must.
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 10:53 am
by baber
dwhitfield wrote:What's the output of ls -la /usr/local/nagios/etc/objects/? Also, let's try find / -name commands.cfg. I'm suspecting it got moved or renamed.
While we're at it, can you PM me or post the output of history from both root and nagios users. Scrub if you must.
Code: Select all
total 108
drwxrwxr-x. 2 nagios nagios 4096 Dec 2 11:40 .
drwxrwxr-x. 8 nagios nagios 4096 Nov 27 00:16 ..
-rw-rw-r--. 1 nagios nagios 0 Dec 2 12:44 commands.cfg
-rw-rw-r--. 1 nagios nagios 7688 May 26 2016 commands.cfg~
-rw-rw-r--. 1 nagios nagios 2147 Jul 30 06:44 contacts.cfg
-rw-rw-r--. 1 nagios nagios 2138 May 26 2016 contacts.cfg~
-rw-r--r--. 1 root root 979 Aug 10 05:31 hostgroup.cfg
-rw-rw-r--. 1 nagios nagios 5375 May 26 2016 localhost.cfg
-rw-rw-r--. 1 nagios nagios 5375 May 26 2016 localhost.cfg~
-rw-rw-r--. 1 nagios nagios 3096 May 26 2016 printer.cfg
-rw-rw-r--. 1 nagios nagios 3096 May 26 2016 printer.cfg~
-rw-rw-r--. 1 nagios nagios 3265 May 26 2016 switch.cfg
-rw-rw-r--. 1 nagios nagios 3265 May 26 2016 switch.cfg~
-rw-rw-r--. 1 nagios nagios 17284 Aug 10 03:03 templates.cfg
-rw-rw-r--. 1 nagios nagios 10621 May 26 2016 templates.cfg~
-rw-rw-r--. 1 nagios nagios 3180 May 26 2016 timeperiods.cfg
-rw-rw-r--. 1 nagios nagios 3180 May 26 2016 timeperiods.cfg~
-rw-rw-r--. 1 nagios nagios 3991 May 26 2016 windows.cfg
-rw-rw-r--. 1 nagios nagios 3991 May 26 2016 windows.cfg~
Code: Select all
find / -name commands.cfg
/usr/local/nagios/etc/objects/commands.cfg
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 11:07 am
by dwhitfield
Is commands.cfg~ just the original template?
Also, it might be on the way, but I didn't get a PM of the two history commands. You can post them here of course, but if you PM, just update the post.
Last question for this round: is this the same server that had the check_by_ssh issue? I can't remember if you had multiple nagios servers. I seem to remember you are managing something like 150 hosts.
UPDATE: history command received and shared with techs
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 2:25 pm
by baber
dwhitfield wrote:Is commands.cfg~ just the original template?
Also, it might be on the way, but I didn't get a PM of the two history commands. You can post them here of course, but if you PM, just update the post.
Last question for this round: is this the same server that had the check_by_ssh issue? I can't remember if you had multiple nagios servers. I seem to remember you are managing something like 150 hosts.
no i just have one nagios server and more than 120 hosts that monitored by nagios server commandcfg file data has been removed from nagios server
untill now i did not restart nagios server because if rstart that nagios will not work now is there any temo command.cfg file before nagios restart that i restore it ?
because that is difficult i can not do changes untill commands.cfg file restored
BR
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 2:36 pm
by dwhitfield
When you looked at commands.cfg as root in vi (
vi /usr/local/nagios/etc/objects/commands.cfg), was that before or after the issue?
I notice the next two commands are
Code: Select all
999 service nagios restart
1000 cat /usr/local/nagios/etc/objects/commands.cfg
so my assumption is you restarted the service to get your new commands.cfg, then something went wrong so went to look at what was going on in commands.cfg and noticed nothing was there.
Is that correct?
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 2:56 pm
by baber
dwhitfield wrote:When you looked at commands.cfg as root in vi (
vi /usr/local/nagios/etc/objects/commands.cfg), was that before or after the issue?
I notice the next two commands are
Code: Select all
999 service nagios restart
1000 cat /usr/local/nagios/etc/objects/commands.cfg
so my assumption is you restarted the service to get your new commands.cfg, then something went wrong so went to look at what was going on in commands.cfg and noticed nothing was there.
Is that correct?
Yes i am sure did not delete content of commands.cfg file but now i am confused there is not any temp file from command.cfg because now that is working but sure if restart service it will be out of work
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 3:07 pm
by dwhitfield
What's the output of df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
We are done for the day, but you probably want to look into zero-length file issues over the weekend. Did the server lose power? If this is on network storage, did you lose network connectivity?
One last question: are you the only admin on the server?
Re: how can restore commands.cfg file in nagios server
Posted: Fri Dec 02, 2016 3:20 pm
by baber
dwhitfield wrote:What's the output of df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
We are done for the day, but you probably want to look into zero-length file issues over the weekend. Did the server lose power? If this is on network storage, did you lose network connectivity?
One last question: are you the only admin on the server?
Yes just i am admin server
Yes i suddenly lost the network connectivity and after that command.cfg file was zero because i was not in my office and remoted to my office for work on nagios
Re: how can restore commands.cfg file in nagios server
Posted: Mon Dec 05, 2016 12:34 pm
by dwhitfield
Unfortunately, we don't have a tool for parsing this, but all the commands.cfg information should be in your /usr/local/nagios/var/objects.cache. If you need additional help restoring the information, please PM me your objects.cache file.