Network UPS Tools template -- update November 11, 2010

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Ilya Evseev
Posts: 11
Joined: Sun Mar 01, 2009 7:39 am
Location: Saint-Petersburg, Russia
Contact:

Re: Network UPS Tools template -- update November 11, 2010

Post by Ilya Evseev »

There are Cacti 0.8.7.g-1 from Debian Squeeze and Cacti-nut 0.6 (Nov 11, 2010) from Eric's site.
Importing of ./cacti-nut/templates/nut_ups_status_data_query.xml causes multiple "Unmet Dependency" errors.
Attachments
Importing of nut_ups_status_data_query.xml
Importing of nut_ups_status_data_query.xml
cacti-nut-template-baddeps.png (59.54 KiB) Viewed 5616 times
Ilya Evseev
Posts: 11
Joined: Sun Mar 01, 2009 7:39 am
Location: Saint-Petersburg, Russia
Contact:

Re: Network UPS Tools template -- update November 11, 2010

Post by Ilya Evseev »

My quick-and-dirty fix:

1) Console / Graph Templates / UPS - NUT - UPS Power Input:
and edit all 15 Items in "Graph Template Items" table:
set "Task" for each to "inputVoltage", "inputFrequency" and "batteryVoltage" respectively.

2) Console / Data Queries / NUT - UPS Statistics / UPS - NUT - UPS Power Input:
click checkboxes in "inputVoltage", "inputFrequency" and "batteryVoltage" lines,
assign appropriated templates from pull-down list for them.
Y0d4
Posts: 7
Joined: Mon Sep 03, 2012 7:49 am

Re: Network UPS Tools template -- update November 11, 2010

Post by Y0d4 »

thank you Ilya Evseev!
jannylund
Posts: 1
Joined: Thu May 09, 2013 3:12 pm

Re: Network UPS Tools template -- update November 11, 2010

Post by jannylund »

*bump*

Big thanks to ehall for creating this package and to Ilya Evseev for giving some hints on how to get it running.

I got an Eaton PW5110 UPS and after installing these templates and fixing them, I noticed things still did not work very well.
To begin with, the output of upsc for eaton sometimes contains a blankspace before the actual number, this was easily fixed by modifying the regexp in the php script. Next thing up, I noticed this UPS does not provide information for battery.charge through upsc. :evil:

Googling around, I found out that nut's blazer driver has a way of faking a value for battery.charge to give at least some kind of estimate. As it was a simple thing to do, I decided to implement this into ehall's php script as well. If anyone's interested, I put the diff on pastebin.

NOTE! In a similar way to the blazer driver, I rely on the user to set battery.voltage.high and battery.voltage.low in ups.conf.

I'd be happy to hear comments. It's not very sophisticated, but I wanted to make it as simple as possible and it does the trick. (the most tricky part would probably be to know the limits to set for battery.voltage)

Code: Select all

$ cat ups.conf
[ups]
	driver = bcmxcp_usb
	port = auto
	desc = PW5110
	default.battery.voltage.high=24.7
	default.battery.voltage.low=22

$ diff -b ss_nut_ups_status.php.orig ss_nut_ups_status.php
--- ss_nut_ups_status.php.orig
+++ ss_nut_ups_status.php
@@ -359,10 +359,35 @@
 			#
 			# note response is limited to numeric data
 			#
-			if (preg_match("/^VAR \S+ \S+ \"(\d*\.?\d*)\"$/", $nut_response, $scratch) == 0) {
-
+			if (preg_match("/^VAR \S+ \S+ \" *(\d*\.?\d*)\"$/", $nut_response, $scratch) == 0) {
+				if(trim($nut_response) === "ERR VAR-NOT-SUPPORTED") {
+					# Make guesstimated battery.charge calculation.
+					# Based on http://www.networkupstools.org/docs/man/blazer.html#_battery_charge
+					if(trim($data_request) === "battery.charge") {
+						$curr	= "battery.voltage";
+						$low 	= "battery.voltage.low";
+						$high 	= "battery.voltage.high";
+						$values = array();
+						foreach(array($low, $high, $curr) as $identifier) {
+							fwrite($nut_session, "GET VAR " . $ups['index'] . " " . $identifier . "\n");
+							$response = fgets($nut_session, 1024);
+							if (preg_match("/^VAR \S+ \S+ \" *(\d*\.?\d*)\"$/", $response, $value) == 0) {
+								/* missing value, give up. Fake it to zero. */
+								$ups_array[$ups_count]['data'] = "0.0";
+								break;
+							} else {
+								$values[$identifier] = trim($value[1]);
+							}
+						}
+						$charge = ($values[$curr] - $values[$low]) / ($values[$high] - $values[$low]) * 100;
+						$ups_array[$ups_count]['data'] = number_format(min($charge, 100), 1);
+					} else {
+						$ups_array[$ups_count]['data'] = "0.0";
+					}
+				} else {
 				echo ("FATAL: Unable to locate the requested data in NUT output\n");
 				return;
+				}
 			}
koenraad
Posts: 1
Joined: Fri May 29, 2015 8:39 am

Re: Network UPS Tools template -- update November 11, 2010

Post by koenraad »

Hi,

Since this is an old thread, I hope this will be read.

I'm using cacti 0.8.8b.
I installed everything according to the thread, and I get a graph, but it's blank.
Manually executing the script gets the expected results. But executing the script in "script_server.php" gives 'U'.
The "verbose query" of the associated dataqueries gives this :

Code: Select all

+ Running data query [10].
+ Found type = '6' [Script Query - Script Server].
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/nut_ups_status.xml'
+ XML file parsed ok.
+ <arg_num_indexes> missing in XML file, 'Index Count Changed' not supported
+ Executing script for list of indexes '"/usr/bin/php" -q /usr/share/cacti/site/scripts/ss_nut_ups_status.php rasppi1:3493:500 index' Index Count: 1
+ Found index: qnapups
+ Executing script query '"/usr/bin/php" -q /usr/share/cacti/site/scripts/ss_nut_ups_status.php rasppi1:3493:500 query ups.device'
+ Found item [upsDevice='qnapups'] index: qnapups
+ Executing script query '"/usr/bin/php" -q /usr/share/cacti/site/scripts/ss_nut_ups_status.php rasppi1:3493:500 query ups.description'
+ Found item [upsDescription='APC-ups'] index: qnapups
The log-file has this every 5 minutes :

Code: Select all

05/29/2015 02:45:01 PM - POLLER: Poller[0] WARNING: Poller Output Table not Empty.  Issues Found: 5, Data Sources: batteryCharge(DS[38]), upsLoad(DS[38]), batteryVoltage(DS[39]), inputFrequency(DS[39]), inputVoltage(DS[39])
05/29/2015 02:45:02 PM - CMDPHP: Poller[0] Host[6] DS[38] WARNING: Result from SERVER not valid.  Partial Result: FATAL: Unable to loc
05/29/2015 02:45:02 PM - CMDPHP: Poller[0] Host[6] DS[38] WARNING: Result from SERVER not valid.  Partial Result: U
05/29/2015 02:45:02 PM - CMDPHP: Poller[0] Host[6] DS[39] WARNING: Result from SERVER not valid.  Partial Result: FATAL: Unable to loc
05/29/2015 02:45:02 PM - CMDPHP: Poller[0] Host[6] DS[39] WARNING: Result from SERVER not valid.  Partial Result: U
05/29/2015 02:45:02 PM - CMDPHP: Poller[0] Host[6] DS[39] WARNING: Result from SERVER not valid.  Partial Result: FATAL: Unable to loc
05/29/2015 02:45:02 PM - SYSTEM STATS: Time:1.1253 Method:cmd.php Processes:1 Threads:N/A Hosts:7 HostsPerProcess:7 DataSources:60 RRDsProcessed:33
The verbose output of

Code: Select all

+ <arg_num_indexes> missing in XML file, 'Index Count Changed' not supported
is suspicious, but I don't know what to do.

Any suggestions how to debug this ?
I'm new to cacti, so please be gentle.

Thanks,

Koenraad.
brian32768
Posts: 1
Joined: Wed Jul 01, 2015 2:57 pm

Re: Network UPS Tools template -- update November 11, 2010

Post by brian32768 »

I am running 8.8.c and using a Cyberpower CP1500AVRLCD

The problem I had was getting the power graph; the temperature and load graphs worked just fine.

I had to use Ilya's fix. THANKS

Then I had to remove the frequency measurement because this UPS does not support it. I determined this by running the ss_nut_ups_status.php script from the command line. After seeing errors on frequency I removed it, not something I feel compelled to monitor anyway.

I did really want the voltage graphs! That's sort of the point -- so that I can watch for brownouts and power failures. So I kept hammering away at it until it worked.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests