From owner-freebsd-hackers Mon Oct 28 7:31:51 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A55137B401; Mon, 28 Oct 2002 07:31:49 -0800 (PST) Received: from mail.ubergeeks.com (lorax.ubergeeks.com [209.145.65.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id 92F6743E3B; Mon, 28 Oct 2002 07:31:48 -0800 (PST) (envelope-from adrian+freebsd-audit@ubergeeks.com) Received: from mail.ubergeeks.com (localhost [127.0.0.1]) by mail.ubergeeks.com (8.12.5/8.12.5) with ESMTP id g9SFVgel064168; Mon, 28 Oct 2002 10:31:42 -0500 (EST) (envelope-from adrian+freebsd-audit@ubergeeks.com) Received: from localhost (adrian@localhost) by mail.ubergeeks.com (8.12.5/8.12.5/Submit) with ESMTP id g9SFVfCq064165; Mon, 28 Oct 2002 10:31:42 -0500 (EST) (envelope-from adrian+freebsd-audit@ubergeeks.com) X-Authentication-Warning: lorax.ubergeeks.com: adrian owned process doing -bs Date: Mon, 28 Oct 2002 10:31:41 -0500 (EST) From: Adrian Filipi-Martin To: Juli Mallett Cc: Maxim Sobolev , Nate Lawson , , , Subject: Re: New kevent types: NOTE_STARTEXEC and NOTE_STOPEXEC In-Reply-To: <20021027010429.A90908@FreeBSD.org> Message-ID: <20021028102544.O64046-100000@lorax.ubergeeks.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 27 Oct 2002, Juli Mallett wrote: > * De: Maxim Sobolev [ Data: 2002-10-27 ] > [ Subjecte: Re: New kevent types: NOTE_STARTEXEC and NOTE_STOPEXEC ] > > On Sat, Oct 26, 2002 at 06:09:31PM -0700, Nate Lawson wrote: > > > On Thu, 24 Oct 2002, Maxim Sobolev wrote: > > > > Please review the patch, which adds two new types of events - > > > > NOTE_STARTEXEC and NOTE_STOPEXEC, that could be used to get > > > > notification when the image starts or stops executing. For example, it > > > > could be used to monitor that a daemon is up and running and notify > > > > administrator when for some reason in exits. I am running this code > > > > for more than a year now without any problems. > > > > > > > > Any comments and suggestions are welcome. > > > > > > Couldn't this just be done by init(8) and /etc/ttys? Or inetd? If you > > > want to write your own, couldn't you use waitpid()? Or a kevent() of > > > EVFILT_PROC with NOTE_EXIT/NOTE_FORK? I'm not sure I see the need for > > > this. > > > > EVFILT_PROC operates on pids, while NOTE_{START,STOP}EXEC operate on > > vnodes - it is the main difference. Currently, you can't reliably > > get a notification when kernes started executing some arbitrary > > executable from your fs. > > This is not a job for the kernel, I don't think. Implement it in userland > in terms of having the daemon write to a pidfile at startup, and have SIGUSR1 > make it tell the sender it's alive (using my sigq stuff this is trivial, just > send SIGUSR2 back), and periodically read the pidfile and try to communciate > with the daemon, and respawn it if it fails. This could be racey if done > poorly. However if you want this for *any* executable, rather than just > "some arbitrary executable" rather than some specific job, then while I wonder > how useful it is in a generic concept, the kq solution might be more > reasonable. > > Juli Mallett | FreeBSD: The Power To Serve Monitoring process health isn't nearly as intersting as being able to track system statistics for IDS purposes. STOP/START_EXEC tracking would make it much easier to profile a running system and then generate a statistical profile of what should normally be running. This cannot be accurately done outside the kernel. Adrian -- [ adrian@ubergeeks.com ] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message