Download the PHP package sunfoxcz/apc-pdu without Composer
On this page you can find all versions of the php package sunfoxcz/apc-pdu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sunfoxcz/apc-pdu
More information about sunfoxcz/apc-pdu
Files in sunfoxcz/apc-pdu
Package apc-pdu
Short Description PHP library for reading data from APC PDU AP8XXX series via SNMP (v1 and v3) with Network Port Sharing support
License MIT
Informations about the package apc-pdu
APC PDU Library
PHP library for reading data from APC PDU AP8XXX series via SNMP (v1 and v3) or SSH with Network Port Sharing support.
Requirements
- PHP 8.2+
- One of the following backends:
ext-snmp- PHP SNMP extension (for Native client)net-snmp- System package (for Binary client)freedsx/snmp- Composer package (for FreeDSx client)ext-ssh2- PHP SSH2 extension (for SSH client)
Installation
Usage
SNMPv1 Connection
SNMPv3 Connection
Client Implementations
The library provides multiple SNMP client implementations with automatic discovery:
| Method | Description | Dependencies |
|---|---|---|
snmpV1() / snmpV3() |
Auto-detects best available client | Any of the below |
snmpV1Binary() / snmpV3Binary() |
Uses the snmpget binary via shell |
net-snmp package |
snmpV1FreeDsx() / snmpV3FreeDsx() |
Uses the FreeDSx SNMP library | freedsx/snmp composer package |
snmpV1Native() / snmpV3Native() |
Uses PHP's native SNMP functions | ext-snmp |
ssh() |
Uses SSH/CLI interface | ext-ssh2 |
Automatic Client Discovery
The snmpV1() and snmpV3() methods automatically detect and use the best
available SNMP client in priority order:
- Binary - Most efficient batch operations (
net-snmppackage) - FreeDSx - Efficient batch operations, pure PHP (
freedsx/snmp) - Native - Fallback, slower batch operations (
ext-snmp)
If no client is available, a NoSnmpClientAvailableException is thrown.
Performance Comparison
Benchmark results (SNMPv3, AP8653 PDU):
| Operation | Native | Binary | FreeDSx | SSH |
|---|---|---|---|---|
| Single device metric | 128 ms | 69 ms | 73 ms | 905 ms |
| Device metrics (batch) | 1.26 s | 200 ms | 215 ms | N/A* |
| Single outlet metric | 62 ms | 65 ms | 233 ms | 904 ms |
| Outlet metrics (batch) | 1.09 s | 213 ms | 229 ms | N/A* |
| All 24 outlets | 25.82 s | 7.07 s | 7.45 s | N/A* |
| Full PDU status | 54.74 s | 16.64 s | 13.72 s | N/A* |
*SSH uses an interactive shell which adds latency. It supports only a limited set of metrics (Power, Energy, ApparentPower, PowerFactor, Current, Name) and cannot retrieve full device/outlet status.
Recommendations:
- Native: Good for simple single-metric queries, requires
ext-snmp - Binary: Best batch performance, requires
net-snmpsystem package - FreeDSx: Best for full status dumps, pure PHP with no extension dependencies
- SSH: Alternative when SNMP is unavailable, limited metrics support
Run bin/benchmark to compare performance on your system. Use --ssh flag to
include SSH in the comparison.
Device-Level Metrics
Outlet-Level Metrics
Outlet Control (Write Operations)
Device Reset Operations
Complete Status
Network Port Sharing (NPS)
When multiple PDUs are daisy-chained (up to 4 PDUs supported), specify the PDU index as the second parameter:
Testing Connection
Available Metrics
Device Metrics (DeviceMetric)
| Metric | Unit | Description |
|---|---|---|
| ModuleIndex | - | Module index |
| PduIndex | - | PDU index |
| Name | string | Device name |
| LoadStatus | LoadStatus | Load status (Normal, LowLoad, NearOverload, Overload) |
| Power | W | Current power consumption |
| PeakPower | W | Peak power since last reset |
| PeakPowerTimestamp | datetime | When peak power occurred |
| PeakPowerStartTime | datetime | When peak power tracking started (last reset) |
| Energy | kWh | Total energy since last reset |
| EnergyStartTime | datetime | When energy tracking started (last reset) |
| ApparentPower | VA | Apparent power |
| PowerFactor | ratio | Power factor (0.0-1.0) |
| OutletCount | - | Number of outlets |
| PhaseCount | - | Number of phases |
| LowLoadThreshold | % | Low load warning threshold |
| NearOverloadThreshold | % | Near overload warning threshold |
| OverloadRestriction | - | Overload restriction setting |
Outlet Metrics (OutletMetric)
| Metric | Unit | Description |
|---|---|---|
| ModuleIndex | - | Module index |
| PduIndex | - | PDU index |
| Name | string | Outlet name/label |
| Index | int | Outlet index |
| State | PowerState | Power state (Off, On) |
| Current | A | Current draw |
| Power | W | Power consumption |
| PeakPower | W | Peak power |
| PeakPowerTimestamp | datetime | When peak power occurred |
| PeakPowerStartTime | datetime | When peak power tracking started (last reset) |
| Energy | kWh | Total energy |
| EnergyStartTime | datetime | When energy tracking started (last reset)* |
| OutletType | string | Outlet type (e.g., "IEC C13") |
| ExternalLink | string | External link URL |
*Note: EnergyStartTime for outlets is shared across all outlets on a PDU (comes from
device-level rPDU2DeviceStatusOutletsEnergyStartTime OID). When you reset an outlet's
energy, all outlets share the same start time.
Enums
Tested Devices
- APC AP8653 (Metered by Outlet with Switching)
- Rack PDU FW: 7.1.4
- APC OS: 7.1.2
Development
Running Tests with Docker
Without Docker
License
MIT License. See LICENSE for details.