|
|
| Author |
Message |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Thu Jul 03, 2008 7:21 am Post subject: Getting Temptrax working... |
|
|
Hello all,
I have recently installed cacti on a VM server, I am looking to monitor several sensatronics temperature sensors.
I am looking at monitoring a couple of E4's a few E8's, and an E16.
I have installed the temptrax template, and i have it working for one of the E4's
But this is where my problems start, I can add the others into the devices section, but the temptrax query displays 0 rows, 0 colums. I get this for the other few E4's, E8's and E16.
I have tried to do the snmpwalk without success. but if i run perl temptrax 192.168.1.1 192.168.1.1 query name on the good sensor, i get the four probes displayed.
but if i do the same for the other sensatronics boxes, i just get a time out..
I can incidently ping the others, and get sensor data from them using nagios(its running a temptrax binary) and the web front end....
I have spent a few days struggling, and reading posts on here but i have not discovered a solution...Is there anyone who can help please??
Thanks! |
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12206 Location: Muenster, Germany
|
Posted: Thu Jul 03, 2008 10:42 am Post subject: |
|
|
Well, this depends on how the Data Query works. As I do not have access to such a device, I'm not able to test on my own. Are you able to debug the script? Perhaps, it has a fiexd limitation to 4 probes?
The other way round would be to use the nagios stuff and feed data into cacti. See 1st link of my sig for a start
Reinhard |
|
| Back to top |
|
 |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Fri Jul 04, 2008 2:40 am Post subject: |
|
|
Thanks Gandalf!
I have since discovered that this may be a mis-configuration with the temp sensors..
I just seems funny that one E4 works and the other E4's dont...
I am using the same templates and same method, and even when i smtpwalk the others they just time out, this is not the case for the working one., so logic says it is something to do with the sensors, and not the way that cacti is handling them??
I wiil make sure the rest are configured the same as the working one and i will get back to you..
Thanks for your help so far!!
Regards,
Chummers |
|
| Back to top |
|
 |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Tue Jul 22, 2008 6:50 am Post subject: |
|
|
I have managed to get all the E4's and E8's working just need to get the last E16 working....
Right i have been doing some more looking around and this is what i have discovered...
I have been looking at the perl script that reads the OID's
If i walk the OID's from all different type of temp sensors i get the following...
E4
the result from OID .1.3.6.1.4.1.16174.1.1.1.1.2.0 is :
SNMPv2-SMI::enterprises.16174.1.1.1.1.2.0 = STRING: "E4"
E8
The result from OID .1.3.6.1.4.1.16174.1.1.1.1.2.0 is :
SNMPv2-SMI::enterprises.16174.1.1.1.1.2.0 = STRING: "E8"
E16
The result from OID .1.3.6.1.4.1.16174.1.1.1.1.2.0 is :
SNMPv2-SMI::enterprises.16174.1.1.1.1.2.0 = Hex-STRING: 50 38 21 17 02
So it looks like the E16 has some different enteries, but being i know no perl whatsoever, i am finding this very difficult to change.
below is the script i am using, so i will need to call it a different name (i had to do this for the differences between the E4's and the E8's)
(so one script for the E4, one for the E8 and so on....)
| Code: | #!/usr/bin/perl
#
# Cacti TempTrax query script, 03.05.06 Paul Venezia (pvenezia@jpj.net)
#
# It's pretty ugly, but the non-standard SNMP support in these
# devices makes this necessary. Sigh.
#
#
use strict;
use Data::Dumper;
my ($probecount);
my %tempdata;
my $probe = $ARGV[0];
my $comm = 'secret';
#my $comm = $ARGV[1];
my $func = $ARGV[2];
open(WALK, "/usr/bin/snmpwalk -c $comm -v1 -On $probe .iso |grep -v 4.0|");
foreach my $snmpret (<WALK>) {
chomp($snmpret);
if ($snmpret =~ /\.1\.3\.6\.1\.4\.1\.16174\.1\.1\.1\.1\.2\.0\s=\sSTRING:\s\"(.+)\"/) {
my $pcount = $1;
$pcount =~ s/^E//;
$probecount = $pcount;
}
if ($snmpret =~ /\.1\.3\.6\.1\.4\.1\.16174\.1\.1\.1\.3\.(\d)\.(\d)\.0\s=\s(\w+):\s(.*)/) {
if ($1 <= $probecount) {
$tempdata{$1}{probe} = $1;
$tempdata{$1}{name} = $4 if $2 == 1;
$tempdata{$1}{name} =~ s/\"//;
$tempdata{$1}{temp} = $4 if $3 eq 'INTEGER';
}
}
}
#print Dumper %tempdata;
if ($func eq "index") {
foreach my $pindex ( sort keys %tempdata ) {
print "$pindex:$pindex\n";
}
} elsif ($func eq "get") {
foreach my $pindex ( sort keys %tempdata ) {
print "$tempdata{$pindex}{$ARGV[3]}" if $ARGV[4] == $pindex;
}
} elsif ($func eq "query") {
foreach my $pindex ( sort keys %tempdata ) {
print "$pindex:$tempdata{$pindex}{$ARGV[3]}\n";
}
}
#print Dumper %licstatus;
|
I think i should be using the OID .1.3.6.1.4.1.16174.1.1.1.1.9 (which will return the value of 16 (just what i need) but its an integer, not a string
I do not know how to use the new OID, everytime i change a value, it just seems to break the script.... - get no output...
I know what i need to do but dont know the perl syntax to accomplish it...
Can anyone help me please - not sure if this is in the right place, if not sorry ...... |
|
| Back to top |
|
 |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Thu Jul 24, 2008 10:11 am Post subject: |
|
|
Respectfully bumping
I could really use some help please...
Seem so close yet so far... |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Thu Jul 24, 2008 11:18 pm Post subject: |
|
|
Gandolf is taking a well deserved vacation. He may get back to you in a week or so.
TheWitness |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Thu Jul 24, 2008 11:20 pm Post subject: |
|
|
IMHO, that script sucks. It is very inefficient and would be very prone to latency, and spike the CPU on the device (depending on it's clock). It should be "respectfully" rewritten. There are many examples. I would do it for $$, if I could find the time.
TheWitness |
|
| Back to top |
|
 |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Fri Jul 25, 2008 2:24 am Post subject: |
|
|
Hi TheWitness!,
Thank you for your reply, Gandalf does look like a busy person indeed!
I will wait for his return - I hope he enjoys his break
Something you may be able to answer in the meantime...
Since i do not know any perl whatsoever, can i rewrite this script in another language - is cacti really fussed (as long as it can query the values?) i was thinking about bash or something....
I guess it would just be a case of pointing the .xml file to a .sh rather than a .pl file??
I think it may be better for me to do this, since i have to get the E16 working, and then the EM1 (which outputs temperature, humidity, and wetness....)
I makes it rather awkward to actually know what this perl script does, since the auther did not put any comments in whatsoever... |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Fri Jul 25, 2008 12:11 pm Post subject: |
|
|
You are correct. I prefer the PHP Script Server cause it's very fast, I have some systems using Script Server that poll 100% scripts 50k calls in less than 30 seconds, but shell script bash/ksh/csh work all fine as well.
TheWitness |
|
| Back to top |
|
 |
BWB8771
Joined: 10 Oct 2008 Posts: 2
|
Posted: Fri Oct 10, 2008 1:37 pm Post subject: PHP version of script? |
|
|
| I too would be interested in a PHP version for the E16! |
|
| Back to top |
|
 |
chummers
Joined: 02 Jul 2008 Posts: 9
|
Posted: Tue Oct 14, 2008 6:02 am Post subject: |
|
|
I did this :
| Code: | #!/bin/bash
# Reads number of probes
# uses number of probes to loop, and read temperature values
# This is ONLY for the E4, E8 and E16 Temptrax devices
#
#
# Usage : ./test.sh <ip address> <ipaddress> get index name
# INDEX GET TEMP NAME
#
#*********************** Define variables *********************************
ip=$1;
ip2=$2;
func=$3;
func2=$4;
probe=$5;
counter="0";
detail_oid_counter="0";
ProbeName[0]="STRING"
ProbeTemp[0]="1"
QueryName[0]="TEST"
QueryTemp[0]="1.0"
numberofprobes="1";
completewalk=" ";
trimmed=" ";
version="-v1";
community="-c temperature";
oid=".1.3.6.1.4.1.16174.1.1.1.1.9";
oid_em1=".1.3.6.1.4.1.16174.1.1.3.1.2";
#******************** Get OID variable routine *****************************
function getnumberofprobes
# Walks OID for number of probes on the device
{
numberofprobes=`snmpwalk $version $community $ip $oid | sed 's/.*: //g' | sed 's/"//g' `;
}
function getprobename
{
A="1";
B="1";
C="1";
D="3";
E=$probe;
F="1";
counter="1";
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
ProbeName[$probe]=`snmpwalk $version $community $ip $detail_oid | sed 's/.*: //g' | sed 's/"//g' `;
echo ${ProbeName[$probe]}
}
function getprobetemp
{
A="1";
B="1";
C="1";
D="3";
E=$probe;
F="3";
counter="1";
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
ProbeTemp[$probe]=`snmpwalk $version $community $ip $detail_oid | sed 's/.*: //g' | sed 's/"//g' `;
echo ${ProbeTemp[$probe]}
}
function getqueryname
{
A="1";
B="1";
C="1";
D="3";
E="1";
F="1";
counter="1";
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
until [ $counter -gt $numberofprobes ];
do
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
QueryName[$counter]=`snmpwalk $version $community $ip $detail_oid | sed 's/.*: //g' | sed 's/"//g' `;
echo $counter":"${QueryName[$counter]}
let E+=1
let counter+=1
done
}
function getquerytemp
{
A="1";
B="1";
C="1";
D="3";
E="1";
F="1";
counter="1";
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
until [ $counter -gt $numberofprobes ];
do
detail_oid=".1.3.6.1.4.1.16174.$A.$B.$C.$D.$E.$F";
QueryTemp[$counter]=`snmpwalk $version $community $ip $detail_oid | sed 's/.*: //g' | sed 's/"//g' `;
echo $counter":"${ProbeTemp[$counter]}
let E+=1
let counter+=1
done
}
function getprobeindex
{
counter="1"
let numberofprobes+=1
until [ "$counter" = "$numberofprobes" ];
do
echo $counter:$counter
let counter+=1
done
}
#****** Routine for the E4 / E8 & E16 Temptrax sensors routine *****************
function E4816
# Prints number of probes on device
{
if [ "$numberofprobes" = 4 ];then
ActionToTake
elif [ "$numberofprobes" = 8 ];then
ActionToTake
elif [ "$numberofprobes" = 16 ];then
ActionToTake
fi
}
#*******Routing for the EM1 Environment monitor routine **********************
function EM1
# Routine for the EM1 Environment monitors
{
echo "probe to run EM1!!! "
ActionToTake
}
#*********************** Main routine ************************************
function main
{
if [ "$numberofprobes" = "" ]; then
numberofprobes_em1=`snmpwalk $version $community $ip $oid_em1 | sed 's/.*: //g' | sed 's/"//g' `;
EM1
else
E4816
fi
}
#******* Routine to get values from appropriate probe ************************
function ActionToTake
{
#echo $func, $header, $probe;
if [ "$func" = 'index' ];then
getprobeindex
fi
if [ "$func" = 'get' ];then
if [ "$func2" = 'name' ];then
getprobename
fi
if [ "$func2" = 'temp' ];then
getprobetemp
fi
fi
if [ "$func" = 'query' ];then
if [ "$func2" = 'name' ];then
getqueryname
fi
if [ "$func2" = 'temp' ];then
getquerytemp
fi
if [ "$func2" = 'probe' ]; then
getprobeindex
fi
fi
}
#*********************** Main routine ************************************
getnumberofprobes
main
#*********************************************************************** |
And the XML
| Code: |
<interface>
<name>Get all temptrax Data</name>
<description>Queries all temptrax sensors for temp data</description>
<script_path>perl |path_cacti|/scripts/query_temptrax_all.sh</script_path>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<arg_num_indexes>num_indexes</arg_num_indexes>
<arg_prepend>|host_hostname| |host_hostname|</arg_prepend>
<output_delimeter>:</output_delimeter>
<index_order>probe</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>
<fields>
<probe>
<name>Probe</name>
<direction>input</direction>
<query_name>probe</query_name>
</probe>
<name>
<name>Probe Name</name>
<direction>input</direction>
<query_name>name</query_name>
</name>
<temp>
<name>Temp</name>
<direction>output</direction>
<query_name>temp</query_name>
</temp>
</fields>
</interface>
|
It is not great, its in bash, there are routines that are not needed, and it is generally in a bit of a mess.
But i was under alot of pressure to get these working, and the OID are different from one box to another.
I am not a programmer, and only started bash a few weeks ago.
So please go easy on me, i am sure it can be done better, but it does work , and probes all probes on the E4, the E8, and E16
all my temptrax are working on this at present, and i can at least understand it!
I will at some point add another routine for the EM1's and have all temptrax devices in one script!
if it helps someone, then its made me happy!
 |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|