From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Mon, 20 Aug 2012 21:59:02 -0400 To: 9fans@9fans.net Message-ID: <1748b045cc1050dc736dc683b0ec4db1@brasstown.quanstro.net> In-Reply-To: <2D9EDA28-F8AC-441B-82B5-1A4BD08ED0F5@corpus-callosum.com> References: <2D9EDA28-F8AC-441B-82B5-1A4BD08ED0F5@corpus-callosum.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-vjspztklabatnqysbyhqluexwo" Subject: Re: [9fans] dns Topicbox-Message-UUID: ad41e244-ead7-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-vjspztklabatnqysbyhqluexwo Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 --upas-vjspztklabatnqysbyhqluexwo Content-Disposition: attachment; filename=restartdns Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable #!/bin/rc rfork en nl=3D' ' mailto=3D(quanstro) allow=3D(ladd) recursive=3D() gcidr =3D ( # 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=3D2]; exit user } 9fs other fn syslog{ echo $sysname `{date} restartdns: $* > /sys/log/dns } fn pgroup{ ifs=3D$nl g=3D`{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=3D() for(i in `{ps | awk '$6 =3D=3D "Broken" && $7 =3D=3D "dns" {print $2}'})= { r =3D /n/other/$user/dnssnap/$sysname.$i.`{date -n} snap -o $r `{pgroup $i} nbroken =3D ($nbroken $r) } } fn getips{ ndb/dnsquery $* | sed 's/.*[ ]//g' } fn google{ google=3D() if(! ip/cidr -rf <{getips google.com} <{echo $gcidr}) google=3D1 if(ip/cidr -f /lib/badcidr <{getips 9fans.net} ) google=3D($google 2) } fn why{ if(! ~ $#nbroken 0){ echo getting medi=C3=A6val on $#nbroken broken dns processes. for(i in $nbroken) echo $i } if(! ~ $#nwait 0){ echo getting medi=C3=A6val 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=3D'p,f' args=3D() if(! ifs=3D() eval `{aux/getflags $*} || ! ~ $#* 0){ aux/usage exit usage } if(~ $#flagf 0){ if(! ~ $sysname $allow) exit 'wrong system' reaper ifs=3D$nl nwait=3D`{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 =3D ndb/dns slaydns =3D `{echo $dns | sed 's:.*/::g'} slay $slaydns | rc unmount '#s/dns' /net/dns >[2=3D] unmount '#s/dns_net.alt' /net.alt/dns >[2=3D] 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 --upas-vjspztklabatnqysbyhqluexwo--