Wiki source for Falks


Show raw source

**Script and Website for live NS0 data driven Smokeping configuration file generation**

== Smokeping / Monitorung URL ==
[[http://frontline.paketsequenz.de/smokeping/smokeping.cgi | Smokeping for OpenNIC on Paketsequenz]]

== Script ==
This script generates the Targets file for /etc/smokeping/config.d on a Debian squeeze box. The shown smokeping Installation on the URL above is generated. This is still development Quality software/website!

%%(bash)
#!/bin/bash
# 2012, Falk

# This script assumes the following hostname format for Tier 2 Servers
# Servername(nsX).State(NRW).Country(DE).DontCare
#
# And outputs a Targets file for smokeping

# Whats the IPv4 address of NS0?
NS0="75.127.96.89"

# Where can we store some tmpfiles?
TMPDIR="/tmp/"

function getHostByName()
{
host -Ts "${1}" | awk '{ print $4}'
}
tier1=`dig opennic.glue NS @${NS0}| egrep '.opennic.glue.[[:blank:]][0-9]{1,6}' | awk '{print $1}' | uniq`
tier2=`dig axfr dns.opennic.glue @${NS0}| egrep '.dns.opennic.glue. [0-9]{1,6} IN' | cut -d " " -f 1 | uniq`


# First, let's generate a static preamble to make all things nice and tight!
echo "
*** Targets ***

probe = DNS

menu = Top
title = OpenNIC Infrastructure
remark = Welcome to OpenNIC Infrastructure Monitoring



+ OpenNIC

menu = OpenNIC Topology
title = All OpenNIC registered Nameservers from NS0 zone



++ NS0
host = ${NS0}
title = Tier 0 (NS0)


++ Tier1
menu = Tier1
title = Tier 1 Nameservers
"
# Now lets add all Tier 1 servers to this cool list
for server in ${tier1}
do
echo "+++ "`echo ${server%?} | sed 's/\./_/g'`
echo "host = ${server%?}"
done
# Lets add another preamble for the Tier 2 servers
echo "



++ Tier2
menu = Tier2
title = Tier 2 Nameservers
"
for server in ${tier2}
do
# Get the de from ns1.nrw.de.dontcare and save it for tree generation
serverCountry=`echo ${server} | cut -d "." -f 3`
echo "++++ "`echo ${server%?} | sed 's/\./_/g'` >> "${TMPDIR}/onictarget_${serverCountry}"
echo "host = ${server%?}" >> "${TMPDIR}/onictarget_${serverCountry}"
done
for countryFile in `ls ${TMPDIR}/onictarget_*`
do
country=`echo ${countryFile} | cut -d "_" -f 2 | tr 'a-z' 'A-Z'`
echo "+++ ${country}
menu = ${country}
title = Tier 2 Nameservers in ${country}
"
cat ${countryFile}
done
rm ${TMPDIR}/onictarget_*

%%
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki