Book Review: Building Network Management Tools with Tcl/Tk
Authors: Dave Zeltserman and Gerard Puoplo
Publisher: Prentice Hall
Price: $48 US
Reviewer: Syd Logan
The stated target audience for this book is the systems administrator or network consultant who needs to develop network management software. While feature-rich third-party network management tools (for example, HP's Openview) are widely available, there may be times when an administrator or network consultant will find that the tools at his/her disposal are not flexible enough to solve a particular problem. In addition, the costs of purchasing third-party tools can often be prohibitive; it may be impractical to spend thousands of dollars on a package, especially if one's network status monitoring needs tend to be modest.
Developing your own tools in Tcl/Tk will take some effort, but Linux comes with everything except possibly the extensions to Tcl that are needed to perform SNMP (simple network management protocol) communications. (A search on the Net indicated there is a Red Hat RPM for Scotty, one of the extensions.) The book describes two SNMP extensions to Tcl. The first, Tickleman, is a commercial product that is available for a fee. The second, Scotty, is a package that is freely available via the Internet.
For those of you who are unfamiliar with Tcl/Tk, SNMP, or RMON (remote monitor), a lot of new material is included for you to read. Those interested in learning about these technologies form a second target audience for this book, one to which I belong. I was already familiar with SNMP, having used it to develop a remote configuration tool for X terminals several years ago. I was new to Tcl/Tk, but not to scripting or GUI development. I read this book primarily to gain an understanding of Tcl/Tk. I wanted to learn about the tools, the commands and the syntax of Tcl/Tk by seeing how it could be used to solve a non-trivial programming task.
A third audience for this book is engineers interested in the design of network management software. The high-level concepts introduced should apply regardless of the programming language or GUI APIs the developer might choose to work with, although it will be up to the reader to make the transition from Tcl/Tk to whatever tool set is to be used.
The book consists of three major sections. Section 1 includes Chapters 1 and 2, which introduce the extensions (Scotty and Tickleman) which allow Tcl to be used with SNMP. Chapter 2 provides a nice survey of the sort of network management tools the authors intend to be written using the technologies covered. Much of the information in this chapter will be new to readers unfamiliar with SNMP or TCP/IP networking and is provided with little explanation. I don't have a problem with this; the stated audience of the book, after all, is the network consultant, and my expectation is that network consultants are familiar with the network-related concepts and technologies in this chapter and elsewhere in the book. However, if you are new to technologies like SNMP, you may want to search the Web for background information or perhaps take a look at one of the books listed by the authors. They state that learning the basics of SNMP is easy. I agree, but I think the book would have benefitted from an early chapter introducing TCP/IP, SNMP and RMON, including an overview of MIB-II variables similar to the one provided later in the book in Chapter 12.
The second section, chapters 3 through 9, introduces Tcl/Tk and further discusses the Scotty and Tickleman SNMP extensions to Tcl.
Chapter 3 is entitled “Tcl Basics”. Arrays, variables, expressions, procedures and functions, string manipulation, and flow of control aspects of Tcl are all covered in this chapter. Chapter 4, “More Tcl”, covers topics such as Tcl built-in variables, writing HTML source files, file I/O, event-driven programming and pattern matching. To illustrate pattern matching, a routine capable of validating an IP address or mask is presented and this routine is used in code later in the book. Because of this, I would suggest skimming Chapter 4, even if you are already experienced with Tcl, paying close attention to the code examples presented. If you are new to Tcl, you might want to fire up wish and experiment with some of the code in these chapters as you read along; this will help solidify the material as it is presented.
Chapter 5 is where all the fun begins. This chapter discusses both the Scotty and Tickleman SNMP extensions to Tcl. Reading this chapter teaches you to use SNMP to connect to an SNMP daemon on a host, and once connected, set and get MIB variables and perform other SNMP operations both synchronously and asynchronously. The chapter first deals with Tickleman and continues by showing how the same operations illustrated with Tickleman can be performed using Scotty. This chapter is important and should be studied carefully (even read twice, if necessary) before moving on.
Chapter 6 wraps up the discussion of Tcl and Scotty/Tickleman with the design and implementation of a polling loop capable of obtaining information from a number of network devices. The chapter is code intensive; I'd recommend reading slowly and carefully. It begins by describing the author's approach to maintaining data about the devices being polled (specifically, SNMP retry counts and timeout values, and community names organized by IP address and subnet). This data is stored in the form of a Tcl script at the beginning of the Tcl code that performs the polling task. When asked to poll a given device, this data is searched, first for an exact IP address match followed by a match based upon subnet mask if an exact IP match was not found. If neither of these searches results in a match, hardcoded default values are used instead. The code that performs the lookup and retrieves the data is presented in detail. The remainder of the chapter deals with implementation and use of the polling loop.
Now that the reader has a grip on Tcl and the use of Scotty and Tickleman, the authors begin a discussion of GUI development using Tk. Much as was done for Tcl, Chapter 7 starts from the beginning, assuming no prior experience on the part of the reader. Again, I suggest firing up wish and trying out the Tk examples as you read. After some basic Tk widgets are introduced, the authors develop an example Tk application similar to the full-blown StatusMgr introduced in Chapter 1, making use of the Tk widgets presented earlier in the chapter. The authors do not go into any great detail when they discuss the Tk widgets introduced in this chapter; for details, you will need to refer to a Tcl/Tk reference. Their goal is to give the reader just enough information to make sense out of the Tk sample code presented. However, be aware that some of the sample code presented makes use of Tk widgets not explained in the text.
Chapter 8, “More Tk”, continues the book's coverage of Tk. The chapter starts by designing a table widget using Tk components. Next, an interactive IP path trace graphic is designed, where the code illustrates how to register and respond to mouse enter, move and leave events within a canvas. The chapter concludes with a discussion of the Itcl Mega-Widgets. These are extension widgets to Tk and are provided with the Tickleman package, or can be downloaded from the Net for use with Scotty. The authors first discuss several Mega-Widgets in a manner similar to that used to introduce Tk widgets in Chapter 7. They then use these widgets to re-implement the StatusMgr interface that was developed earlier in Chapter 7.
Chapter 9 discusses socket programming using Tcl's socket command. The chapter first covers some of the commands associated with Tcl sockets, then a very simple client/server example is presented. Finally, the authors describe how to build a web-based interface, so users can view network management data using a browser such as Navigator.
The third and final section of the book uses the information presented in the first two sections to build four complete network management tools. Chapter 10 develops a response time monitoring tool. This tool gathers the following statistics: current (last measured) delay, average delay, peak delay and number of completed tests as an indication of the reachability of the device being tested. The tool is capable of monitoring several network devices at once, and results are displayed in the table widget developed earlier in the book.
In Chapter 11, the authors present and discuss code that implements a network discovery tool. The code is based upon Tickleman, not Scotty. The authors are careful to point out in the source code all places that are SNMP specific; I assume this was done to identify those portions of the code that would need to be ported by readers using Scotty. It might have been helpful for the authors to supply both Scotty and Tickleman versions of the code. Chapter 11 is code-intensive; perhaps 90% of the chapter consists of annotated listings.
Chapter 12 discusses another sample application, StatusMgr. In contrast to Chapter 11, this chapter does not provide code—just a description of the program's organization and flow of control, making it a more casual read. The StatusMgr application makes use of code discussed and developed in earlier chapters, and the authors tell you where to look when needed. To get the full effect of this chapter, you can download the source code from the Internet to glance at as you read.
StatusMgr appears to be a serious network management tool, one that administrators should find useful. The application data can be accessed from a console or X terminal via the Tk user interface or from a web browser over the web. The application displays information such as device network availability, reset counts, interface uptimes, interface utilization and interface discards. It is also capable of reporting which nodes are routing the most IP traffic and are generating and receiving the most IP traffic. The application also reports historical availability information for the previous 48-hour period.
Readers should find StatusMgr a good starting point for adding their own custom network management features. The design of the user interface seems to lend itself to expansion. (Functional groups in the Tk version are organized as tab dialogs.) Since you'll have the source code and this book, you should have enough information at your disposal to tweak the code and add your own custom features.
Chapter 13 presents the next full-blown application, an IP path tracing tool. This tool is similar to traceroute, but with significant differences. The application not only shows the route from source to destination, but it also indicates the device types along the way (e.g., serial, Ethernet, token ring) and operational characteristics of each link (e.g., speeds, device vendor, number of packets forwarded by second). The route is depicted graphically using code developed in Chapter 8 and the operational data is displayed using the simple table widget, also developed in Chapter 8. The tool polls for operational data every 60 seconds, so it can be used to monitor the health of the link which is depicted. The authors are careful to warn the reader that the tool may not do its job 100% of the time. This is due to the use of RFC 1213 IP routing tables as opposed to the newer IP forwarding table defined in RFC 1354. Their reason for this choice is a logical one; RFC 1354 was not widely deployed at the time of the book's writing.
The chapter is well-organized, with the first section describing the tool in general. Following sections describe the code which traces the IP path, builds the user interface and polls the nodes along the path for operational status.
Chapter 14 discusses RMONv2, which can be used for application-level protocol monitoring. These tools can be used to configure RMONv2 and build an inventory of your current RMONv2 probe configurations.
Chapter 15 is the final chapter in the book. It describes how to use the Tcl plug-in for both Netscape Navigator and Microsoft's Internet Explorer. Information is provided on downloading the plug-in from the Internet. The plug-in basically allows your browser to handle HTML documents with embedded Tcl/Tk scripts. The authors present a quick overview of security policies supported by the Tcl plug-in, then go on to describe the <EMBED> HTML tag which is used to embed Tcl code in an HTML document. Then, the authors suggest two practical uses of Tcl plug-ins for network management. The first is to provide a graphical front-end to server-based management applications, meaning a Tcl applet embedded in an HTML page could connect via sockets to a host to retrieve network management data, which the applet would then render. The second use is to display graphs of network management report data that is stored in a server-based file or database. Examples for both of these uses of embedded Tcl are provided, along with the code necessary to implement them.
Appendix A provides a Tcl script that creates a table mapping RMON octet strings to names such as ether2.ip.tcp.kerberos. This table defines the set of protocols that an application of the type developed in this chapter is interested in configuring. The authors started Chapter 14 by developing code that connects to a device and queries RMONv2 for the protocols supported by the device. These resulting protocols are then searched for in the application-defined table. The results of this search define the protocols which can be probed by the Tcl application. Next, scripts are developed for configuring the RMONv2 Protocol Distribution Control Table, Address Map Control Table, Host Control Table and Matrix Control Table. Finally, the chapter develops code which accesses each of these tables for data. For example, code is developed which can access packet and octet counts for a given protocol (e.g., ether2.ip.tcp.nntp) using the Protocol Distribution Control Table. Not having previous exposure to RMONv2, this chapter will provide an idea of its capabilities; a look at the relevant RFCs will give a more complete overview. I'm sure this was intentional, since RMON is not the principal subject of the book. The discussion of RMONv2 Matrix Groups provides code that configures the hiMatrixControlTable , but no code to retrieve information.
Instructions for obtaining the sample code and the SNMP Tcl extensions are provided in the book. The sample code is available from Net Mgmt Solutions, Inc. and requires a login and password wich are provided in the book's preface. In order to access the download page, you must give your name, phone number and e-mail address, which is a bit much as far as I am concerned. Personally, I feel the book should have been packaged with a CD or floppy containing the latest releases of Tcl/Tk, Scotty and the sample code. The Scotty code was downloaded from the web.
This book provides a comprehensive overview of the use of Tcl/Tk to develop both stand-alone and web-based network management tools. If you are a network consultant or system administrator, it should provide you with a good starting point for the development of custom tools not present in your current tool set. The authors provide information about Tcl/Tk and the Scotty and Tickleman SNMP extensions to Tcl. With this information, you should be able to start with the code from any of their sample applications and tweak it into the network management tool that best meets your needs.
For readers wanting an introduction to Tcl/Tk and SNMP, I think this book serves well to a certain degree. If you are new to SNMP or networking, you may want to look on the Internet for a more complete introduction. As far as Tcl/Tk goes, the book does a fairly good job of describing things, but eventually you will need to augment it with a Tcl reference or programming primer. The authors list (at the end of Chapter 15) additional books, newsgroups and web sites that provide information about SNMP, Tcl/Tk and network management in general.