New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


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

Votes:

0

Your Vote:

Up

Down

I have an older APC UPS that only has a serial monitoring port so the default PRTG 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]



8 Replies

Accepted Answer

Votes:

4

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 14 or later

Monitoring an APC UPS with Serial Monitoring Port Using a PowerShell Script

PRTG includes an SNMP APC Hardware sensor out of the box. With this sensor type, you can monitor various performance counters of an APC UPS (uninterruptible power supply) via SNMP. Using 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 has a serial monitoring port only, you cannot use this default APC hardware sensor because the UPS has to 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 shares 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, Time Left, and show the status as sensor message.

How to Use the PowerShell Script

  1. Before applying the custom script, download and get to run the APC UPS Daemon apcupsd for Windows.
  2. Configure apcupsd.conf appropriately (please see the apcupsd online 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 your PRTG installation directory on the system running the probe 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, choosing 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


See Also

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

Last change on Mar 31, 2015 11:23:23 AM by  Gerald Schoch [Paessler Support]



Votes:

4

Your Vote:

Up

Down

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 by  i3laze (102) 2 1

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



Votes:

0

Your Vote:

Up

Down

I would expand 6. to

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

Created on Mar 30, 2015 7:32:02 PM by  i3laze (102) 2 1

Last change on Apr 1, 2015 5:53:04 AM by  i3laze (102) 2 1



Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  mjgporzio (50)



Votes:

5

Your Vote:

Up

Down

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 by  mjgporzio (50)



Votes:

3

Your Vote:

Up

Down

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 by  K0NCTANT1N (40)

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



Votes:

0

Your Vote:

Up

Down

Thank you for sharing this, K0NCTANT1N.

Kind regards,

Erhard

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



Please log in or register to enter your reply.


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.