From owner-freebsd-questions@freebsd.org Sat Oct 3 22:10:43 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5632C3F1451 for ; Sat, 3 Oct 2020 22:10:43 +0000 (UTC) (envelope-from dewayne@heuristicsystems.com.au) Received: from hermes.heuristicsystems.com.au (hermes.heuristicsystems.com.au [203.41.22.115]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2560 bits) client-digest SHA256) (Client CN "hermes.heuristicsystems.com.au", Issuer "Heuristic Systems Type 4 Host CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C3gzN4sqxz3cls for ; Sat, 3 Oct 2020 22:10:40 +0000 (UTC) (envelope-from dewayne@heuristicsystems.com.au) Received: from [10.0.5.3] (noddy.hs [10.0.5.3]) (authenticated bits=0) by hermes.heuristicsystems.com.au (8.15.2/8.15.2) with ESMTPSA id 093M9Sed032396 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 4 Oct 2020 09:09:29 +1100 (AEDT) (envelope-from dewayne@heuristicsystems.com.au) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=heuristicsystems.com.au; s=hsa; t=1601762972; x=1602367773; bh=onw26L0cfpmqKfFXFB5mbCcN3FtQDPcwPExjO8A2JiU=; h=Subject:To:From:Message-ID:Date; b=TCRXSoPdL4roCWpBTlWXU2LCzDIFFGPKQtQJ0FDnI4oXSxDeZ4LJ3m+Ddh5r5/+uJ NXyrRIsE/aiYKH3M+RBag5tMKjpIUonGQtXGcRyvBbe3Bzup++bW6UiAYj/Kz0jV3z 2OqFjkaEZ7UOL+XXG0qusPZoeKkJpGwIRPRaXyjRG+YRd9jjdSniJ X-Authentication-Warning: b3.hs: Host noddy.hs [10.0.5.3] claimed to be [10.0.5.3] Subject: Re: Monitor an app To: freebsd-questions@freebsd.org, Jerry References: <65C3BE67-3389-4F8E-9975-7EC0714FB056@kreme.com> <20201002075125.000001d6@seibercom.net> From: Dewayne Geraghty Message-ID: <69ec859f-163d-2908-7e34-bc3d1c8d3381@heuristicsystems.com.au> Date: Sun, 4 Oct 2020 09:09:21 +1100 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20201002075125.000001d6@seibercom.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4C3gzN4sqxz3cls X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=heuristicsystems.com.au header.s=hsa header.b=TCRXSoPd; dmarc=none; spf=pass (mx1.freebsd.org: domain of dewayne@heuristicsystems.com.au designates 203.41.22.115 as permitted sender) smtp.mailfrom=dewayne@heuristicsystems.com.au X-Spamd-Result: default: False [-5.39 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[heuristicsystems.com.au:s=hsa]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.01)[-1.011]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; DMARC_NA(0.00)[heuristicsystems.com.au]; DWL_DNSWL_MED(-2.00)[heuristicsystems.com.au:dkim]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[203.41.22.115:from]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[heuristicsystems.com.au:+]; NEURAL_HAM_MEDIUM(-1.01)[-1.010]; NEURAL_HAM_SHORT(-0.17)[-0.165]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:1221, ipnet:203.40.0.0/13, country:AU]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-questions]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Oct 2020 22:10:43 -0000 On 2/10/2020 9:51 pm, Jerry wrote: > On Fri, 2 Oct 2020 04:59:59 -0600, @lbutlr commented: >> Are there any tools that monitor apps or services and do sane things >> to make sure that the series are running? >> >> Obviously, I can write a simple script that says something like "if >> service status doesn't have a PID, then …" but that's >> simplistic and I don't want something that is simply going to restart >> a failed service over and over every time it crashes. (But once or >> twice when it crashes is good, with an escalation to maybe restart a >> different series and a fall back from that to restart the machine… but >> again, not restarting the machine a few seconds after boot because it >> can't start the service.) >> >> I am not looking for something that says "hey, email is not working" >> (I already have that but more subtly like "Hey, dovecot isn't running" >> or "MySQL isn't running". >> >> Googling leads me to external monitoring of forward facing services >> based on port scanning, I'm looking for something local to the machine. > > Have you considered "/sysutils/monit" or one of its cousins? It might > do what you want. It an be configured to limit the number of times it > will attempt to restart a program, and lots of other things too. > I've used monit for a few years and its VERY helpful. Though, for the reason that you reference managing applications via PID, I've also incorporated s6 and s6-rc to manage services (and hence eliminate reliance upon a PID). monit is very easy to learn and should do most of what you want, s6 and friends have a steep learning curve. (If you choose the latter, the gentoo website has an excellent guideline) Cheers. PS port scanning is like penetration testing - last resort for technical folks, yet often mandated by management ;)