9front - general discussion about 9front
 help / color / mirror / Atom feed
From: rgl@antares-labs.eu
To: 9front@9front.org
Subject: [9front] stats: resilience to machine disconnections
Date: Thu, 01 Jul 2021 08:00:06 +0200	[thread overview]
Message-ID: <9B3506067B3042F3D6F00E7AF5015E00@antares-labs.eu> (raw)

[-- Attachment #1: Type: text/plain, Size: 464 bytes --]

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


[-- Attachment #2: Type: text/plain, Size: 928 bytes --]

--- //.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;

                 reply	other threads:[~2021-07-01  9:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9B3506067B3042F3D6F00E7AF5015E00@antares-labs.eu \
    --to=rgl@antares-labs.eu \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).