Bug #249

init script should not only depend on lockfile

Added by dnsmichi over 4 years ago. Updated almost 4 years ago.

Status:ResolvedStart date:01/10/2010
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:Other
Target version:-
Icinga Version: OS Version:

Description

there are several states and action which lead into wrong information or don't do what they should in special cases.

====================================================

state: icinga running

  1. icinga status
    => correct

====================================================

state: icinga not running, icinga.lock file there

#icinga status
=> show faulty icinga running => should check against ps

====================================================

state: icinga stopped, lock file already there

  1. icinga start
    => icinga already running => that is wrong!

====================================================

state: icinga running

  1. icinga restart
    => icinga stops not in timely manner, leaves icinga.lock there, starting again fails
    => wrong output, better would be icinga did not stop in a timely manner for restarting, please try icinga stop\nicinga start\n

====================================================

state: icinga running, lockfile removed

  1. icinga stop
    => Stopping icinga: No lock file found in /opt/icinga/var/icinga.lock
    => should check against ps -C icinga and issue a killall -9

daemon-init.diff Magnifier (2.6 KB) hbaecker, 01/20/2010 09:47 pm


Related issues

Related to Core - Bug #197: service icinga stop, doesn't work on ubuntu Resolved 11/23/2009

Associated revisions

Revision 4e99d936
Added by Meier almost 4 years ago

use redhaht init script on redhat rpm builds
fixes #387
fixes #249 on redhat

Revision e290d8d8
Added by Meier almost 4 years ago

use redhat init script on redhat rpm builds
fixes #387
refs #249 on redhat

History

#1 Updated by dnsmichi over 4 years ago

  • Assignee set to hbaecker
  • Target version set to 1.0.1

#2 Updated by Meier over 4 years ago

In ido2db init-script i used this

checkpid_ido2db() {
        local i

        for i in $* ; do
                [ -d "/proc/$i" ] && return 0
        done
        return 1
}

To check against /proc if the process with a given pid is still running.

#3 Updated by dnsmichi over 4 years ago

jep but in *bsd there is no /proc so ps -o pid -p $pid would be nice instead

#4 Updated by hbaecker over 4 years ago

Following Note was added by Hiren on icinga-devel list:

Could someone give it a try?


  1. Message:
    looking for comments on this diff, have not tested it yet, have not setup a test environment to test with yet.
    comments on how it works and if it would be accepted welcome, if so, I'll get around to testing it and submitting fixes if there are issues.
    thanks.
    ----

#5 Updated by dnsmichi about 4 years ago

$ patch -p0 < daemon-init.diff

it behaves rather strange:

$ sudo /etc/init.d/icinga status
icinga (pid 12689) is running...
$ sudo killall -9 icinga
$ sudo /etc/init.d/icinga status
icinga is not running
$ sudo /etc/init.d/icinga stop
Stopping icinga: /etc/init.d/icinga: line 91: kill: (12689) - No such process
done.
$ sudo /etc/init.d/icinga start
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
No lock file found in /opt/icinga/var/icinga.lock
no PID file found but icinga found in ps listing
please manually kill existing icinga process

lock file is not there, but for some reason icinga is detected running (only ido2db and postgres match on ps aux | grep icinga). any ideas?

#6 Updated by Meier about 4 years ago

dnsmichi wrote:

jep but in *bsd there is no /proc so ps -o pid -p $pid would be nice instead

As I mentioned long time ago, we really might want different initscripts for different platforms:
- redhat/fedora
- suse
- debian/ubuntu
- bsd
- Windows?

I'm not a bsd user but iirc they do not use SysV init so at least there we should go for a seperate implementation matching their startup framework.

#7 Updated by Meier about 4 years ago

I added a redhat/fedora specific init script. Currently is uses --user in the startup so only works if all necessary files belong to nagios, that avoids the "reload problem".

#8 Updated by dnsmichi about 4 years ago

  • Target version changed from 1.0.1 to 1.0.2

needs more investigations, postponed.

#9 Updated by dnsmichi about 4 years ago

during the show-errors feature from wolfang and now in git, i also changed the behavior when icinga daemon cannot be stopped in a timely manner.

before, the 10 times retry loop failed, and an error msg was the output. afterwards, the pid/lock was removed automatically. but icinga daemon was running - so everyone needed to killall -9 icinga - no this is changed into not removing that and just telling the user to try again.

imho that's a better solution regarding usability. on large environments it will happen, that stopping icinga will no be possible and doing it manually everytime is not a prefered solution.

#10 Updated by dnsmichi almost 4 years ago

  • Assignee deleted (hbaecker)
  • Target version deleted (1.0.2)
  • % Done changed from 0 to 80

#11 Updated by Meier almost 4 years ago

for redhatish systems this is fixed in daemon-init-redhat.in

4e99d936674173cfc5673c2c9121f8a5d1386b36

#12 Updated by Meier almost 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 80 to 100

Also available in: Atom PDF