What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I monitor an APC UPS that does not support SNMP?

Votes:

0

I have an older APC UPS that only has a serial monitoring port so the default SNMP sensor for APC does not work. Can I monitor this UPS device nevertheless?

apc apc-ups custom-script-exe custom-sensor prtg ups

Created on Mar 16, 2015 4:12:17 PM by  Gerald Schoch [Paessler Support]

Last change on Jul 11, 2019 10:43:39 AM by  Maike Guba [Paessler Support] (2,404) 2 1



10 Replies

Accepted Answer

Votes:

4

This article applies as of PRTG 22

Monitoring an APC UPS with serial monitoring port using a PowerShell script

With the SNMP APC Hardware sensor, you can monitor various performance counters of an APC UPS (uninterruptible power supply) via SNMP. With appropriate OIDs, you can also monitor additional counters of APC UPS hardware with custom SNMP sensors.

If you have, for example, an older APC UPS device that only has a serial monitoring port, you cannot use the default SNMP APC Hardware sensor because the UPS must support SNMP. One of our customers found a solution for this issue and monitors an APC UPS with an EXE/Script Advanced sensor using the corresponding Windows binaries for controlling APC UPS devices.

We are happy that this customer is sharing the corresponding script (see below) with us. Thank you!

Using this PowerShell script, you can monitor the following values of your APC UPS: Volt Line, Volt Battery, Volt Output, Load, Temperature, Charge, and Time Left. You can also view the status as a sensor message.

How to use the PowerShell script

  1. Before applying the custom script, download the APC UPS Daemon apcupsd for Windows and run it.
  2. Configure apcupsd.conf appropriately (see the APCUPSD User Manual).
  3. Copy the source code for the sensor from below and paste it into a text editor.
  4. Save the file with the extension .ps1, for example, apc-ups.ps1.
  5. Copy this file into the \Custom Sensors\EXEXML subfolder of the PRTG program directory on the probe system that monitors your APC UPS.
  6. Set the correct execution policy for PowerShell.
  7. In PRTG, add an EXE/Script Advanced sensor to your APC UPS device, and select the apc-ups.ps1 script in the Add Sensor dialog.

Note: We do not offer support for custom sensors provided by customers. Of course, you are free to adjust the script according to your needs.

Script

#-----------------
$cmd="c:\apcupsd\bin\apcaccess.exe"
#-----------------


$status = invoke-expression $cmd" -u -p STATUS"
$linev=invoke-expression $cmd" -u -p LINEV"
$loadpct=invoke-expression $cmd" -u -p LOADPCT"
$bcharge=invoke-expression $cmd" -u -p BCHARGE"
[int]$ti=invoke-expression $cmd" -u -p TIMELEFT"
$timeleft=$ti*60
$battv=invoke-expression $cmd" -u -p BATTV"
$itemp=invoke-expression $cmd" -u -p ITEMP"
$outputv=invoke-expression $cmd" -u -p OUTPUTV"

$result= "<?xml version=`"1.0`" encoding=`"Windows-1252`" ?>`r`n"
$result+="<prtg>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Volt Line</channel>`r`n"
$result+="       <CustomUnit>V</CustomUnit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$linev+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Volt Battery</channel>`r`n"
$result+="       <CustomUnit>V</CustomUnit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$battv+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Volt Output</channel>`r`n"
$result+="       <CustomUnit>V</CustomUnit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$outputv+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Load</channel>`r`n"
$result+="       <unit>Percent</unit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$loadpct+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Temperature</channel>`r`n"
$result+="       <unit>Temperature</unit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$itemp+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Charge</channel>`r`n"
$result+="       <unit>Percent</unit>`r`n"
$result+="       <float>"+"1"+"</float>`r`n"
$result+="       <value>"+$bcharge+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <result>`r`n"
$result+="       <channel>Time Left</channel>`r`n"
$result+="       <unit>TimeSeconds</unit>`r`n"
$result+="       <value>"+$timeleft+"</value>`r`n"
$result+="   </result>`r`n"
$result+="   <text>"+$status+"</text>`r`n"
$result+="</prtg>`r`n"
$result
Exit 0

More

Created on Mar 16, 2015 4:21:23 PM by  Gerald Schoch [Paessler Support]

Last change on Dec 29, 2022 10:40:57 AM by  Brandy Greger [Paessler Support]



Votes:

4

Works great!

My APCUPSD installation is placed in C:\Program Files.

It's a real pain to find a correct syntax for parameters with 'spaces' and 'quotes' for PowerShell invoke-expression command.

I finished with entering path as

$cmd="'C:\Program Files\APCUPSD\bin\apcaccess.exe'"
$status = invoke-expression "&$cmd -u -p STATUS"

Created on Mar 30, 2015 7:25:05 PM

Last change on Jan 13, 2016 11:23:45 AM by  Luciano Lingnau [Paessler]



Votes:

0

I would expand 6. to

6A. Modify PowerShell execution policy: https://kb.paessler.com/en/topic/20443-powershell-32bit-or-64bit-and-execution-policy

Created on Mar 30, 2015 7:32:02 PM

Last change on Mar 30, 2015 7:32:02 PM



Votes:

0

Thank you for your tips! We added also a note about the execution policy.

Created on Mar 31, 2015 11:26:39 AM by  Gerald Schoch [Paessler Support]



Votes:

0

I am attempting to do this, and have set the execution policy, and when I add the script, I get no values. When I run the ps script from the device, I get values. What am I missing?

Created on Mar 8, 2016 6:57:28 PM



Votes:

5

I figured a way around my problem. I put apcaccess.exe locally on the probe and changed the $cmd variable to look there. Then I modified the invoke-expression lines to include the -h switch for apcaccess. This also gets around modifying the powershell execution policy.

Created on Mar 9, 2016 7:25:52 PM



Votes:

3

Here's a custom sensor for working with APC UPS devices and PRTG (scriptsxml/apc.sh): https://github.com/andygajetzki/prtg-sensors

I was very helped

Created on Aug 1, 2018 12:24:20 PM

Last change on Aug 1, 2018 1:12:51 PM by  Erhard Mikulik [Paessler Support]



Votes:

0

Thank you for sharing this, K0NCTANT1N.

Kind regards,

Erhard

Created on Aug 1, 2018 1:11:26 PM by  Erhard Mikulik [Paessler Support]



Votes:

0

Should step 6 be performed on the target machine where apsupsd is installed, or on the PRTG server? Should powershell be enabled on the target computer?

Created on May 23, 2023 4:22:01 AM



Votes:

0

The reason for this step is because PRTG starts the 32-bit version of PowerShell even on a 64-bit Windows system, therefore you need to do this on the PRTG side.

Enable the PowerShell 32-Bit and 64-Bit and Execution Policy if you want to run the script/sensor from the computer connected to the Apcupsd USB UPSes on Windows

What PRTG does with the EXE/Script Advanced sensor is to monitor the USB UPSes on Windows that are used for power management and controlling most of APC’s UPS models.

Created on May 24, 2023 10:54:20 PM by  Ivan Escalante [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.