9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] stats: resilience to machine disconnections
@ 2021-07-01  6:00 rgl
  0 siblings, 0 replies; only message in thread
From: rgl @ 2021-07-01  6:00 UTC (permalink / raw)
  To: 9front

[-- 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-01  9:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01  6:00 [9front] stats: resilience to machine disconnections rgl

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git