|
|
| Author |
Message |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Tue Feb 14, 2006 9:56 am Post subject: Trying to write Script/Data Template/Graph How to debug? |
|
|
Right, I've looked around, and can't find anything on this, apart from the tutorials, which got me started but NOW I need some help...
OK I have a Perl script which is meant to gather some data about my servers, and report back 8 variables, this is it:
| Code: | #!/usr/bin/perl
# Replace '/usr/local/nagios/libexec/check_nt' with the localtion where your check_nt binary is located
# Written By A. Owen on 13/2/2006
# This script assumes:
# 1 - You have NSCLIENT Installed on the WINDOWS servers you wish to interrogate
# 2 - NSCLIENT is contactable via the default port (if not, change the "-p 1248"parameter)
# 3 - the check_nt binary is installed in the default Cacti scripts directory
# (according to the CactiEZ distro: /var/www/html/scripts).
# If not then replace /var/www/html/scripts with the correct location
# If you need the nsclient of check_nt packages go to: http://nsclient.ready2run.nl/
# The NSCLIENT package includes a compiles binary for various OS's including Linux
#
# Troubleshooting: If this script doesn't run things to check include:
# a - Does the script have the same persmissions as other scripts
# b - can the user that CACTI runs as execute this script
# c - Can the user that CACTI runs as execute Check_nt
# d - attempt to run this from a command prompt as the cacti user thus pel 4vert.pl <ipaddress>
# wher <ipaddress> is the ip address of the server you want to interrogate
# Stuff we are trying to gather:
# VPerComBytes = % Committed Bytes in use
# VPerProcTime = % Processor Time
# VAvailBytes = Available Bytes
# VPgFilePerUsage = Paging File - % Usage
# VPgFilePerUsagePk = Paging File - % Usage Peak
# VProcQLength = Processor Queue Length
# VDiskQLength = PhysicalDisk - Disk Queue Length
# VTotDiskTime = PhysicalDisk(_Total) - Disk Time
# Gather Data
$VPerComBytes = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\Memory\\% Committed Bytes In Use"`;
chomp $VPerComBytes;
$VPerProcTime = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\Processor(_Total)\\% Processor Time"`;
chomp $VPerProcTime;
$VAvailBytes = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\Memory\\Available Bytes"`;
chomp $VAvailBytes;
$VPgFilePerUsage = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\Paging File(_Total)\\% Usage"`;
chomp $VPgFilePerUsage;
$VPgFilePerUsagePk = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\Paging File(_Total)\\% Usage Peak"`;
chomp $VPgFilePerUsagePk;
$VProcQLength = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\System\\Processor Queue Length"`;
chomp $VProcQLength;
$VDiskQLength = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\PhysicalDisk(_Total)\\Current Disk Queue Length"`;
chomp $VDiskQLength;
$VTotDiskTime = `/var/www/html/scripts/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l "\\PhysicalDisk(_Total)\\%Disk Time"`;
chomp $VTotDiskTime;
# Print the data out
print "VPerComBytes:$VPerComBytes VPerProcTime:$VPerProcTime VAvailBytes:$VAvailBytes VPgFilePerUsage:$VPgFilePerUsage VPgFilePerUsagePk:$VPgFilePerUsagePk VProcQLength:$VProcQLength VDiskQLength:$VDiskQLength VTotDiskTime:$VTotDiskTime\n"; |
It looks like the script is running correctly, i.e. if I run it from the command prompt as a user with same permissions as the Cacti User it returns something like this:
| Quote: | -sh-3.00$ perl /var/www/html/scripts/4Virt.pl 10.96.24.39
VPerComBytes:49 VPerProcTime:0 VAvailBytes:93245440 VPgFilePerUsage:17 VPgFilePerUsagePk:25 VProcQLength:0 VDiskQLength:0 VTotDiskTime:0 |
Now, when I gather the data using a Data input method I get SOME of the data across (I dunno how to show this so I'll post a screen grab of the data input method):
This I use in a Data Template like this:
Which leads to a Graph Template like this:
OK so I'll create a graph from this...:
BUT it isn't graphing everything I want it to: i.e. the Available Bytes item is ALWAYS zero 0. BUT on another graph (just using several data templates instead of the one) I DO get the item graphed:
(OK to get everything on I had to use the logarithmic scale)...
Anybody got any clues? I've included the template files too! (in the next post).
| Description: |
|
| Filesize: |
67.8 KB |
| Viewed: |
1429 Time(s) |

|
| Description: |
|
| Filesize: |
56.13 KB |
| Viewed: |
1429 Time(s) |

|
| Description: |
|
| Filesize: |
223.23 KB |
| Viewed: |
1429 Time(s) |

|
| Description: |
|
| Filesize: |
219.08 KB |
| Viewed: |
1429 Time(s) |

|
| Description: |
| Screen shot of data input method |
|
| Filesize: |
205.31 KB |
| Viewed: |
1429 Time(s) |

|
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Tue Feb 14, 2006 9:57 am Post subject: |
|
|
Follow up with the template file:
| Description: |
|
 Download |
| Filename: |
cacti_graph_template_4virtualisation_system_monitor_report_v2.xml |
| Filesize: |
36.56 KB |
| Downloaded: |
50 Time(s) |
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Tue Feb 14, 2006 10:39 am Post subject: |
|
|
Now, if I graph the Available bytes data source separately (using the same data input method) I get a valid graph..
(which is probably what I will use anyway as if I graph that with the other things I need to use Logs or divide it by a large no, to get sensible graph... However I'd like to include the DATA from the query on the first graph for completeness - if not the line itself!!)
Argon0
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Tue Feb 14, 2006 10:45 am Post subject: |
|
|
Ah, same data input method, different data source, different RRA....
Could it be timing out before putting the value into the RRA?
Or is there something else going on ?
Dunno , all I know for sure now, is that the RRA for the original Data Source does NOT Seem to contain the data needed by the original graph - i.e. it has only got 0 in it...
WHY????
Oh, BTW I upped the logging level to see if it showed anything - but I don't seem to see any actions, just really simple stuff like " Data Source: Andy's PC Windows - Perfmon Data
RRD: /var/www/html/rra/andys_pc_vpercombytes_337.rrd
Action: 1, Script: perl /var/www/html/scripts/4Virt.pl 10.96.24.242".)
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12604 Location: Muenster, Germany
|
Posted: Tue Feb 14, 2006 2:13 pm Post subject: |
|
|
| argon0 wrote: | Oh, BTW I upped the logging level to see if it showed anything - but I don't seem to see any actions, just really simple stuff like " Data Source: Andy's PC Windows - Perfmon Data
RRD: /var/www/html/rra/andys_pc_vpercombytes_337.rrd
Action: 1, Script: perl /var/www/html/scripts/4Virt.pl 10.96.24.242".) | That's not from log. Please see log/cacti.log for that.
For the failing rrds, please perform a | Code: | | rrdtool info <rrd file> | and look aut for sth like | Code: | ds[a].min = NaN
ds[a].max = NaN | where a should be your data source name. If there's a limit on it, updates may "fail". The current Data Template may be misleading if changed after creation of the real rrd file (changes on data source definitions in Data Templates are NOT propagated to existing rrds!). And of course checking the logs would give you more info about what's going on
Reinhard
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Thu Feb 16, 2006 5:12 am Post subject: |
|
|
Ah, thanks - I was looking at the Poller logs - as I'm using a script..
I did change the "limit" on the data source template from 100 to 0 (to match the data template which works) AFTER initially trying to graph the item. So that sounds like it may be the problem.
Is there a way to get the existing RRD to accept the change?
Also is there a way to graph the data from tan existing RRD in another graph, using graph templates? Or does each graph (from a graph template) have to run a new query?
(actually I may see a way around this, specify a graph with None as its data source, and then CHOOSE the data source when creating the graph, then the query only has to be run once per machine!).
Also is there a way to have something as just a comment/gprint, without actually graphing it?
Thanks for your help!
Argon0
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Thu Feb 16, 2006 5:35 am Post subject: |
|
|
This is the bit concerning the AvailBytes bit:
| Code: | ds[VAvailBytes].type = "GAUGE"
ds[VAvailBytes].minimal_heartbeat = 600
ds[VAvailBytes].min = 0.0000000000e+00
ds[VAvailBytes].max = 1.0000000000e+02
ds[VAvailBytes].last_ds = "UNKN"
ds[VAvailBytes].value = 0.0000000000e+00
ds[VAvailBytes].unknown_sec = 5 |
For another server I get this:
| Code: | ds[VAvailBytes].type = "GAUGE"
ds[VAvailBytes].minimal_heartbeat = 600
ds[VAvailBytes].min = 0.0000000000e+00
ds[VAvailBytes].max = 1.0000000000e+02
ds[VAvailBytes].last_ds = "UNKN"
ds[VAvailBytes].value = 0.0000000000e+00
ds[VAvailBytes].unknown_sec = 5 |
And this graph is showing Availbytes as NaN rather than 0.
Argon0
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Thu Feb 16, 2006 5:49 am Post subject: |
|
|
From the Cacti.log file (which I now know you don't access via Cacti...) I get that the poller IS returning the correct values. I think that they are getting into the RRD files.
BUT it's still not graphing them..
I've tried it again on a new Server. I need to wait and see now...
(BTW people don't mind if I post what I'm going through to debug on here do they? I know some boards HATE multi-posters...)
Argon0
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Thu Feb 16, 2006 6:06 am Post subject: |
|
|
Aha - it now works on a new device!!
Now all I need do it NOT graph availbytes on this graph, but still include the gprint or comment for it... Is this possible?
Argon0
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12604 Location: Muenster, Germany
|
Posted: Thu Feb 16, 2006 1:02 pm Post subject: |
|
|
| argon0 wrote: | | Is there a way to get the existing RRD to accept the change? | try "rrdtool tune" | Code: | | rrdtool tune <rrdfile> --maximum <ds>:<max> | if I remember correctly
| Quote: | | Also is there a way to graph the data from tan existing RRD in another graph, using graph templates? Or does each graph (from a graph template) have to run a new query? | This is possible. Create the graph that generates the Data Sources from the Devices as usual ("Create Graphs for this Host"). The second Graph must be generated from Graph Management. Click Add and specify the wanted Template and the Host, Create and proceed by selecting the Data Sources
| Quote: | | Also is there a way to have something as just a comment/gprint, without actually graphing it? | No. But you may select a color of white. Pay attention: if this DS will give you the biggest values of all DSs, it will define the Graphs y-Axis when running in autoscale mode (if you need the workaround, lets talk about that seperately, it's a bit tricky)
Reinhard
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12604 Location: Muenster, Germany
|
Posted: Thu Feb 16, 2006 1:04 pm Post subject: |
|
|
| argon0 wrote: | This is the bit concerning the AvailBytes bit:
| Code: | | ds[VAvailBytes].max = 1.0000000000e+02 |
For another server I get this:
| Code: | | ds[VAvailBytes].max = 1.0000000000e+02 |
And this graph is showing Availbytes as NaN rather than 0.
Argon0 | You must rrdtool tune the maximums above
Reinhard
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Fri Feb 17, 2006 4:44 am Post subject: |
|
|
Thanks Reinhard...
So this would work (for example):
| Code: | rrdtool tune /var/www/html/rra/andys_pc_vpercombytes_337.rrd --maximum VAvailBytes:0
|
(I get no feedback from the machine)
Yup worked out about graphing stuff on another graph. Bit of a workaround.... No big deal though...
Also worked out the bit about white line, unfortunately the AvailBytes variable is in the range of 40 - 1000 Megabytes, everything else is in the 0-100 range.
Workaround I have for this is to divide the Availbytes by an arbitrarily large number so that it doesn't affect the graph. Would be lovely to be able to overlay different scales on the same graph...
Hmmm, can you multiply by 0 or do you get an error...
The other workaround is to use Logarithmic scales. But this hides the detail for the lower graphs...
Going to run the rrdtool tune on the two ds's and leave it for a while -- in the meantime going to work on the "Legends" bit...
Last edited by argon0 on Fri Feb 17, 2006 11:09 am; edited 1 time in total |
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Fri Feb 17, 2006 6:59 am Post subject: |
|
|
Right done the "work" on my "legends" project...
Now to tackle some more Perl stuff (EXCHANGE) this time, which looks like its gone wonky...
Argon0
|
|
| Back to top |
|
 |
argon0 Cacti User
Joined: 12 Mar 2004 Posts: 238
|
Posted: Fri Feb 17, 2006 11:10 am Post subject: |
|
|
Right done that..
rrdtool tune didn't seem to work, but as there isn't much history here I've decided to recreate the graphs from scratch.
Now to finish off the Virtualisation Graphs, and publish them...
Argon0
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12604 Location: Muenster, Germany
|
Posted: Mon Feb 20, 2006 1:22 pm Post subject: |
|
|
| argon0 wrote: | Also worked out the bit about white line, unfortunately the AvailBytes variable is in the range of 40 - 1000 Megabytes, everything else is in the 0-100 range.
Workaround I have for this is to divide the Availbytes by an arbitrarily large number so that it doesn't affect the graph. Would be lovely to be able to overlay different scales on the same graph...
Hmmm, can you multiply by 0 or do you get an error...
| Well, the multiply by 0 was near. It may be much simpler: use a CDEF=0 would always result in 0 and is incredibly performant (and dumb, of course).
Reinhard
|
|
| Back to top |
|
 |
|