CUPS Administrative Guide — Save 50%
A practical tutorial to installing, managing, and securing this powerful printing system
In this second part of this two part article series by Ankur Shah, we will learn how Simple Network Management Protocol (SNMP) helps CUPS discover the printer and help other networking tools such as Cacti in managing printers.
How SNMP Behaves in the CUPS Web Interface
In the CUPS web interface under the Administration tab, the option Find New Printers is used to discover printers that support SNMPv1.
This will search and list the available network printers. The discovery of printers is based on the directive configuration done in the /etc/cups/snmp.conf file. On the basis of the search list, you can add a printer using the Add This Printer option. The process is very similar to the Add Printer wizard.
Overview of Basic Debugging in CUPS-SNMP
In the snmp.conf, we started discussion about various debugging levels in CUPS support. If the directive DebugLevel is set to anything other than 0, you will get the output accordingly. The debugging mode can be made active using the following command.
As the SNMP backend supports debugging mode, the command for setting up debugging mode changes depending on the shell prompt. The SNMP backend is located at /usr/lib/cups/backend/snmp when using the Bourne, Bash, Z, or Korn shells. The following command will output verbose debugging information into the cupssnmp.log file when using those shells:
$CUPS_DEBUG_LEVEL=1 /usr/lib/cups/backend/snmp 2>&1 | tee cupssnmp.log
On Mac OS X, the SNMP backend is located /usr/libexec/cups. The following command will be used:
$CUPS_DEBUG_LEVEL=1 /usr/libexec/cups/backend/snmp 2>&1 | tee cupssnmp.log
If you are using the C or Tcsh shells, you can use the following command.
$(setenv CUPS_DEBUG_LEVEL 1; /usr/lib/cups/backend/snmp) |& tee
An example of the output might look like this:
DEBUG: Scanning for devices in "public" via "@LOCAL"...
DEBUG: 0.000 Sending 46 bytes to 192.168.0.255...
DEBUG: 0.001 Received 50 bytes from 192.168.0.250...
DEBUG: 1.001 Scan complete!
The above output shows that doesn't find any printer at the specified DeviceURI. The above shows the output at the basic debugging level; more information can be found if we use level 2 or 3.
Overview of mailto.conf
The CUPS provides the facility to send notifications through email. It can be done by integrating the local mail server with CUPS. The configuration file is /etc/cups/mailto.conf, and contains several directives and the characteristics and behavior of the local mail server and email notification for CUPS. We normally use each of the following directives in our daily communication done through mail.
The Cc Directive
The directive Cc (carbon copy) is used to specify an additional recipient for all email notifications. By default, the value directive is not set and the email is sent only to the administrator. The following examples shows that how email IDs can be specified with this directive.
Cc Kajol Shah <firstname.lastname@example.org>
The From Directive
This directive is used to specify the sender's name in the email notifications. By default, the ServerAdmin address specified in the cupsd.conf file is used. The following are some examples that show how the sender's email is specified with this directive:
From Your CUPS Printer <email@example.com>
The Sendmail Directive
The directive Sendmail specifies the command to run and deliver an email locally. If there is an SMTPServer directive, then this directive cannot be used. If both directives appear in the mailto.conf file, then only the last directive is used. The following example shows how this directive can be specified. The default value for this directive is /usr/sbin/sendmail.
Sendmail /usr/lib/sendmail -bm -i
The SMTPServer Directive
This directive is used to specify an IP address or hostname of an SMTP mail server. As we have seen previously, this directive cannot be used with the Sendmail directive, and if both Sendmail and SMTPServer directives don't appear in the mailto.conf file, then the default Sendmail will be considered. The following are examples of the SMTP server:
The Subject Directive
The Subject directive is used if you want to prefix some text to the subject line in each email that CUPS sends out. The following examples show how a prefix can be specified with this directive. By default, no prefix string is added:
Subject URGENT CUPS NOTICE
Monitoring SNMP Printers
As discussed, CUPS supports SNMPv1 for discovering SNMP enabled printers. This Simple Network Management Protocol-SNMP is used for managing networking printers. We can use any network monitoring tools that supports SNMP for monitoring these SNMP-enabled printers. You can check various open-source network monitoring tools at:
I would recommend you to use Cacti, which is a frontend to an RRDTool (Round Robin Database Tool) that collects and stores data in a MySQL database. The frontend is completely written in PHP. The advantage of Cacti over other network monitoring tool is that it has built-in SNMP capabilities and like other monitoring tools such as Nagios, it has its internal mechanism to check certain aspects of the infrastructure. It also provides a frontend for maintaining customized scripts, which an administrator normally creates. But the most important factor is that it is much easier to configure than Nagios. RRDTool is a system that stores high performance logging data and displays related time-series graphs. You can get more information about RRDTool from: http://oss.oetiker.ch/rrdtool/
Downloading and Installing Cacti
The pre-requisites of Cacti include MySQL database, PHP, RRDTool, net-snmp, and PHP supported web servers such as Apache or IIS. You can get detailed information about the pre-requisites for Cacti installation at:
The current stable release of Cacti is 0.8.7b. You can download various versions of Cacti for different platforms from:
You can get installation information for Cacti and its pre-requisites on the UNIX/Linux platform from:
The following URL will help you install Cacti on the Windows platform:
You can proceed further by clicking on Next. The next screen shows two options for a new install or an upgrade. If you want to do fresh installation, use the option New Install and click on Next. The screen also displays some useful information such as database user, database hostname, database name, and OS that was specified while configuring Cacti.
If you want to upgrade the Cacti, follow the instructions mentioned here:
And then select the upgrade from cacti-current-version option and click on Next to proceed further.
The following screen appears, which shows the recommended path of the binary files such as RRDTool, PHP, snmpwalk, snmpgetV, snmpbulkwalk, snmpgetnext, and information related to the Cacti log file and versions for net-snmp and RRDTool. If you found any change in the path with your installation, it should be modified first. Otherwise, Cacti may not work properly. Click on Finish to complete the installation procedure.
Once the installation is finished and the next screen will ask for authentication. You need to use the username and the password mentioned in your database configuration to log into a Cacti application:
You can use default login information to log in for the first time. Once you click on Login, the next screen will force you to change your password.
Once the password is changed, you can see the main page of Cacti that contains two major tabs: console and graphs apart from other generalized options. The console tab contains various options related to the template and graphs management, whereas the graphs tab contains related graphs.
eBook Price: $23.99
Book Price: $39.99
Features of Cacti
Cacti supports various features such as graphs, graph display, data source, data gathering, scripts, templates, and user management. You can find more information on this at:
You can get information about the various additional scripts:
Configuring an SNMP Printer with Cacti
In this section, we are going to integrate an SNMP Printer as a network device in Cacti. Before we start discussing, let's first understand how Cacti works. Like any other network monitoring functionality Cacti also depends on three factors:
- Data Retrieval
- Data Storage
- Data Presentation
You can get detailed information on this at:
The greatest strength of Cacti is its graphing. To make the graphs of a networking device available, the device should be configured in Cacti. You can configure it by clicking on Device and then on Add by selecting the proper options. The following screen will appear which shows general information on the device and the protocol you want to use for polling. The first two fields of Description and Hostname are important as they identify the device you are creating. If you are not sure about how to use other options in the Host Template field, it is recommended that you use Generic SNMP-enabled Host. You can keep the remaining fields as the default if you are sure of an option. The screen is divided in two parts for better display.
The second part contains options for SNMP such as versions, ports, and so on. Select the version of SNMP and the other options properly and then click on Create to make the device available for use.
You can get detailed information about the device options at:
The second part of the configuration is creating the graph for a device you have specified. You can use the option New Graph from the Create menu option, or you can choose the Create option from the edit screen. This will show on the following screen. You just need to select the options for the features for which you want to create a graph. Cacti provides the method to have graph value for a single OID (Object Identifier) using "SNMP - Generic OID Template" for SNMP-enabled services.This feature has been introduces with Cacti 0.8.5. You will get to see more on this at:
Cacti also provides some methods to get data from various networking devices. These methods can be categorized as "Collection Methods", "Template" and "PHP Script Server". A graph will be generated based on this data. You can get detailed information on the above methods at:
The Collection Methods are again divided into the following two methods:
- Data Input Methods
- Data Queries
We will be discussing the "Data Queries" as we have shown one of the methods in our following example. This "Data Query" method again provides two ways for querying: SNMP query and Script query. The only difference between these two query methods is the way they obtain data.
These data queries contain two parts: a definition for Cacti and an XML file.
The XML file gives the required information and the method for its retrieval, whereas the definition part informs Cacti where to find this XML file and related data queries with proper graph templates. You can get detailed information on this at:
Here, we will be discussing the SNMP query for which I have created an XML file. You can use the Data Queries navigation link in the Collection Methods menu. You will have to supply a Name, and a Description. The other two fields of data input are important, which show the XML path of your data query and the method.
To generate a graph using a template for this data query, click on Add as highlighted in the previous screenshot. You will get a new screen as follows:
Fill in the appropriate information in the Name and Graph Template fields.
You can import a new Graph/Host/Data template using the Import Template option from the Import/Export menu.
This should generate an appropriate graph for you.
The above graph shows the toner level for color and black and white printers, and the drum level for cupsprinter.
In this two part article series, we have discussed how to monitor printers and print jobs using CUPS. You've seen in the first part how to use the lpstat command, the access_log file and the error_log file to help you monitor printing on your network. In this part of the two part series, we have discussed how SNMP helps CUPS to search for printers. We have seen how the setup of email helps users, and then the administrator, in conveying some important messages. Finally, we also discussed how Cacti can be used to monitor our printer with the help of SNMP.
If you have read this article you may be interested to view :
eBook Price: $23.99
Book Price: $39.99
About the Author :
Ankur Shah has been working with Linux/AIX for last 4 years as a System Administrator. His previous assignment was with Packt Publishing, where he worked as System Administrator and also started implementing CUPS. He completed his graduation in Computer Engineering from Nagpur University, India. He is currently working as a SAP Basis Administrator and also started working on Governance Risk and Compliance for access Control. He is also interested in Oracle Database Administration and Security.
He is the biggest fan of Kajol (a Bollywood actress) and dedicates this book to her. The day her movie releases is a day of celebration for him and he only parties once a year - 5th August - that's Kajol's birthday. It goes without saying that he watches all her movies several times - often dragging his friends and family to participate in his madness.