Skip to content
This repository has been archived by the owner. It is now read-only.

[dev.icinga.com #4243] init script status exit codes on not running daemon and present pid file #1292

Closed
icinga-migration opened this issue Jun 4, 2013 · 4 comments
Labels
Milestone

Comments

@icinga-migration
Copy link
Member

@icinga-migration icinga-migration commented Jun 4, 2013

This issue has been migrated from Redmine: https://dev.icinga.com/issues/4243

Created by adrianlzt on 2013-06-04 14:07:38 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2013-06-29 16:30:45 +00:00)
Target Version: 1.9.3
Last Update: 2013-07-07 15:39:25 +00:00 (in Redmine)

Icinga Version: 1.8.2
OS Version: Linux

If the pid file (/var/run/icinga.pid) is present, but icinga is not running, running status in the init.d gives the correct message (icinga is not running), but the return code is 0, when it must be 3.

A patch is attached.

Attachments

  • icinga.patch adrianlzt - 2013-06-04 14:05:05 +00:00 - Fix return code when icinga is not running but pid file present

Changesets

2013-06-29 16:28:21 +00:00 by (unknown) 45915d9

core: fix init script status exit codes on not running daemon and present pid file

- exit 3 when daemon is not running (means no pid file)
- exit 1 when daemon is dead, but pid file there

fixes #4243

2013-07-01 21:02:50 +00:00 by (unknown) b22c934

core: fix init script status exit codes on not running daemon and present pid file

- exit 3 when daemon is not running (means no pid file)
- exit 1 when daemon is dead, but pid file there

fixes #4243

Conflicts:
	Changelog
@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Jun 29, 2013

Updated by mfriedrich on 2013-06-29 16:20:08 +00:00

  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Priority changed from High to Normal
  • Target Version set to 1.10
  • Done % changed from 100 to 0

the issue is two-folded when calling the 'status' option on the init script

  • when a daemon is not running, lsb compliant exit status would be 3 instead of now 1
  • when a daemon is not running, but pid file exists, it should still be exit code 1 to illustrate the error

http://www.rcramer.com/tech/linux/init\_lsb.shtml

in order to solve the issue, rename printstatus() function to checkstatus() to illustrate the need of exit calls, and further, add a check function simply looking if pid file exists (if not, exit 3) and if, decide wether icinga pid is running, or pidfile is invalid and daemon dead (exit 1).

@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Jun 29, 2013

Updated by mfriedrich on 2013-06-29 16:25:47 +00:00

michi@sol ~/coding/icinga/icinga-core @ next $ sudo service icinga stop

michi@sol ~/coding/icinga/icinga-core @ next $ sudo service icinga status
icinga is not running
michi@sol ~/coding/icinga/icinga-core @ next $ echo $?
3

michi@sol ~/coding/icinga/icinga-core @ next $ sudo touch /var/run/icinga.pid
michi@sol ~/coding/icinga/icinga-core @ next $ sudo service icinga status
icinga is not running. removing /var/run/icinga.pid
michi@sol ~/coding/icinga/icinga-core @ next $ echo $?
1

michi@sol ~/coding/icinga/icinga-core @ next $ sudo service icinga start
Running configuration check...OK
Starting icinga: Starting icinga done.
michi@sol ~/coding/icinga/icinga-core @ next $ echo $?
0

michi@sol ~/coding/icinga/icinga-core @ next $ sudo service icinga restart
Running configuration check...OK
Stopping icinga: .Stopping icinga done.
Starting icinga: Starting icinga done.
michi@sol ~/coding/icinga/icinga-core @ next $ echo $?
0
@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Jun 29, 2013

Updated by Anonymous on 2013-06-29 16:30:45 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 45915d9.

@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Jul 7, 2013

Updated by mfriedrich on 2013-07-07 15:39:25 +00:00

  • Subject changed from Init.d script error when pid file is present to init script status exit codes on not running daemon and present pid file
  • Target Version changed from 1.10 to 1.9.3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.