weblog d’un abbe

20080619

Filed under: Fun — abbe @ 2244

Please refer to the following *interesting* traceroute output from a
box in the VSNL network:

edmond@monte-cristo:~$ traceroute -I  msdn.microsoft.com
traceroute to msdn.microsoft.akadns.net (65.55.11.235), 30 hops max,
52 byte packets
 1  210.211.168.1.bb-static.vsnl.net.in (210.211.168.1)  26.749 ms
27.256 ms  27.091 ms
 2  delhi-203.200.108-213.vsnl.net.in (203.200.108.213)  26.836 ms
27.022 ms  26.588 ms
 3  59.163.16.138.static.vsnl.net.in (59.163.16.138)  294.918 ms
294.162 ms  295.428 ms
 4  219.64.231.5.mpls-vpn-sj.static.vsnl.net.in (219.64.231.5)
299.259 ms  299.098 ms  298.917 ms
 5  ge-6-3-0-46.pao-64cb-1b.ntwk.msn.net (207.46.46.67)  298.534 ms
299.173 ms  297.798 ms
 6  ge-1-2-0-0.tuk-64cb-1b.ntwk.msn.net (207.46.33.222)  312.887 ms
313.286 ms  313.417 ms
 7  ge-3-0-0-0.co1-64c-1b.ntwk.msn.net (207.46.34.41)  316.248 ms
317.286 ms  316.995 ms
 8  ge-0-0-0-0.co1-64c-1a.ntwk.msn.net (207.46.34.189)  321.016 ms
320.803 ms  320.532 ms
 9  10.22.8.62 (10.22.8.62)  321.021 ms  319.924 ms  319.659 ms
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *

And following is the output of traceroute from a box in Airtel Broadband network.

abbe [~] chateau% sudo traceroute -I msdn.microsoft.com
Password:
traceroute to msdn.microsoft.akadns.net (65.55.11.235), 64 hops max, 72 byte packets
 1  * * *
 2  ABTS-NCR-Static-246.220.160.122.airtelbroadband.in (122.160.220.246)  33.458 ms  29.046 ms  30.290 ms
 3  rasBTNLDel-static-174.215.56.202.mantraonline.com (202.56.215.174)  33.563 ms  31.811 ms  30.377 ms
 4  125.19.22.145 (125.19.22.145)  29.517 ms  28.377 ms  30.774 ms
 5  125.21.167.25 (125.21.167.25)  75.891 ms  75.737 ms  75.602 ms
 6  sl-gw39-nyc-10-1.sprintlink.net (160.81.228.73)  294.580 ms  301.473 ms  306.050 ms
 7  sl-bb21-nyc-3-0-0.sprintlink.net (144.232.13.57)  297.558 ms  297.729 ms  299.510 ms
 8  sl-bb22-nyc-14-0.sprintlink.net (144.232.7.102)  304.510 ms  314.244 ms  305.923 ms
 9  sl-bb21-chi-3-0-0.sprintlink.net (144.232.20.102)  332.567 ms  331.458 ms  331.284 ms
10  sl-bb25-chi-13-0.sprintlink.net (144.232.26.90)  328.455 ms  328.153 ms  360.344 ms
11  sl-bb20-sea-1-0.sprintlink.net (144.232.20.85)  370.266 ms  367.872 ms  369.547 ms
12  sl-gw20-sea-0-0-0.sprintlink.net (144.232.6.8)  375.711 ms  406.419 ms  378.141 ms
13  sl-microsoft-23-0.sprintlink.net (144.224.113.146)  384.781 ms  383.371 ms  387.322 ms
14  207.46.41.125 (207.46.41.125)  401.802 ms  402.980 ms  415.847 ms
15  ge-3-0-0-0.co1-64c-1b.ntwk.msn.net (207.46.34.41)  388.315 ms  549.512 ms *
16  ge-0-0-0-0.co1-64c-1a.ntwk.msn.net (207.46.34.189)  390.412 ms  416.519 ms  386.261 ms
17  * * *
18  * * *
19  * * *
20  * * *

VSNL, which has got peerings with MSN, whereas Airtel Broadband connects via Sprint.

Good fences make good neighbors (at least valid in case of Internet)

Want to script CUPS print queue management

Filed under: Hacking — Tags: , , , — abbe @ 0101

Following is the python script I hacked, with my limited python skills, to script addition/deletion of cups print queues, when I’d to install same set of printers on 15-20 GNU/Linux boxen:

#!/usr/bin/env python
# manage-printer.py: manage cups queues using command line
# author: Ashish Shukla <gmail.com!wahjava>
# license: gnu gpl license v2 or v3

# requires hplip
import cupsext
import sys

def list_printers():
	"List printers"
	printers = cupsext.getPrinters()
	for printer in printers:
		print "%s at %s" % (printer.name, printer.device_uri)

def add_printer(name, uri, location, ppd, info):
	"Adds a new printer"
	(status, status_str) = cupsext.addPrinter(name, uri, location, ppd, '', info)

def del_printer(name):
	"Delete a printer"
	return cupsext.delPrinter(name)

def printer_exists(printer_uri):
	"Checks if printer exists"
	printers = cupsext.getPrinters()
	for printer in printers:
		if printer.device_uri == printer_uri:
			return printer.name
	return None

def main():
	# list all printers
	if sys.argv[1] == "-l":
		list_printers()
	# add a new printer
	elif sys.argv[1] == "-a":
		printer_name = sys.argv[2]
		printer_uri = sys.argv[3]
		printer_ppd = sys.argv[4]
		printer_location = sys.argv[5]
		printer_info = ''
		add_printer(printer_name, printer_uri, printer_location, printer_ppd, printer_info)
	# check if a queue to a specific URI exists
	elif sys.argv[1] == "-g":
		printer_uri = sys.argv[2]
		printer_name = printer_exists(printer_uri)
		if printer_name == None:
			sys.exit(1)
		else:
			print printer_name
			sys.exit(0)
	# delete printer
	elif sys.argv[1] == '-d':
		printer_name = sys.argv[2]
		if del_printer(printer_name):
			sys.exit(0)
		else:
			sys.exit(1)

###
# usage: ${0} -l
#             -a [queue-name] [printer-device-uri] [path-to-ppd-file] [printer-location-field] [printer-info]
#             -g [printer-uri] |-d [queue-name])
#             -d [queue-name]
###

if __name__ == "__main__":
	main()

# vim:ts=4:sw=4

The script is poorly documented, maybe someone like to extend it. BtW, this script requires cupsext from hplip package. Happy hacking….:)

P.S. Lazy hackers, and bots can download the script from http://wahjava.googlepages.com/manage-printer.py.

Blog at WordPress.com.