Author image Chris Josephes


Router::LG - Looking Glass


use Router::LG; $glass=Router::LG::new();


The LG class is based on the program originally written by Ed Kern of Digex. The original program was used as a web-based front end to obtain information from routers via RSH.

All of the original features of have been incorporated into

        - Multiple router vendor support
        - Multiple parameter support
        - Custom command definition


The LG module has a set of driver modules for accessing routers made by different vendors, like Cisco or Juniper. Each driver contains code and data structures regarding what commands it can send and how it can communicate with the router. The driver module is dynamically loaded when a router is defined.





Returns version data on the Router::LG class.


Sets or returns the router data structure. The router data structure defines the host address of the router, the vendor class, the remote access method, and any arguements are required to connect.

The following code defines a router data structure and tells the Looking Glass object to use it.

            -hostname => "core.pop.isp.node", 
            -class => "Cisco", 
            -method => "rsh", 
            -args => { 
                    -luser => "local_user", 
                    -ruser => "remote_user", 

See the POD documentation for a particular Router::LG class, (ex, Router::LG::Cisco, or Router::LG::Driver)


Sets or returns an array of parameters that will be inserted into the command sent to the router. Setting the first arguement of the list to "-clear" erases the contents of the array.

cache( -directory => $CACHE, -ttl => $TTL);

Sets of returns a hash defining the optional cache setup. Defining a cache takes two parameters, a directory, and a default time to live (in seconds).

If no TTL is defined, a default value of 10 minutes will be used.


Returns a list of commands the driver supports


Sets or returns data regarding a command structure. See the POD documentation for the particular vendor class for more information.


Executes the command on the router. If the command is successful, the method returns a cache state variable, followed by the lines of output the router sent back. The cache state variable can be a 1 indicating that LG returned cached data instead of accessing the router, or a 0 indicating that the router was accessed to obtain the data.

If the command failed, undef will be returned.




Works like execute, however it returns the command it would send to the router, but doesn't actually send it.


Sets or returns one or more error messages. If the first arguement in the list is "-clear", it will erase the list of errors.


The following methods are part of the LG class, but implementors are not expected to use them.


Loads the driver defined in the router data structure


Returns the object pointer to the router driver


Returns a parsed filename for the cachefile, which is the name of the command followed by two dashes and the hostname of the remote router


Returns a boolean flag indicating whether or not we could use cached data instead of accessing the remote router


Reads a cached output file


Writes output to a cache file