9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] dns
Date: Mon, 20 Aug 2012 21:59:02 -0400	[thread overview]
Message-ID: <1748b045cc1050dc736dc683b0ec4db1@brasstown.quanstro.net> (raw)
In-Reply-To: <2D9EDA28-F8AC-441B-82B5-1A4BD08ED0F5@corpus-callosum.com>

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

i'm using a modified version of dns.  i found that aktomi
redirections too unreliable.  even so, i still get crashes, which have
become more frequent in recent weeks.  i've attached a copy of
"restartdns" which is ment to be called from cron on short intervals.

contrib quanstro/ndb has the whole nine yards.

one of these days i will redo dns with a better (and maintainable)
structure.  :-).  but please beat me to it.

- erik

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

#!/bin/rc
rfork en
nl='
'
mailto=(quanstro)
allow=(ladd)
recursive=()
gcidr = (
	# only blocks that can map to google's a records
	72.14.192.0/18
	74.125.0.0/16
	209.85.128.0/17
	216.239.32.0/19
	173.194.0.0/16
)

if(! ~ `{cat /dev/user} `{cat /dev/hostowner}){
	echo 'restartdns: must be hostowner' >[1=2];
	exit user
}

9fs other

fn syslog{
	echo $sysname `{date} restartdns: $* > /sys/log/dns
}

fn pgroup{
	ifs=$nl g=`{cat /proc/$1/noteid}
	for(i in `{grep -l $g /proc/*/noteid | sed 's:/proc/([^/]+)/noteid:\1:g'})
		if(test -d /proc/$i)
			echo $i
}

fn reaper{
	nbroken=()
	for(i in `{ps | awk '$6 == "Broken" && $7 == "dns" {print $2}'}){
		r = /n/other/$user/dnssnap/$sysname.$i.`{date -n}
		snap -o $r `{pgroup $i}
		nbroken = ($nbroken $r)
	}
}

fn getips{
	ndb/dnsquery $* | sed 's/.*[ 	]//g'
}

fn google{
	google=()
	if(! ip/cidr -rf <{getips google.com} <{echo $gcidr})
		google=1
	if(ip/cidr -f /lib/badcidr <{getips 9fans.net} )
		google=($google 2)
}

fn why{
	if(! ~ $#nbroken 0){
		echo getting mediæval on $#nbroken broken dns processes.
		for(i in $nbroken)
			echo $i
	}
	if(! ~ $#nwait 0){
		echo getting mediæval on $#nwait deadlocked dns processes.
		for(i in $nwait)
			echo $i
	}
	if(! ~ $#google 0){
		echo google broken
		ndb/dnsquery google.com
		ndb/dnsquery 9fans.net any
	}
}

flagfmt='p,f'
args=()
if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 0){
	aux/usage
	exit usage
}

if(~ $#flagf 0){
	if(! ~ $sysname $allow)
		exit 'wrong system'
	reaper
	ifs=$nl nwait=`{ps -a |sed -n 's/.* +dns \[query lock wait for(.*)\]/\1/gp' | sort | uniq -c | awk '$1>2'}
	google

	if(~ $#nbroken 0 && ~ $#nwait 0 && ~ $#google 0)
		exit 'none broken'
	why
	if(~ $service rx)
		{date; echo; why; echo; ps -a | grep ' dns ' }| mail -s 'restartdns: '^$sysname $mailto
}

if(~ $flagp 1)
	exit ''

syslog slaying broken $#nbroken nwait $#nwait google $#google

dns = ndb/dns
slaydns = `{echo $dns | sed 's:.*/::g'}
slay $slaydns | rc
unmount '#s/dns' /net/dns >[2=]
unmount '#s/dns_net.alt' /net.alt/dns >[2=]
rm -f '#s/dns'  '#s/dns_net.alt'

$dns -N 20000 -s
if(~ $sysname $recursive)
	$dns -sx /net.alt -f /lib/ndb/external
if not
	$dns -Rrsx /net.alt -f /lib/ndb/external

  reply	other threads:[~2012-08-21  1:59 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21  1:51 Jeff Sickel
2012-08-21  1:59 ` erik quanstrom [this message]
2012-08-21  4:23 ` arisawa
2012-08-21  5:08   ` Jeff Sickel
2012-08-21  8:42     ` Kenji Arisawa
2012-08-21 11:27       ` cinap_lenrek
2012-08-21 12:18         ` Lucio De Re
2012-08-21 12:37         ` arisawa
2012-08-21 18:32         ` erik quanstrom
2012-08-21 20:05           ` Charles Forsyth
     [not found]           ` <CAOw7k5hALBex13jJUbscVt4th-Z9urpmAP0eOBi7b1HuBQESrw@mail.gmail.c>
2012-08-21 20:41             ` erik quanstrom
2012-08-21 22:44           ` cinap_lenrek
2012-08-22 10:32           ` cinap_lenrek
2012-08-22 12:09             ` Kenji Arisawa
2012-08-22 12:35               ` cinap_lenrek
2012-08-22 13:05                 ` erik quanstrom
2012-08-22 13:08                   ` erik quanstrom
2012-08-22 13:11                   ` Charles Forsyth
     [not found]                   ` <CAOw7k5gGhL-=E=V1C9ffQP7qMyUVMhtrgpzLMidnCsHFGDzHwA@mail.gmail.c>
2012-08-22 13:18                     ` erik quanstrom
2012-08-22 13:21                       ` Charles Forsyth
2012-08-22 13:31                       ` cinap_lenrek
2012-08-22 14:22                         ` erik quanstrom
2012-08-22 14:41                           ` Charles Forsyth
2012-08-22 14:47                           ` cinap_lenrek
2012-08-22 15:26                             ` erik quanstrom
2012-08-22 15:33                             ` erik quanstrom
2012-08-22 15:35                               ` erik quanstrom
     [not found]                             ` <CAOw7k5jOE0Bf13fXJ04dUF4vGniRTJ1LwEMV1Oqw=AFKg77boA@mail.gmail.com>
2012-08-22 16:05                               ` Charles Forsyth
2012-08-22 13:23                 ` Lucio De Re
2012-08-25  0:10         ` Kenji Arisawa
2012-08-25 10:54           ` cinap_lenrek
2012-08-25 12:37             ` Kenji Arisawa
2012-08-25 13:22               ` cinap_lenrek
2012-08-25 13:38                 ` cinap_lenrek
2012-08-25 13:41                 ` Charles Forsyth
2012-08-25 13:44                   ` cinap_lenrek
2012-08-27 22:44               ` arisawa
2012-08-28  1:45                 ` cinap_lenrek
2012-08-28  1:57                   ` erik quanstrom
2012-08-28  2:08                     ` cinap_lenrek
2012-08-28  4:03                       ` erik quanstrom
2012-09-08 17:37                         ` Skip Tavakkolian
2012-09-08 18:02                           ` cinap_lenrek
2012-09-08 18:18                           ` cinap_lenrek
2012-09-08 21:53                             ` Skip Tavakkolian
2012-09-08 22:27                               ` cinap_lenrek
2012-09-09  2:09                                 ` Charles Forsyth
2012-09-09  2:37                                   ` cinap_lenrek
2012-09-09  3:01                                     ` Charles Forsyth
     [not found]                                     ` <CAOw7k5jydN7wssxBEqTc6h9FtLErjkoyxyfuQZLgcBTZ-nRgiw@mail.gmail.c>
2012-09-09  4:26                                       ` erik quanstrom
2012-09-09  5:28                                         ` Skip Tavakkolian
2012-08-25 21:56           ` cinap_lenrek
2012-08-26 13:16             ` cinap_lenrek
2012-08-26 13:36               ` Charles Forsyth
2012-08-21  5:08 ` Benjamin Huntsman
  -- strict thread matches above, loose matches on Subject: below --
2017-04-01  1:28 [9fans] DNS cinap_lenrek
2017-04-01  3:40 ` Skip Tavakkolian
2017-04-01  9:46   ` Alexandru Gheorghe
2017-04-01 17:04     ` Steve Simon
2017-04-03  7:06       ` David Arroyo
2017-03-20  7:26 Skip Tavakkolian
2017-03-21 19:19 ` Skip Tavakkolian
2017-03-30 22:19   ` Steve Simon
2017-03-31  7:43   ` Peter Hull
2012-08-26 14:48 [9fans] dns cinap_lenrek
2007-08-15 19:26 erik quanstrom
2007-07-03 20:54 erik quanstrom
2007-07-04 20:51 ` geoff
2007-07-04 21:18   ` erik quanstrom
2007-07-04 21:52     ` geoff
2004-03-20  2:25 David Presotto

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=1748b045cc1050dc736dc683b0ec4db1@brasstown.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /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).