Script Speed vs. Impacting OpenNMS October 5, 2010
I’ve been asked a similar question by two different people so I figured a public response was in order. After looking at the scripts on this site they noticed that some of them could be changed to run much faster. Most of the speed increase would come from performing a single large SQL statement and parsing the result as opposed to many smaller SQL statements. So the question is: Why are the scripts built the way they are?
In fact, the scripts where first written as these folks have suggested. The problem was that on a busy OpenNMS deployment the single large SQL query could cause hiccups. While the impact was not major it was noticeable.
One solution would have been to optimize the hardware and database but there is no guarantee the hiccups would not come back when OpenNMS is upgraded or more nodes are added. Since the slow CGI scripts contain information only used intermittently, it made sense to simply break their workload down into smaller SQL statements. This causes them to run slower but does not put a single large hit on the system. The results are slow but safe.
Specifically knownames.cgi and commentsforced.cgi can take minutes to run if there are 1000+ nodes in your OpenNMS database. Shortly, I will also post a nodedetails.cgi script which will have similar performance. I agree that these 3 scripts feel slow even when run on a high performance system. Although these 3 scripts currently report on all nodes at once, I rarely use them this way. Future posts will show how to separate an OpenNMS installation into views where nodes can be reported on in smaller groups. With smaller groups the speed difference is not noticeable.
Leave a Reply