Yet Another NUT (Network UPS Tools) Status

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

Moderators: Moderators, Developers

Author
Message
User avatar
bsd
Posts: 3
Joined: Tue Jun 27, 2006 8:00 am
Location: Chandigarh, UT, India
Contact:

Yet Another NUT (Network UPS Tools) Status

#1 Post by bsd » Tue Jun 27, 2006 8:41 am

Hi all,

I have been using this one since long, but forget to share it with you :)

The tarball contains a Ruby script to collect NUT data and a graph template; put the config.rb somewhere in your /usr/local/lib/site_ruby/1.x/, and the other script in to your cacti/scripts directory, import the graph template in to your working cacti.

You will need to pass on the UPS name/id as parameter like [email protected] to monitor it.

Image

Hope it is almost as useful to you as it is for me.

Cheers!
Attachments
cacti-nut-ups-status-0.0.1.tar.gz
Contains Ruby scripts and graph template
(6.23 KiB) Downloaded 2968 times
Balwinder S "bsd" Dheeman
http://cto.homelinux.net/~bsd

Morpheus4you
Posts: 1
Joined: Sat Sep 16, 2006 7:37 pm
Location: Arnhem, Netherlands

#2 Post by Morpheus4you » Sat Sep 16, 2006 7:42 pm

Thank you for sharing this, it works well.

I only had to change line 14 of the file "nut_ups_status.rb" to get it to work,
so it pointed to the correct config file:

Code: Select all

conf = Config::read "/etc/ups/upsd.users"
It seems like it looks something from the config, but i couln't find the location where to set it from the cacti-web-interface, so i changed it manually in the file.

Thanks again!

User avatar
bsd
Posts: 3
Joined: Tue Jun 27, 2006 8:00 am
Location: Chandigarh, UT, India
Contact:

#3 Post by bsd » Sat Sep 30, 2006 3:33 pm

Morpheus4you wrote:Thank you for sharing this, it works well.
You're welcome!
Morpheus4you wrote: I only had to change line 14 of the file "nut_ups_status.rb" to get it to work,
so it pointed to the correct config file:

Code: Select all

conf = Config::read "/etc/ups/upsd.users"
It seems like it looks something from the config, but i couln't find the location where to set it from the cacti-web-interface, so i changed it manually in the file.
It trys to read password for user cacti from /etc/nut/upsd.users file; will continue even if you have not defined one. The path to upsd.users file depends on distro and, or packaging.
Morpheus4you wrote:Thanks again!
Welcome again ;)
Balwinder S "bsd" Dheeman
http://cto.homelinux.net/~bsd

le
Posts: 1
Joined: Wed Mar 07, 2007 12:28 pm

Problem with no rrd graphs being displayed

#4 Post by le » Wed Mar 07, 2007 12:42 pm

I had the problem that the graphs were not being generated. I simply deleted the statement "-y-grid=v" from the rrd template definition and everything worked.

mmcnamee
Posts: 1
Joined: Wed May 09, 2007 5:41 pm

Fixing a few niggles

#5 Post by mmcnamee » Wed May 09, 2007 6:01 pm

Hi,

I was trying this using a Ubuntu 6.06 server with apache and cacti installed via apt (standard stuff)

I had a few little niggly issues: firstly I mis-read the original post and put the config.rb file in the wrong place (I got the config.rb and nut_ups_status.rb the wrong way around, doh!).

Importing the XML file caused some errors for me. I tracked this down the the degrees symbol not being a valid XML entity! I've removed the 2 symbols from the XML, and it imported successfully.

Once I got to the bottom of that, I still had some issues. I was getting errors in the /usr/share/cacti/site/log/poller-error.log file.

I added some configuration to my upsd.users file
---
[cacti]
password=password
allowfrom=local
upsmon slave
---
and this resolved part of the issue. The other problem was that the web server could not read the upsd.users file (not sure if this is strictly essential, but it logs an error).

Hacking slightly, I just ran this
chmod o+r /etc/nut/upsd.users

Which resolve the issue. I intend to sort out proper group permissions for this file later!

Hope this helps someone. I've attached a new zip, with the updated XML file, and a readme.txt file which details how I installed it.

Great script, really really useful, thanks for your hard work in writing this in the first place!!

Cheers,
Mark
Attachments
cacti-nut-ups-status-0.0.1-patch.zip
Patched version with XML fix and a readme.txt instructions file
(7.31 KiB) Downloaded 1578 times

dblosvn
Posts: 1
Joined: Sat Jun 23, 2007 2:34 pm

#6 Post by dblosvn » Sat Jun 23, 2007 2:35 pm

Has anyone been able to make this work for remote UPS's

I have a number of them that I would like to graph over time.

thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

Almost Working!!!

#7 Post by thavinci » Tue Nov 06, 2007 12:23 pm

Man ive spent days trying to get this working following every step.
First the xml issue happened to me aswell.
And other few glitches.

But eventually i was presented with emty graphs.

After much searching i checked the cacti.log

and was presented with a

"CMDPHP: Poller[0] Host[1] DS[19] WARNING: Result from CMD not valid. Partial Result:"

I have tried running the poller manually as root. This presents me with values and it starts graphing. Then i attempted to change to the user "cacti" to see if this is a permission issue. Running it as user "cacti" as per cron job also presented the graphs.

Image

However it DOES not do so automatically from crontab.
I have the default crontab entry for cacti as follows:

*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1

I have also tried to change the user to root in the crontab, this also does not work.

It seems it ONLY creates the graphs when the cacti poller is run manually.
This is really confusing me as i have no idea whats causing this.

YelP! ;p

thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

Even Tried Replaceing Poller

#8 Post by thavinci » Tue Nov 06, 2007 3:26 pm

Ive even tried replacing poller to cactid to see if i can get any additional info.


logs show following....


11/06/2007 10:20:01 PM - CACTID: Poller[0] Host[1] DS[19] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/06/2007 10:20:01 PM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'ruby /usr/local/share/cacti/scripts/nut_ups_status.rb [email protected]'

However running command directly as cacti user shows following....
blvl:97.5 ivol:226.9 load:24.0 ovol:226.9 stat:1 temp:25.0

hanji
Posts: 3
Joined: Thu Nov 15, 2007 5:14 pm
Contact:

#9 Post by hanji » Thu Nov 15, 2007 5:15 pm

Any luck with this? I'm getting the exact same problem.

Thanks!
hanji

hanji
Posts: 3
Joined: Thu Nov 15, 2007 5:14 pm
Contact:

#10 Post by hanji » Thu Nov 15, 2007 5:44 pm

I actually got the poller thing worked out, it was related to the config.rb path, but I'm still getting a broken graph (not graphing at all). Checking the apache error logs, I see this:

Code: Select all

ERROR: invalid y-grid format
I'm definitely getting data:

Code: Select all

./nut_ups_status.rb [email protected]
blvl:100 ivol:121 load:022 ovol: stat:1 temp:45.0
Here is the output from graph debug:
RRDTool Command:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Backup Server - NUT/UPS Status" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--y-grid=v \
--vertical-label="volts/level/load/temp" \
--slope-mode \
DEF:a="/var/www/localhost/htdocs/cacti/rra/backup_server_temp_54.rrd":ovol:AVERAGE \
DEF:b="/var/www/localhost/htdocs/cacti/rra/backup_server_temp_54.rrd":ivol:AVERAGE \
DEF:c="/var/www/localhost/htdocs/cacti/rra/backup_server_temp_54.rrd":blvl:AVERAGE \
DEF:d="/var/www/localhost/htdocs/cacti/rra/backup_server_temp_54.rrd":load:AVERAGE \
DEF:e="/var/www/localhost/htdocs/cacti/rra/backup_server_temp_54.rrd":temp:AVERAGE \
AREA:a#FF99FF:"Output"  \
GPRINT:a:LAST:"    Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
AREA:b#FFFF66:"Input"  \
GPRINT:b:LAST:"     Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n"  \
LINE2:c#666633:"Batteries"  \
GPRINT:c:LAST:" Current\:%8.2lf %%"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf %%"  \
GPRINT:c:AVERAGE:"Maximum\:%8.2lf %%\n"  \
LINE2:d#0033FF:"Load"  \
GPRINT:d:LAST:"      Current\:%8.2lf %%"  \
GPRINT:d:AVERAGE:"Average\:%8.2lf %%"  \
GPRINT:d:MAX:"Maximum\:%8.2lf %%\n"  \
LINE2:e#FF3300:"Temprature"  \
GPRINT:e:LAST:"Current\:%8.2lf C"  \
GPRINT:e:AVERAGE:"Average\:%8.2lf C"  \
GPRINT:e:MAX:"Maximum\:%8.2lf C" 

RRDTool Says:

ERROR: invalid y-grid format
Any ideas as to what the problem is?

Thanks
hanji
[url=http://www.uno-code.com]Server Admin Blog - Uno-Code.com[/url]

hanji
Posts: 3
Joined: Thu Nov 15, 2007 5:14 pm
Contact:

#11 Post by hanji » Thu Nov 15, 2007 5:52 pm

I'm getting a graph now. I edit'd the graph template and removed the 'v' from 'Unit Grid Value'. Curious if this is normal, or do I need v for useful graphs.. I guess I'll wait and see.

Thanks!
hanji
[url=http://www.uno-code.com]Server Admin Blog - Uno-Code.com[/url]

thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

Still No Luck Here!

#12 Post by thavinci » Sat Nov 24, 2007 7:18 pm

I had already removed the axis problem, so twas not the issue for me.

Mine "seems" to be some permission issue. The odest thing i tell you.
I will post a debug screen aswell from cacti soon. Just as soon as i switch that box back on. Pitty i can't get no advise on this one.



.:thavinci:.

thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

More issues

#13 Post by thavinci » Mon Dec 03, 2007 10:32 am

After waiting a while hopying to get a clear head and tackle this one again ive still come up emty.....

RRDTool Command:

/usr/local/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Localhost - NUT/UPS Status" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="volts/level/load/temp" \
--slope-mode \
DEF:a="/usr/local/share/cacti/rra/localhost_stat_19.rrd":ovol:AVERAGE \
DEF:b="/usr/local/share/cacti/rra/localhost_stat_19.rrd":ivol:AVERAGE \
DEF:c="/usr/local/share/cacti/rra/localhost_stat_19.rrd":blvl:AVERAGE \
DEF:d="/usr/local/share/cacti/rra/localhost_stat_19.rrd":load:AVERAGE \
DEF:e="/usr/local/share/cacti/rra/localhost_stat_19.rrd":temp:AVERAGE \
AREA:a#FF99FF:"Output" \
GPRINT:a:LAST:" Current\:%8.2lf %s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
AREA:b#FFFF66:"Input" \
GPRINT:b:LAST:" Current\:%8.2lf %s" \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" \
LINE2:c#666633:"Batteries" \
GPRINT:c:LAST:" Current\:%8.2lf %%" \
GPRINT:c:AVERAGE:"Average\:%8.2lf %%" \
GPRINT:c:AVERAGE:"Maximum\:%8.2lf %%\n" \
LINE2:d#0033FF:"Load" \
GPRINT:d:LAST:" Current\:%8.2lf %%" \
GPRINT:d:AVERAGE:"Average\:%8.2lf %%" \
GPRINT:d:MAX:"Maximum\:%8.2lf %%\n" \
LINE2:e#FF3300:"Temprature" \
GPRINT:e:LAST:"Current\:%8.2lfC" \
GPRINT:e:AVERAGE:"Average\:%8.2lfC" \
GPRINT:e:MAX:"Maximum\:%8.2lfC"

RRDTool Says:

OK
Running poller manually presents with .....
[[email protected]???? /home/thavinci]# /usr/local/bin/php /usr/local/share/cacti/poller.php
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:6.12
OK u:0.00 s:0.00 r:6.12
OK u:0.00 s:0.00 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
OK u:0.00 s:0.01 r:6.12
12/03/2007 03:27:03 PM - SYSTEM STATS: Time:7.1529 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
Segmentation fault: 11 (core dumped)
Running poller manually presents still with possitive result and fully operational..

Image

Whereass allowing cacti to do its thing on own presents emty graphs.

Image

cacti shows the following error in cacti.log when running on own....
12/03/2007 03:30:09 PM - SYSTEM STATS: Time:8.1736 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
12/03/2007 03:30:02 PM - CACTID: Poller[0] Host[1] DS[19] WARNING: Result from SCRIPT not valid. Partial Result: ...
12/03/2007 03:30:02 PM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'ruby /usr/local/share/cacti/scripts/nut_ups_status.rb [email protected]'
12/03/2007 03:27:03 PM - SYSTEM STATS: Time:7.1529 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
12/03/2007 03:26:35 PM - SYSTEM STATS: Time:7.1543 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
12/03/2007 03:25:17 PM - SYSTEM STATS: Time:7.1501 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
12/03/2007 03:25:08 PM - SYSTEM STATS: Time:7.1503 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:46 RRDsProcessed:39
12/03/2007 03:25:01 PM - CACTID: Poller[0] Host[1] DS[19] WARNING: Result from SCRIPT not valid. Partial Result: ...
12/03/2007 03:25:01 PM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'ruby /usr/local/share/cacti/scripts/nut_ups_status.rb [email protected]'
Yet when poller is run manually....
12/03/2007 03:34:23 PM - SYSTEM STATS: Time:7.2649 Method:cactid Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:47 RRDsProcessed:40

All good :<

tomines
Posts: 4
Joined: Mon Dec 03, 2007 4:21 pm

#14 Post by tomines » Mon Dec 03, 2007 8:19 pm

I'm having this same issue. I posted my problem in the Help Linux/Unix forums. When I run poller.php manually as the cacti user I have no issues however when I let it run out of cron it just doesn't work.

thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

At least im not alone!

#15 Post by thavinci » Tue Dec 04, 2007 11:02 am

At least im not the only one!

Hope someone can find a fix..

Post Reply