Comments were removed after nagios reload

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.
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Comments were removed after nagios reload

Post by belogrud »

Hello everyone.

Could someone help us with follow question.
We have installed
Nagios® Core™ 4.1.2-Pre1
And as we not so far ago noted, all not persistant comments are remove from nagios after it reload ( /etc/init.d/nagios reload ).
Can somebody help us and give us advise how to save our not persistant comments after nagios reload.

This behavior of nagios is not clear for me. I'd rather prefere save comments after nagios reloaded and delete it when nagios restarted.
[root@~ ]# service nagios help
Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig|configtest}

We need reload nagios, because we transfer our changes (new hosts for check, new services, changes in existed services and so on) in nagios from our nagios pre-production environment to our nagios production environment. We use GIT to rule our changes.
We don't want use persistent comments, because it bring a risk to forget about this comment after service turn back its state from critical to normal. In addition, we use special script, that test services via LiveStatus - has critical service, its duration of critical state more than 8 hours and if this service found, our script check on existance comment, acknowledge, downtime for this service. If there are no comments, acknowledge, downtime - this script create alarm email. So, because of it, if we start use persistant comments, we will get misfunction of this script, when not removed old comment prevent us to be noticed about service without apropriate attention.
We use persistant comments, but very rare and for special cases.

I'd like to ask people - had someone come across to described difficulties and how you have fixed it.

With hope on help,
Sergey
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Comments were removed after nagios reload

Post by hsmith »

What OS is this installed on? I do have to point out that supported for 4.1.2 is currently limited, as it is not an officially released version yet. You may want to create an issue on GitHub if you continue to experience this. We can try to replicate, though.
Former Nagios Employee.
me.
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Re: Comments were removed after nagios reload

Post by belogrud »

hsmith wrote:What OS is this installed on? I do have to point out that supported for 4.1.2 is currently limited, as it is not an officially released version yet. You may want to create an issue on GitHub if you continue to experience this. We can try to replicate, though.
Hi, and thanks for comment.

We are using Red Hat:
[root@~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)
[root@~]
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Comments were removed after nagios reload

Post by tmcdonald »

I'm a little confused here:
belogrud wrote:all not persistant comments are remove from nagios after it reload ( /etc/init.d/nagios reload ).
Can somebody help us and give us advise how to save our not persistant comments after nagios reload.
That is exactly what persistent comments are meant to do, be persistent across restarts. From the Comment page in the interface:
If you do not check the 'persistent' option, the comment will automatically be deleted the next time Nagios is restarted.
By marking a comment as non-persistent you are telling it not to survive reboots.
Former Nagios employee
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Re: Comments were removed after nagios reload

Post by belogrud »

tmcdonald wrote:I'm a little confused here:
belogrud wrote:all not persistant comments are remove from nagios after it reload ( /etc/init.d/nagios reload ).
Can somebody help us and give us advise how to save our not persistant comments after nagios reload.
That is exactly what persistent comments are meant to do, be persistent across restarts. From the Comment page in the interface:
If you do not check the 'persistent' option, the comment will automatically be deleted the next time Nagios is restarted.
By marking a comment as non-persistent you are telling it not to survive reboots.
Hello tmcdonald.

Let me explain, what way I thought.

I suppose, that it would be great if nagios behavior differ between "reload" and "restart".
When nagios reloaded - it doesn't remove not persistant comments.
When nagios restarted - it remove not persistant comments (as it was exactly written above by you).

Current nagios behavior doesn't differ "restart" and "reload" - it always do "restart".
That's not convenient at least.
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Re: Comments were removed after nagios reload

Post by belogrud »

Yesterday I have written two scripts, that help to walk around described difficulty.

One of these scripts save not persistant comment for services, that have critical state.
Other one restore previously saved comments to nagios.
These scripts start periodically by cron daemon.

Code: Select all

[root@~ ]# cat nagios_save_not_persistant_comments.sh
#!/bin/bash

let index=0

while IFS=';' read -a array_for_read_data
do

 array_first_argument[${index}]="${array_for_read_data[0]}"
 array_second_argument[${index}]="${array_for_read_data[1]}"
 array_third_argument[${index}]="${array_for_read_data[2]}"
 array_fourth_argument[${index}]="${array_for_read_data[3]}"
 array_fifth_argument[${index}]="${array_for_read_data[4]}"

 ((index++))

done < <( echo -e "GET comments\nFilter: persistent = 0\nFilter: type = 2\nFilter: entry_type = 1\nFilter: service_state = 2\nColumns: host_name service_description author comment entry_time" | /usr/local/bin/unixcat /usr/local/nagios/var/rw/live )

if [ -e /var/tmp/nagios_not_persistant_comments.backup ] ; then rm -f /var/tmp/nagios_not_persistant_comments.backup ; fi

if [ ${index} -gt 0 ]
 then
    for (( count=0  ; count < ${index} ; count++ ))
     do
        echo "${array_first_argument[${count}]};${array_second_argument[${count}]};${array_third_argument[${count}]};${array_fourth_argument[${count}]};${array_fifth_argument[${count}]}" >> /var/tmp/nagios_not_persistant_comments.backup
     done
 fi

[root@~ ]#

Code: Select all

[root@~ ]# cat nagios_restore_not_persistant_comments.sh
#!/bin/bash

let index=0

if [ -e /var/tmp/nagios_not_persistant_comments.backup ]
 then
    while IFS=';' read -a array_for_read_data
     do

      array_first_argument[${index}]="${array_for_read_data[0]}"
      array_second_argument[${index}]="${array_for_read_data[1]}"
      array_third_argument[${index}]="${array_for_read_data[2]}"
      array_fourth_argument[${index}]="${array_for_read_data[3]}"
      array_fifth_argument[${index}]="${array_for_read_data[4]}"

      ((index++))

     done < <( cat /var/tmp/nagios_not_persistant_comments.backup )
fi

if [ ${index} -gt 0 ]
 then
    for (( count=0  ; count < ${index} ; count++ ))
     do
        echo -e "COMMAND [${array_fifth_argument[${count}]}] ADD_SVC_COMMENT;${array_first_argument[${count}]};${array_second_argument[${count}]};0;${array_third_argument[${count}]};${array_fourth_argument[${count}]}" | /usr/local/bin/unixcat /usr/local/nagios/var/rw/live
     done
 fi

[root@~ ]#
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Re: Comments were removed after nagios reload

Post by belogrud »

belogrud wrote:
tmcdonald wrote:I'm a little confused here:
belogrud wrote:all not persistant comments are remove from nagios after it reload ( /etc/init.d/nagios reload ).
Can somebody help us and give us advise how to save our not persistant comments after nagios reload.
That is exactly what persistent comments are meant to do, be persistent across restarts. From the Comment page in the interface:
If you do not check the 'persistent' option, the comment will automatically be deleted the next time Nagios is restarted.
By marking a comment as non-persistent you are telling it not to survive reboots.
Hello tmcdonald.

Let me explain, what way I thought.

I suppose, that it would be great if nagios behavior differ between "reload" and "restart".
When nagios reloaded - it doesn't remove not persistant comments.
When nagios restarted - it remove not persistant comments (as it was exactly written above by you).

Current nagios behavior doesn't differ "restart" and "reload" - it always do "restart".
That's not convenient at least.
By the way - I'd like to note, as I see in our nagios, current nagios behavior allow to save "acknowledge" and its comment after nagios "reboot" and "restart" even if this "acknowledge" have no persistent comment.
;)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Comments were removed after nagios reload

Post by tmcdonald »

This is something we're going to need to test internally before our developer can look into it. If you want to get this on his radar immediately, you can post to our GitHub:

https://github.com/NagiosEnterprises/nagioscore

Otherwise we'll need to test and confirm this on our end. Let me know how you would like to continue, but if you do post on GitHub feel free to update this thread with a link!
Former Nagios employee
belogrud
Posts: 15
Joined: Mon Dec 07, 2015 10:34 am

Re: Comments were removed after nagios reload

Post by belogrud »

tmcdonald wrote:This is something we're going to need to test internally before our developer can look into it. If you want to get this on his radar immediately, you can post to our GitHub:

https://github.com/NagiosEnterprises/nagioscore

Otherwise we'll need to test and confirm this on our end. Let me know how you would like to continue, but if you do post on GitHub feel free to update this thread with a link!
Hello tmcdonald.
Thank you for your answer and excuse me for long time silence. There were long weekend and I was unable to answer.
I'm newbie to usage GitHub to post something - I don't know how to do it right - I never did it. By the way, I'm not to much hurry to add my proposal to nagios, because I've created my two scripts, that fix this issue.

So, for above reasons, you can test this issue, as you want. I will waiting for your results and your advices, respectively.

Sergey.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Comments were removed after nagios reload

Post by lmiltchev »

So, for above reasons, you can test this issue, as you want. I will waiting for your results and your advices, respectively.
I set up an internal testing task (task_id=8822). As soon as we complete the testing task, we will update this post. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked