Bug 127444 - sysutils/nagios-statd: RC script fails to log a valid PID, cannot detect running instance
Summary: sysutils/nagios-statd: RC script fails to log a valid PID, cannot detect runn...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Stefan Walter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-17 16:50 UTC by Tyler Aviss
Modified: 2009-01-28 12:00 UTC (History)
0 users

See Also:


Attachments
nagios-statd-pidfile.diff (1.06 KB, patch)
2009-01-27 13:56 UTC, Stefan Walter
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Aviss 2008-09-17 16:50:02 UTC
nagios-statd does not appear to by default create a pidfile (or not in the location the rc script expects).

Starting nagios-statd via /usr/local/etc/rc.d/nagiosstatd will therefore launch the daemon, but not create a PIDfile. This in turn means that attempting to start or restart the daemon via the RC script will fail, as it does not detect a running instance.

How-To-Repeat: $ /var/run$ /usr/local/etc/rc.d/nagiosstatd start
Starting nagiosstatd.
$ ps auxwww | grep statd
root    68885  0.0  0.2  5140  3696  ??  Ss   11:30AM   0:00.04 python /usr/local/sbin/nagios-statd
$ ls /var/run/nagiosstatd.pid
ls: /var/run/nagiosstatd.pid: No such file or directory
$ /var/run$ /usr/local/etc/rc.d/nagiosstatd restart
nagiosstatd not running?
Starting nagiosstatd.
Port 1040 is already in use.  Unable to bind - exiting.

Manually adding a "-P /var/run/nagiosstatd.d" will create the pidfile, but a stop/restart will still complain that the daemon is not running (even when it is, and the pidfile contains a valid process-id for statd)
Comment 1 Remko Lodder freebsd_committer freebsd_triage 2008-09-17 17:11:49 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

reassign to ports team
Comment 2 Stefan Walter freebsd_committer freebsd_triage 2008-10-12 08:11:24 UTC
Dear maintainer of sysutils/nagios-statd,

a problem report has been submitted for your port for which your 
feedback might be required; its contents can be found at [1]. If it 
contains a patch or suggestions for a change, please send a followup to 
the PR explaining whether or not you approve it and want it to be 
committed.

Regards,
Stefan

[1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/127444
Comment 3 Stefan Walter freebsd_committer freebsd_triage 2008-10-12 08:12:00 UTC
Responsible Changed
From-To: freebsd-ports-bugs->stefan

Take.
Comment 4 Stefan Walter freebsd_committer freebsd_triage 2008-10-21 13:07:14 UTC
Hi Tyler,

there hasn't been a reply by the maintainer of sysutils/nagios-statd, yet.
Can you provide a patch with changes that fix the problem you reported?

Regards,
Stefan
Comment 5 Stefan Walter freebsd_committer freebsd_triage 2008-10-21 21:21:02 UTC
Maintainer replied in private mail:

Jim Shewmaker, 21.10.08, 17:25h CEST:

> Hi Stefan,
> 
> I am traveling out of the country and haven't had a chance to look at
> it yet.  I should have sometime time tomorrow to hopefully finish a
> patch (assuming the description is valid).  thanks.
> 
> Regards,
> 
> Jim Shewmaker
Comment 6 Stefan Walter freebsd_committer freebsd_triage 2008-10-21 21:21:40 UTC
Submitter replied in private mail:

Aviss, Tyler, 21.10.08, 19:42h CEST:

> I have a modified/hacked-up version of the RC script. I've been running 
> into another bug more recently though. Even when statd is terminated and 
> the process is no longer running, sometimes it hangs on to the port for 
> awhile which causes a new instance to fail on restart. I tried to add a 
> few "sleep" lines to avoid this, but how long it holds on seems random 
> up to a minute or sometimes a bit more.
> 
> I'll see if I can dig up the modified script, though your mileage may vary.
> 
> 
> - TJA
Comment 7 Stefan Walter freebsd_committer freebsd_triage 2008-12-10 10:33:40 UTC
Hi Tyler, hi Jim,

there hasn't been a followup to this PR [1] for a while. Any news on this
issue?

Regards,
Stefan

[1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=127444
Comment 8 Stefan Walter freebsd_committer freebsd_triage 2008-12-10 15:43:37 UTC
Submitter replied in private mail:

Tyler Aviss, 10.12.08, 16:23h CET:

> Hmm. Well my modifications are definitely an outright "hack" (although 
> hatchet-job might be more description) of the RC file, so I wouldn't 
> want to put them up here even though they do work.
> 
> Basically adding a -P ${pidfile} to the flags, and having it read that 
> file on a "stop" then kill the associated process will work. A restart 
> is tricky though, since (on my boxes at least) nagios sometimes takes 
> quite awhile to release the port even after being killed, in which case 
> you need to do a sleep between the stop and start. The time for this 
> varies though... I'm not sure why.
> 
> - TJA
Comment 9 Stefan Walter freebsd_committer freebsd_triage 2009-01-27 13:56:58 UTC
Hi Tyler, hi Jim,

I finally had a bit of time to look for the problem in the rc script. Can
you two please verify that the attached patch fixes the problem?

The definition of $pidfile in the script referenced another variable that
didn't exist, and it's necessary to set $command_interpreter here because
the daemon process is a Python script.

I didn't see any problems with 'restart' here. If this fix works for you,
I'll commit it.

Best regards,
Stefan
Comment 10 dfilter service freebsd_committer freebsd_triage 2009-01-28 11:58:25 UTC
stefan      2009-01-28 11:58:14 UTC

  FreeBSD ports repository

  Modified files:
    sysutils/nagios-statd Makefile 
    sysutils/nagios-statd/files nagiosstatd.sh.in 
  Log:
  Fix stopping the daemon via rc script by properly setting $pidfile and
  $command_interpreter.
  
  PR:             127444
  Submitted by:   Tyler Aviss <a-freebsd@phormix.com>
  Patch by:       stefan
  
  Revision  Changes    Path
  1.6       +1 -0      ports/sysutils/nagios-statd/Makefile
  1.2       +3 -1      ports/sysutils/nagios-statd/files/nagiosstatd.sh.in
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 11 Stefan Walter freebsd_committer freebsd_triage 2009-01-28 11:58:35 UTC
State Changed
From-To: open->closed

Patch committed. Thanks for your report!