supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Querying service status :: A suggestion
@ 2005-08-09 12:23 B S Srinidhi
  2005-08-09 15:14 ` Joël Riou
  0 siblings, 1 reply; 2+ messages in thread
From: B S Srinidhi @ 2005-08-09 12:23 UTC (permalink / raw)


Hello list,

I'm new to this list but not to runit. :) 

I'm writing a small utility to show the status of the services being
supervised. One of the main challenges (for me) was to find the time the
service spent in the current state. e.g., how long a service has been
down, etc. I checked runit's sources to get a clue, but wasn't able to
(confidently) implement anything. (I'm not very comfortable with
tai64n) :(

I observed something in the behavior of runsvctrl and friends, but I'm
not sure. 

Whenever a service is sent a signal, the supervise/status file is
regenerated. (???) In other words, its creation time stamp gets changed.
So I thought that a simple stat() of supervise/status file could give me
the creation time and then a simple difftime() against the current
time(NULL) could give the last change status.

Is this approach *sane*??? :) If not, then could someone please explain
the correct procedure?

Srinidhi.
-- 
B S Srinidhi <srinidhi@deeproot.co.in>
DeepRoot Linux Pvt. Ltd.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Querying service status :: A suggestion
  2005-08-09 12:23 Querying service status :: A suggestion B S Srinidhi
@ 2005-08-09 15:14 ` Joël Riou
  0 siblings, 0 replies; 2+ messages in thread
From: Joël Riou @ 2005-08-09 15:14 UTC (permalink / raw)
  Cc: supervision

Le mardi  9 août 2005, B S Srinidhi a écrit :
> Whenever a service is sent a signal, the supervise/status file is
> regenerated. (???) In other words, its creation time stamp gets changed.

That seems true, the update_status() function in runsv.c creates a
"supervise/status.new" file, store the information, and finally calls
rename("supervise/status.new", "supervise/status") to atomically replace
the previous status file.

> So I thought that a simple stat() of supervise/status file could give me
> the creation time and then a simple difftime() against the current
> time(NULL) could give the last change status.
> 
> Is this approach *sane*??? :) If not, then could someone please explain
> the correct procedure?

I do not really see why it may not be sane in usual configurations, but a
more reliable way to do this is to use the information actually stored in
supervise/status as the runsvstat program does ; the structure of this file
is very simple, you will not have to embed an XML parser in your program :)

-- 
Joël Riou



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-08-09 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-09 12:23 Querying service status :: A suggestion B S Srinidhi
2005-08-09 15:14 ` Joël Riou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).