Hardware::UPS::Perl::Driver::Megatec - package of methods for dealing with an UPS using the Megatec protocol
use Hardware::UPS::Perl::Connection; use Hardware::UPS::Perl::Driver::Megatec; use Hardware::UPS::Perl::Logging; $logger = Hardware::UPS::Perl::Logging->new(); $connection = Hardware::UPS::Perl::Connection->new({ Connection => 'serial', Options => { SerialPort => '/dev/ttyS0', }, Logger => $logger, }); $ups = Hardware::UPS::Perl::Driver::Megatec->new({ Connection => $connection, Logger => $logger, }); $ups->readUPSInfo(); $ups->printUPSInfo(); $ups->readStatus(); $ups->printStatus(); undef $ups; # disconnects
Hardware::UPS::Perl::Driver::Megatec provides methods dealing with an UPS using the Megatec protocol. It should be included in your code via the Hardware::UPS::Perl::Driver module by specifying Megatec as driver name.
new - creates a new UPS object
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups = Hardware::UPS::Perl::Driver::Megatec->new({ Connection => $connection, });
new initializes an UPS object $ups using a Hardware::UPS::Perl::Conection object to connect to an UPS directly or via an UPS agent.
new expects the options as an anonymous hash.
Connection => $connection
optional; a Hardware::UPS::Perl::Connection object; defines the connection to the UPS.
Logger => $logger
optional; a Hardware::UPS::Perl::Logging object; defines a logger; if not specified, a logger sending its output to STDERR is created.
"connect", "connected", "disconnect", "getLogger", "setConnection", "setLogger"
setDebugLevel - sets the debug level
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->setDebugLevel(1);
setDebugLevel sets the debug level, the higher, the better. It returns the previous one if available, 0 otherwise.
$debugLevel
integer number; defines the debug level.
"getDebugLevel"
getDebugLevel - gets the current debug level
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $debugLevel = $ups->getDebugLevel();
getDebugLevel returns the current debug level.
"setDebugLevel"
setLogger - sets the logger to use
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $logger = Hardware::UPS::Perl::Logging->new(); $ups->setLogger($logger);
setLogger sets the logger object used for logging. setLogger returns the previous logger used. The logger will be promoted to the current connection.
$logger
required; a Hardware::UPS::Perl::Logging object; defines the logger used for logging.
"new", "getLogger"
getLogger - gets the current logger object
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $logger = $ups->getLogger();
getLogger returns the current logger object used for logging, if defined, undef otherwise.
"new", "setLogger"
getErrorMessage - gets the internal error message
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); if (!$ups->connect()) { print STDERR $ups->getErrorMessage($errorMessage), "\n"; exit 0; }
getErrorMessage returns the internal error message, if something went wrong.
connect - connects to an UPS
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); # serial connection $ups = Hardware::UPS::Perl::Driver::Megatec->new({ Connection => "serial" }); $ups->connect($port); # serial connection $ups = Hardware::UPS::Perl::Driver::Megatec->new({ Connection => "tcp" }); $ups->connect(); # TCP connection $ups->connect({ # TCP connection Host => $host, TCPPort => $tcpport, });
connect connects either to an local UPS residing on the port $port using the method connect of package Hardware::UPS::Perl::Connect::Serial or to an UPS agent running at a remote host using the method connect of package Hardware::UPS::Perl::Connect::Net.
$port
optional; serial device; defines a valid serial port.
SerialPort => $port
Host => $host[:$tcpport]
optional; host; defines a resolvable host and, optionally, a valid TCP port separated by ":" to connect to.
TCPPort => $tcpport
optional; TCP port; a valid TCP port.
"new", "connected", "disconnect", "getLogger", "setLogger"
connected - tests the connection status
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); if ($ups->connected()) { ... }
connected tests the connection status, returning 0, when not connected, and 1 when connected.
"new", "connect", "disconnect", "getLogger", "setLogger"
disconnect - disconnects from an UPS
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->disconnect(); $ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); undef $ups;
disconnect disconnects from an UPS or an UPS agent.
undef $ups has the same effect as $ups->disconnect().
undef $ups
$ups->disconnect()
"new", "connect", "connected", "getLogger", "setLogger"
sendCommand - sending a command to the UPS
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->sendCommand($command, \$response, $responseSize);
sendCommand sends a command to an UPS connected and reads the response from the UPS using either the package Hardware::UPS::Perl::Connect::Net or Hardware::UPS::Perl::Connect::Serial. If the command is known by the UPS, sendCommand returns 1, otherwise 0 setting the internal error message.
$command
string; defines a command.
$response
string; the response from the UPS.
$responseSize
integer; the buffer size of the response from the UPS.
"new", "connect", "connected", "readUPSInfo", "readRatingInfo", "readStatus"
flush - flushing any buffered input
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->flush();
flush implements the Megatec protocl feature flushing any buffered input on startup. It sends the M command to an UPS connected.
"connect", "connected", "sendCommand", "readRatingInfo", "readStatus", "readUPSInfo"
readUPSInfo - reading the UPS information
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->readUPSInfo();
readUPSInfo sends the I command to an UPS connected and processes the response from the UPS yielding the UPS manufacturer, model, and version.
"sendCommand", "getManufacturer", "getModel", "getVersion", "printUPSInfo", "readRatingInfo", "readStatus", "readUPSInfo"
getManufacturer - gets the UPS manufacturer
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readUPSInfo(); $manufacturer = $ups->getManufacturer();
getManufacturer returns the UPS manufacturer (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".
"getModel", "getVersion", "printUPSInfo", "readUPSInfo"
getModel - gets the UPS model
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readUPSInfo(); $model = $ups->getModel();
getModel returns the UPS model (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".
"getManufacturer", "getVersion", "printUPSInfo", "readUPSInfo"
getVersion - gets the UPS firmware version
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readUPSInfo(); $version = $ups->getVersion();
getVersion returns the UPS firmware version (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".
"getManufacturer", "getModel", "printUPSInfo", "readUPSInfo"
printUPSInfo - printing the UPS information
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readUPSInfo(); $ups->printUPSInfo();
printUPSInfo prints the UPS information, i.e. manufacturer, model, and (firmware) version to the logger as determined by a previous call of method "readUPSInfo". If these informations are unavailable, the string unknown will be used instead.
"getManufacturer", "getModel", "getVersion", "readUPSInfo"
readRatingInfo - reading the UPS rating information
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->readRatingInfo();
readRatingInfo sends the F command to an UPS connected and processes the response from the UPS yielding the rating information, i.e. the (nominal or firmware) voltage, current, battery voltage and frequency.
"getRatingBatteryVoltage", "getRatingCurrent", "getRatingFrequency", "getRatingVoltage", "printData", "readStatus", "readUPSInfo", "sendCommand"
getRatingVoltage - gets the rating voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readRatingInfo(); $ratingVoltage = $ups->getRatingVoltage();
getRatingVoltage returns the rating voltage, i.e. the nominal output voltage of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.
"getRatingBatteryVoltage", "getRatingCurrent", "getRatingFrequency", "readRatingInfo", "printData"
getRatingCurrent - gets the rating current
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readRatingInfo(); $ratingCurrent = $ups->getRatingCurrent();
getRatingCurrent returns the rating current of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.
"getRatingBatteryVoltage", "getRatingFrequency", "getRatingVoltage", "printData", "readRatingInfo"
getRatingBatteryVoltage - gets the rating battery voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readUPSInfo(); $ratingBatteryVoltage = $ups->getRatingBatteryVoltage();
getRatingBatteryVoltage returns the rating battery voltage, i.e. the nominal battery voltage of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.
"getRatingCurrent", "getRatingFrequency", "getRatingVoltage", "printData", "readRatingInfo"
getRatingFrequency - gets the rating current
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readRatingInfo(); $ratingFrequency = $ups->getRatingFrequency();
getRatingFrequency returns the rating frequency of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.
"getRatingBatteryVoltage", "getRatingCurrent", "getRatingVoltage", "printData", "readRatingInfo"
readStatus - reading the UPS status information
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->connect($port); $ups->readStatus();
readStatus sends the Q1 command to an UPS connected and processes the response from the UPS yielding the current status information, i.e. the actual input voltage, input fault voltage, output voltage, UPS load in % of the maximum VA, input frequency, battery voltage, UPS temperature, the power, battery, bypass, failure, standby, test, shutdown and beeper stati. Additionally, it determines the minima and maxima of the input voltage and frequency.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readRatingInfo", "readUPSInfo", "resetMinMax", "sendCommand"
getInputVoltage - gets the current input voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $inputVoltage = $ups->getInputVoltage();
getInputVoltage returns the current input voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getInputFaultVoltage - gets the current input fault voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $inputFaultVoltage = $ups->getInputFaultVoltage();
getInputFaultVoltage returns the current input fault voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.
For offline UPS models, the purpose of the input fault voltage is to identify a short duration voltage glitch which has caused an offline UPS to transfer to inverter mode. If this occurs, the measured input voltage will appear normal at the query prior to the glitch and will still appear normal during the next query. The input fault voltage will hold the glitch voltage until the next query. After the query, the input fault voltage will be the same as the input voltage, until the next glitch occurs.
For online UPS models, the purpose of the input fault voltage is to identify a short duration utility failure which has caused the online UPS to transfer to battery mode. If this occurs, the measured input voltage will appear normal at the query prior to the utility failure and will still appear normal during the next query. The input fault voltage will hold the utility failure voltage until the next query. After the query, the input fault voltage will be the same as the input voltage, until the next utility fail occurs.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getOutputVoltage - gets the current output voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $outputVoltage = $ups->getOutputVoltage();
getOutputVoltage returns the current output voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getUPSLoad - gets the current UPS load
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $upsLoad = $ups->getUPSLoad();
getUPSLoad returns the actual UPS load in % of the maximum VA as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getInputFrequency - gets the current input frequency
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $inputFrequency = $ups->getInputFrequency();
getInputFrequency returns the current input frequency in Hz as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getBatteryVoltage - gets the current battery voltage
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $batteryVoltage = $ups->getBatteryVoltage();
getBatteryVoltage returns the current battery voltage in Volt as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getUPSTemperature - gets the current UPS temperature
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $upsTemperature = $ups->getUPSTemperature();
getUPSTemperature returns the current UPS temperature in °C as determined by a previous call of method "readStatus". If unavailable, undef is returned.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "printData", "printStatus", "readStatus", "resetMinMax"
getPowerStatus - gets the current power status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $powerStatus = $ups->getPowerStatus();
getPowerStatus returns the current power status of the UPS, i.e. bit 7 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates power failure, a value of 0 that everything is OK.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getBatteryStatus - gets the current battery status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $batteryStatus = $ups->getBatteryStatus();
getBatteryStatus returns the current battery status of the UPS, i.e. bit 6 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates a low battery, a value of 0 that everything is OK.
"getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getBypassStatus - gets the current bypass status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $BypassStatus = $ups->getBypassStatus();
getBypassStatus returns the current bypass status of the UPS, i.e. bit 5 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that a bypass/boost or a buck are active, a value of 0 that they are not.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getFailedStatus - gets the current failure status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $failedStatus = $ups->getFailedStatus();
getFailedStatus returns the current failure status of the UPS, i.e. bit 4 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates failure of the UPS, a value of 0 that everything is OK.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getStandbyStatus - gets the current standby status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $standbyStatus = $ups->getStandbyStatus();
getStandbyStatus returns the current standby status of the UPS, i.e. bit 3 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that the UPS is in standby, a value of 0 that the UPS is online.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getTestStatus - gets the current test status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $testStatus = $ups->getTestStatus();
getTestStatus returns the current test status of the UPS, i.e. bit 2 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that there is a test in progress, a value of 0 that no test is currently performed.
getShutdownStatus - gets the current shutdown status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $shutdownStatus = $ups->getShutdownStatus();
getShutdownStatus returns the current shutdown status of the UPS, i.e. bit 1 of the status value supplied by the "Q1" command, as determined by a previous call of method "readStatus". A value of 1 indicates that there is a shutdown active, a value of 0 that there is no shutdown performed.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
getBeeperStatus - gets the current beeper status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $beeperStatus = $ups->getBeeperStatus();
getBeeperStatus returns the current shutdown status of the UPS, i.e. bit 0 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that the beeper is on, a value of 0 that it is not.
"getBatteryStatus", "getBatteryVoltage", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
resetMinMax - resets the minima and maxima of the input voltage and frequency
$ups = Hardware::UPS::Perl::Driver::Megatec->new(); $ups->resetMinMax();
resetMinMax resets the minima and maxima of the input voltage and frequency.
"printMinMax", "getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus",
printMinMax - prints the minima and maxima of the input voltage and frequency
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printMinMax(); # the same as $ups->printMinMax("syslog"); $ups->printMinMax("debug"); $ups->printMinMax("info"); $ups->printMinMax("error"); $ups->printMinMax("fatal"); $ups->printMinMax("syslog");
printMinMax prints a string containing the minima and maxima of the input voltage and frequency as determined by a previous call of method "readStatus" to the logger or to syslog.
$level
string; defines the logging level ("debug", "info", "error", "fatal" or "syslog"; if omitted, the minima and maxima are written to syslog.
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"
printData - printing the comparison between the rating info and the current UPS status
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readRatingsInfo(); $ups->readStatus(); $ups->printData();
printData prints the comparison between the rating info (firmware data) and the current UPS status to the log file, if available, to STDERR, otherwise, as determined by previous calls of the methods "readRatingInfo" and "readStatus".
"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "readUPSInfo", "resetMinMax"
printStatus - printing status flags in a human readable format
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus($fh); $ups->printStatus();
printStatus prints the status flags as determined by a previous call of method "readStatus" to the log file, if available, to STDERR, otherwise, in a human readable format.
toggleBeeper - toggles the beeper
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $ups->toggleBeeper(); $ups->readStatus(); print STDOUT $ups->getBeeperStatus(), "\n";
toggleBeeper sends the Q command to the UPS connected, i.e. toggles the beeper's state from OFF to ON and vice versa.
"getBeeperStatus", "printStatus", "readStatus"
testUPS - tests the UPS
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $ups->testUPS(); $ups->readStatus(); print STDOUT $ups->getTestStatus(), "\n";
testUPS sends the T command to the UPS connected, i.e. causes the UPS to perform a 10 second test.
If battery low occurs during testing, UPS will return to utility immediately.
"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPSBatteryLow", "testUPSPeriod"
testUPSBatteryLow - tests the UPS
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $ups->testUPSBatteryLow(); $ups->readStatus(); print STDOUT $ups->getTestStatus(), "\n";
testUPS sends the TL command to the UPS connected, i.e. causes the UPS to perform a test until battery low occurs.
"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSPeriod"
testUPSPeriod - tests the UPS for a period of time
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $n = 9; $ups->testUPSPeriod($n); $ups->readStatus(); print STDOUT $ups->getTestStatus(), "\n";
testUPSPeriod sends the T$n command to the UPS connected, i.e. causes the UPS to perform a test for the period of time $n in minutes.
If battery low occurs during testing, the UPS returns to utility immediately.
$n
required; natural number less than 100; the testing period in minutes.
"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSBatteryLow"
cancelTest - cancels UPS tests
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $ups->testUPSPeriod(50); $ups->cancelTest(); $ups->readStatus(); print STDOUT $ups->getTestStatus(), "\n";
cancelTest sends the CT command to the UPS connected, i.e. causes the UPS to cancel any test activity and to connect the output to utility immediately.
"getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSBatteryLow", "testUPSPeriod"
shutdownUPS - shuts the UPS down in a period of time
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $time = 9; $ups->shutdownUPS($n); $ups->readStatus(); print STDOUT $ups->getShutdownStatus(), "\n";
shutdownUPS sends the S$time command to the UPS connected, i.e. causes the UPS to perform a shutdown in a certain period of time $time in minutes.
$time
required; floating number greater than 0 and less than 10; the period in minutes, when the UPS will shutdown.
"cancelShutdown", "getShutdownStatus", "printStatus", "readStatus", "shutdownRestore"
shutdownRestore - shuts the UPS down in a period of time and restarts it again
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $shutdown = 9; $restore = 19; $ups->shutdownRestore($shutdown, $restore); $ups->readStatus(); print STDOUT $ups->getShutdownStatus(), "\n";
shutdownRestore sends the S${shutdown}R${retore} command to the UPS connected, i.e. causes the UPS to perform a shutdown in a certain period of time $shutdown in minutes and restores it after $restore minutes.
$shutdown
$restore
required; floating number greater than 0 and less than 1000; the period in minutes, when the UPS will be restored again.
"cancelShutdown", "getShutdownStatus", "printStatus", "readStatus", "shutdownUPS"
cancelShutdown - cancels UPS shutdown processes
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port); $ups->readStatus(); $ups->printStatus(); $ups->shutdownUPS(50); $ups->cancelShutdown(); $ups->readStatus(); print STDOUT $ups->getShutdownStatus(), "\n";
cancelShutdown sends the C command to the UPS connected, i.e. causes the UPS to cancel any shutdown activity.
If the UPS is in shutdown waiting state, the shutdown command is cancelled.
If UPS is in restore waiting state, the UPS output is turned on, but the UPS must be hold off at least 10 seconds (if utility is present).
"getShutdownStatus", "printStatus", "readStatus", "shutdownUPS", "shutdownRestore"
Hardware::UPS::Perl::Connection(3pm), Hardware::UPS::Perl::Connection::Net(3pm), Hardware::UPS::Perl::Connection::Serial(3pm), Hardware::UPS::Perl::Constants(3pm), Hardware::UPS::Perl::Driver(3pm), Hardware::UPS::Perl::General(3pm), Hardware::UPS::Perl::Logging(3pm), Hardware::UPS::Perl::PID(3pm), Hardware::UPS::Perl::Utils(3pm)
Hardware::UPS::Perl::Driver::Megatec was inspired by the usv.pl program by Bernd Holzhauer, <www.cc-c.de>. The latest version of this program can be obtained from
http://www.cc-c.de/german/linux/linux_usv.php
Another great resource was the Network UPS Tools site, which can be found at
http://www.networkupstools.org
Hardware::UPS::Perl::Driver::Megatec was developed using perl 5.8.8 on a SuSE 10.1 Linux distribution.
There are plenty of them for sure. Maybe the embedded pod documentation has to be revised a little bit.
Suggestions to improve Hardware::UPS::Perl::Driver::Megatec are welcome, though due to the lack of time it might take a while to incorporate them.
Copyright (c) 2007 by Christian Reile, <Christian.Reile@t-online.de>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. For further licensing details, please see the file COPYING in the distribution.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '°C'. Assuming CP1252
To install Hardware::UPS::Perl::PID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hardware::UPS::Perl::PID
CPAN shell
perl -MCPAN -e shell install Hardware::UPS::Perl::PID
For more information on module installation, please visit the detailed CPAN module installation guide.