ExIP is a “research project” to monitor and analyze my router’s (external) ip address and hostname.
A cronjob executes a simple shell script which queries (via w3m -dump_source; tried wget, but the output lacks the ip, don’t know why) the external ip from www.wieistmeineip.de. After that it gets the hostname via the host command. The results will be saved to a csv file (because it’s easy to write).
Now the “real” script comes in. It’s written in Python 3 and it converts the csv file and fills a sqlite3 database. The script is also able to create a neat html file with statistics. (Yeah, the workflow could be a bit better, but it’s only a test for now. The shell script is very small and handy and Python’s sqlite3 support is very good. I wanted to do something with sqlite3, because I was trying to learn sql.)
A sample file is attached. (Note: The normal output isn’t masked. The sed script which masks the page is included in the tarball.)
(Of course, this looks ugly, but I don’t want to set $PATH by myself. If $PATH isn’t set (env -i) sh will set the variable to a proper value. The directory must be changed first, because the script writes the resulting csv file to ./ip.csv. A change of this behavior will be easy to implement if you want.)
This will read the csv table from the file (or if filename isn’t set from stdin) and update the database.
This will save a html page to the file (or if filename isn’t set print it to stdout).
Parts of this page have been generated automatically. Last update: Wed, 19 May 2010 21:40:53 +0200