CPM - Complete module to work with MyPrinterCloud System
use CPM; my $env=CPM->new(); $env->auto(-verbose=>1);
The CPM module manages the API of MyPrinterCloud, providing the subroutines to collect the information from the networked printers and to transmit it to CPS (Cloud Printing Server). It offers several options to accomplish key design criteria such as non-invasive, open, flexible, standard and scalable.
The CPM functionality is completely defined by its configuration file (config.xml) that acts also, as firmware of the module.
The CPM needs a default configuration file that must be adjusted by the user, at least, including his credentials (valid user in MyPrinterCloud).
<?xml version="1.0" encoding="UTF-8"?> <opt call="http://myprintercloud.nubeprint.com/np/selector.pl" proxy="" > <id comm="call" date="2010-09-10" mode="discover" pass="xxx" type="soft-public" user="demo@nubeprint.com" /> <range from="105" to="115" lan=""/> </opt>
Communication with the CPS accepts two different forms depending on the needs of the destination network. Also, note that although there are two mechanisms you can activate only one per CPM.
This method is based on the HTTP standard, which operates in real time and is bidirectional. That allows the CPM apply the latest set of OIDs to be queried for a particular machine. Although an HTTP connection is needed, it is a very efficient solution.
<call="http://myprintercloud.nubeprint.com/np/selector.pl"/>
This method is based on the SMTP standard with Auth support. When it's activated, the CPM collects all the information from the networked printers, composes a summary email, and sends it to the CPS. Obviously it is not bidirectional, nor in real-time, but in some cases this solution provides the Administrator an easier way to check or audit the information being transmitted.
<mail pass="yyy" smtp="myprintercloud.com" user="aaa@myprintercloud.com"/>
If this method is enabled, the CPM discovers all the networked printers and for each one, it will request information to the CPS (if it's already registered, its model, the set of OIDs, ...). The CPM auto-detects the local net in order to make a scanning of the LAN.
The default discover behaviour can be modified specifying the local range and the subnet in where the CPM should scan. By default the CPM assumes the local net and from 1 to 254.
<range from="105" to="110" lan="192.168.2.0"/>
In this case the CPM gets a list of printers (section devices, embedded into the config file) to read, and for each one, it has already all the information needed to make a successful request.
<devices> <device ip="192.168.2.108" number="0"> <oid name="C1">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0</oid> <oid name="C18">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.2.0</oid> <oid name="C2">.1.3.6.1.2.1.43.10.2.1.4.1.1</oid> <oid name="C4">.1.3.6.1.2.1.43.11.1.1.8.1.1</oid> <oid name="C5">.1.3.6.1.2.1.43.11.1.1.9.1.1</oid> <oid name="C59">.1.3.6.1.2.1.43.11.1.1.8.1.2</oid> <oid name="C60">.1.3.6.1.2.1.43.11.1.1.9.1.2</oid> </device> <device ip="192.168.2.109" number="1"> <oid name="C1">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0</oid> <oid name="C18">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.2.0</oid> <oid name="C2">.1.3.6.1.2.1.43.10.2.1.4.1.1</oid> <oid name="C4">.1.3.6.1.2.1.43.11.1.1.8.1.1</oid> <oid name="C5">.1.3.6.1.2.1.43.11.1.1.9.1.1</oid> <oid name="C59">.1.3.6.1.2.1.43.11.1.1.8.1.2</oid> <oid name="C60">.1.3.6.1.2.1.43.11.1.1.9.1.2</oid> </device> </devices>
use CPM; my $env=CPM->new();
The CPM exports several subroutines to allow the developer to choose the way to handle the different transactions.
Create the object to handle the readings and the data transaction
Complete the transaction using the directives from the configuration file
Read printers of a List provided by the configuration file and use the Call method to send the data
Read printers of a List provided by the configuration file and send the data by email
Discover the networked printers and use the Call method to send the data
Discover the networked printers and send the data by email
Save the configuration data into the xml file
Make an SNMP request to read any OID. If MAC, it converts the hex values into an string like AA:BB:CC:DD If SN, it checks that it's a valid string. Enough lenght, and not resetted. Always converts the hex to ASCII strings
Make an SNMP walk request to read a complete branch
Determinate if exists an actived printer using the IP. If yes, it returns its SN
Read the Generics. It uses the common OIDs to try to identify the printer model and collect the basic information.
Read the specific model of printer. This function receives information from the CPS (OIDs of the model) and performs a specific SNMP request.
Juan Jose 'Peco' San Martin, <peco at cpan.org>
<peco at cpan.org>
Copyright 2010 NubePrint
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CPM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CPM
CPAN shell
perl -MCPAN -e shell install CPM
For more information on module installation, please visit the detailed CPAN module installation guide.