Query the Tx SNR of an iDirect modem via SNMP

This is something for the Cacti, Nagios, WhatsUp and what-not users in the satellite business out there…

At work, we use Cacti to graph the SNMP values of A LOT of exotic devices, among them is the very popular family of iDirect modems. Now, we like to graph the Tx (Transmit) SNR (Signal to Noise Ratio) of certain iDirect modems. To do so, you usually open a telnet connection to an iDirect modem, login with the proper user credentials and execute the command

tx snr

Now, as you might know, monitoring and graphing servers like WhatsUp or Cacti cannot perform Telnet connections out of the box. They query SNMP devices through their IP addresses and request the values through their respective OIDs.

How did we solve this?

With a dedicated Linux server that runs an extended SNMP daemon.

Basically, that is a regular SNMP daemon that has some additional configuration lines in its /etc/snmp/snmpd.conf file, like this one:

extend UniqueiDirectModemName '/usr/local/bin/iDirectSNR.py -i -u username -p password'

On this server, you can determine the assigned OID with the snmpwalk command using the -On switch:

snmpwalk localhost -c snmpcommunity -v1 . -On


The following Python skript performs the telnet part to query the Tx SNR value; when it encounters an error, it returns the value “100.00000”, which is also returned when the modem is not locked for whatever reason.
Note: Usually the modem returns -100.000000 when it is not locked, but to make the graphs look a little nicer, we did not want to use negative values.

This is the file


Make sure you perform

sudo chmod a+wxr /usr/local/bin/iDirectSNR.py

to make it executable!

import sys
import telnetlib
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-i", "--ipaddress", dest="ipaddress",
                  help="IP address of iDirect modem", metavar="")
parser.add_option("-u", "--username", dest="username",
                  help="IP address of iDirect modem", metavar="")
parser.add_option("-p", "--password", dest="password",
                  help="IP address of iDirect modem", metavar="")

(options, args) = parser.parse_args()

if options.username is None or options.password is None or options.ipaddress is None:
  print "100.000000"

  tn = telnetlib.Telnet(options.ipaddress,23,2)
except Exception, e:
  print "100.000000"

tn.read_until("Username: ",1)
tn.write(options.username + "\n")
tn.read_until("Password: ",1)
tn.write(options.password + "\n")

tn.read_until("> ",1)

tn.write("rx snr\n")

tn.read_until("Rx SNR: ",1)

result = tn.read_until("\n",1).rstrip("\n")
result = result.lstrip("-")

if result == "":
  result = "100.000000"

print result


If you don’t know how to setup a basic SNMP daemon:

sudo apt-get install snmp

Then you need to modify the file /etc/default/snmpd. Remove the reference to localhost in the SNMPDOPTS line, otherwise the server will ONLY listen to SNMP requests its localhost IP address Make sure that the line looks somehow like this:

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

Now, create a simple /etc/snmp/snmpd.conf file:

rocommunity snmpcommunity
syslocation "MyCompany, MyLocation"
syscontact myname@my.domain
extend UniqueiDirectModemName '/usr/local/bin/iDirectSNR.py -i -u username -p password'

Now restart the SNMP daemon:

sudo /etc/init.d/snmpd restart

And that’s it! Your Linux server will now respond to SNMP queries, and it will even return the Tx SNR value of the modems that you have added to its snmpd.conf file as if they belonged to the server itself. You can add as many devices as you want to your SNMP daemon, and with modified versions of the Python skript, of course, you can also return other values as well.

Dynamic Languages for Desktop Apps

I posted this on Ted Leung’s blog today as my comment on the discussion on his ‘Dynamic Languages for Desktop Apps’ article. For those who don’t want to read the entire story, Ted is basically calling for more desktop applications that should be written (almost entirely) in dynamic languages like Python. He says that dynamic languages have been embedded as scripting languages into desktop apps for years, but since the performance of dynamic language runtimes has significantly increased over the years, “it should be possible to write really good desktop applications using them”.

His article can be found here:


One other commenter mentioned Basic and compared it to scripting languages, but I think he was rather mistaken there.

Here’s my post:

Well, Basic is neither a dynamic nor a typical scripting language. Rather the opposite: All modern Basic dialects are compiled, and when you look at Basic-compilers like BlitzMax or PowerBasic, those use strongly typed and static languages that produce compiled code which is at least as fast as the one emitted by any available C compiler. So, no, Basic is not a valid comparison here, not even if it’s VB.NET.

Civilization IV uses Python for its game logic, but I’m still waiting for a success story for PyGame – even that project’s homepage does not name a ‘real’ product that uses it, where ‘real’ stands for a game that has sold at least a couple of hundreds of thousands of copies. The pyglet project also seems to be under more development recently than PyGame, and it looks quite promising – although there are also no high profile/high visibility apps yet being made with it, as it seems.

Unfortunately the same has to be said for wxPython – there are no visible successful applications with large customer bases written in wxPython. At least I haven’t heard of one except for maybe Boa Constructor, which is rather complicated to get running on my platform, OS X, and an IDE is not necessarily a mass market application anyway. I would be very happy to hear of a very successful commercial wxPython application.

In direct comparison and outside of large corporate environments (where plenty of Java desktop apps exist), Java has at least Tribal Trouble (a very nice commercial and successful 3D real time strategy game), CyberDuck (one of the best FTP clients for OS X), Limewire, Netbeans and Eclipse, which both are not only IDEs, but rich client platforms on which several large desktop applications can be and actually already are built (BlueMarie, e.g.).

Deployment issues could be one of the things that is holding Python back on the desktop. Not everybody feels good about distributing source code or easy-to-reverse-engineer-byte code in an application bundle (OS X) or encapsulated in an .exe file. But maybe that’s more of a psychological problem than a technological one.

The reputation of being slow – whether or not this is justified does not even matter – is another issue. This one is still holding Java desktop apps back, although there are success stories like Eclipse out there.

Other problems that I see could be the fact that Python does not necessarily come with a modern GUI framework out of the box, and it does not come with pyglet or Pygame either in the standard distribution.

Then, as a Mac user in the year 2008, you don’t want to be caught writing Carbon-based applications anymore – but that’s all that wxPython will give you. And if you begin using the pyobjc-bridge: Why would you want to do that in the first place? When you’re giving up multi-platform capabilities, you could as well go with the native Objective-C language which has higher performance to offer than Python but at the same time is still dynamic and even garbage collected.

On Windows, you’d face a similar situation with C# and the .NET framework, and you’d have to ask yourself the same question whether it makes any actual sense to use Python instead of the platform’s native language.

Linux might be a different story, but Linux is far from becoming a widely accepted desktop platform in terms of user base and market share. It’s a huge server platform, but still basically irrelevant on the desktop.