how can restore commands.cfg file in nagios server

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

how can restore commands.cfg file in nagios server

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: how can restore commands.cfg file in nagios server

Post 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.
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: how can restore commands.cfg file in nagios server

Post 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

dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: how can restore commands.cfg file in nagios server

Post 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
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: how can restore commands.cfg file in nagios server

Post by baber »

dwhitfield wrote:Is commands.cfg~ just the original template?

Code: Select all

yes
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.

Code: Select all

i have send history commands 
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
Last edited by dwhitfield on Fri Dec 02, 2016 2:31 pm, edited 1 time in total.
Reason: removed code tags that were not around code, and not in the quote
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: how can restore commands.cfg file in nagios server

Post 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?
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: how can restore commands.cfg file in nagios server

Post 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?

Code: Select all

I can not remember this
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
Last edited by dwhitfield on Fri Dec 02, 2016 3:00 pm, edited 1 time in total.
Reason: removed code tags in non-code
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: how can restore commands.cfg file in nagios server

Post 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?
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: how can restore commands.cfg file in nagios server

Post 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
Last edited by dwhitfield on Fri Dec 02, 2016 4:42 pm, edited 1 time in total.
Reason: removed quote from the part that was not a quote
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: how can restore commands.cfg file in nagios server

Post 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.
Locked