From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14383 invoked from network); 1 Jul 2021 09:08:32 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 1 Jul 2021 09:08:32 -0000 Received: from mslow1.mail.gandi.net ([217.70.178.240]) by 1ess; Thu Jul 1 02:02:23 -0400 2021 Received: from relay8-d.mail.gandi.net (unknown [217.70.183.201]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 7B5D0C423F for <9front@9front.org>; Thu, 1 Jul 2021 06:00:25 +0000 (UTC) Received: (Authenticated sender: rgl@antares-labs.eu) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 58FB51BF20F; Thu, 1 Jul 2021 06:00:15 +0000 (UTC) Message-ID: <9B3506067B3042F3D6F00E7AF5015E00@antares-labs.eu> Date: Thu, 01 Jul 2021 08:00:06 +0200 From: rgl@antares-labs.eu To: 9front@9front.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-pptjnsmpwisgbqxrdlglxpbnch" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: immutable proxy self-signing persistence module-based optimizer Subject: [9front] stats: resilience to machine disconnections Reply-To: 9front@9front.org Precedence: bulk This is a multi-part message in MIME format. --upas-pptjnsmpwisgbqxrdlglxpbnch Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit hi everyone, the following is a patch to allow stats(1) to reconnect to a machine that went awol, be it for network or other issues. i don't think it's the best procedure, especially given how it blocks the Mainproc, although it does the job for me and my usual monitoring-after-reboot needs. if any of you have a better method (to keep the graphs drawing would be neat), please let me know. i'll keep fiddling with it when i have more time. best, -rodri --upas-pptjnsmpwisgbqxrdlglxpbnch Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit --- //.git/fs/object/658757abed7be283e06bae3b1722fc2703334d74/tree//sys/src/cmd/stats.c +++ /sys/src/cmd/stats.c @@ -550,6 +550,20 @@ return i; } +char* +delmachine(Machine *m) +{ + free(m->shortname); + close(m->statsfd); + close(m->swapfd); + close(m->etherfd); + close(m->ifstatsfd); + close(m->batteryfd); + close(m->bitsybatfd); + close(m->tempfd); + return m->name; +} + int initmach(Machine *m, char *name) { @@ -717,11 +731,15 @@ { int n, i; uvlong a[nelem(m->devsysstat)]; - char buf[32]; + char buf[32], *machname; if(m->remote && (m->disable || setjmp(catchalarm))){ - if (m->disable++ >= 5) + if (m->disable++ >= 5){ m->disable = 0; /* give it another chance */ + machname = delmachine(m); + initmach(m, machname); + free(machname); + } memmove(m->devsysstat, m->prevsysstat, sizeof m->devsysstat); memmove(m->netetherstats, m->prevetherstats, sizeof m->netetherstats); return; --upas-pptjnsmpwisgbqxrdlglxpbnch--