Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue May 30, 2017 2:31 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: php script for pcmeasure to run in cacti
PostPosted: Tue Apr 19, 2005 3:45 am 
Offline
Cacti User
User avatar

Joined: Tue Feb 01, 2005 11:34 am
Posts: 60
Here is a little script to get snmp data from the ethernetbox of pcmeasure.
It is designed to run from cactid.

Code:
<?php
if($argv[1] != '' && $argv[2] != '' && $argv[3] != ''){
   $hip = $argv[1];
   $com = $argv[2];
   $sen = $argv[3];
   $max_sensors = 12;
   if($sen > $max_sensors){
      echo "No Data from sensor ".($sen).". Number of sensors: ".$max_sensors." ";
   }else{
      $data = snmpget($hip, $com, ".1.3.6.1.4.1.14848.2.1.2.1.5.".$sen);
      $data = $data/10;
      echo "data:".$data;
   }
      
}else{
   echo "Usage: <path2php>\php\cli\php.exe <path2script>\messpc.php <ipAdr> <snmpcommunity> <sensor>"."\n";
   echo "Example: E:\php\cli\php.exe E:/inetpub/mrtgroot/cacti/scripts/messpc.php 192.168.13.250 pub 1";
}
?>


GreeZ ahab


Last edited by cpt_ahab on Tue Jul 12, 2005 9:28 am, edited 4 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 9:25 am 
Offline

Joined: Thu Jun 30, 2005 9:23 am
Posts: 27
Location: Austria
hi, thx for the script

Please, can you make also a graph Template for this? I´m new @ cacti und I need to control two measure ethernet boxes.

Thx


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 9:17 am 
Offline
Cacti User
User avatar

Joined: Tue Feb 01, 2005 11:34 am
Posts: 60
Here is is... :D

GreeZ ahab


Attachments:
File comment: In this Textfile is the xml-code for the cacti graphtemplate of the pc measure-box. Both Humidity and Temperature
pcmeasure_tmpl.txt [17.23 KiB]
Downloaded 3718 times
Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 5:44 am 
Offline

Joined: Wed Apr 27, 2005 3:08 am
Posts: 8
Hey there... i dont get this script working...

For me everything looks fine, and the poller cache shows me the following line

Code:
Data Source: Redheat - EinSensor
RRD: /srv/www/cacti/rra/messpc_data_232.rrd
Action: 1, Script: php /srv/www/cacti/scripts/messpc1.php 172.16.1.1 public 1


In cacti.log i found these entrys in 'DEBUG' mode:

Code:
02/21/2007 01:52:09 AM - CMDPHP: Poller[0] DEBUG: SQL Exec: "insert into poller_item (local_data_id,host_id,action,hostname,   snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,   rrd_num,arg1,arg2,arg3) values (232,40,1,'172.16.1.1',   'public','2','500',   '','','161',   'data','/srv/www/cacti/rra/messpc_data_232.rrd',   '1','php /srv/www/cacti/scripts/messpc1.php 172.16.1.1 public 1','','')"


and

Code:
02/21/2007 11:22:34 AM - WEBLOG: Poller[0] CACTI2RRD: /usr/bin/rrdtool graph -  --imgformat=PNG  --start=-86400  --end=-300  --title="Redheat - EinSensor"  --base=1000  --height=120  --width=500  --alt-autoscale-max  --lower-limit=-10  --vertical-label="Temperatur"  --slope-mode  --font TITLE:8:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf  --font AXIS:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf  --font LEGEND:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf  --font UNIT:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf  DEF:a="/srv/www/cacti/rra/messpc_data_232.rrd":data:AVERAGE  LINE3:a#FF3932:"


Each time the poller runs this entry appears in the log but nothing else for this host:

Code:
02/21/2007 12:06:51 PM - CMDPHP: Poller[0] DEBUG: SQL Exec: "update host set  status = '1',  status_event_count = '24429',  status_fail_date = '0000-00-00 00:00:00',  status_rec_date = '0000-00-00 00:00:00',  status_last_error = 'Host did not respond to SNMP',  min_time = '9.99999',  max_time = '0.00000',  cur_time = '0.00000',  avg_time = '0.00000',  total_polls = '24430',  failed_polls = '24430',  availability = '0'  where hostname = '172.16.1.1'"


Where can i start to find the problem??
The graph is still there but with NaN ...

Running the poller cache line

Code:
php /srv/www/cacti/scripts/messpc1.php 172.16.1.1 public 1


print the following output

Code:
data:18


Anyone has same problems or can help me??

Cacti Variables
Version 0.8.6h
Operating System: unix
PHP SNMP Support: yes

Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 3:47 am 
Offline
Cacti User
User avatar

Joined: Tue Feb 01, 2005 11:34 am
Posts: 60
Hello

Try to run cacti with MEDUIM Logging. DEBUG is too much.

You should see a line like
Code:
02/27/2007 09:41:03 AM - CACTID: Poller[0] Host[110] DS[793] SCRIPT: /usr/bin/php /var/www/html/cacti/scripts/messpc1.php 192.168.xxx.xxx public 5, output: data:19


You can grep the line easyly out of the cacti.log file,
Or just do a text search with you browser, while viewing it.

If you also see a number after the "data:" field then the script is run right.
Then the problem is about putting the data into the database.

Also try to clear the Pollercache.
System Utilities --> Clear Pollercache

greez ahab


edit: always run the php-binary with its full path.
change php to /usr/bin/php or wherever you php is.
if you dont know run
Code:
whereis php

_________________
cacti 0.8.6j ** cactid 0.8.6d ** rrdtool 1.2.15
Debain ** Apache 2 ** PHP 4.3.0


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 8:38 am 
Offline

Joined: Wed Apr 27, 2005 3:08 am
Posts: 8
Hey!

Okay, i


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 8:39 am 
Offline

Joined: Wed Apr 27, 2005 3:08 am
Posts: 8
Hey!

Okay, i


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 8:40 am 
Offline

Joined: Wed Apr 27, 2005 3:08 am
Posts: 8
Hey!

Okay, i undo all my work for messpc...
Started to import the templates again, created a new device

From this device i get

    SNMP error
Thats okay i think...

Than i created a graph out of the device page

A Look in the Data Source tells me:

    /usr/bin/rrdtool create \
    /srv/www/cacti/rra/messpc_data_235.rrd \
    --step 300 \
    DS:data:GAUGE:600:0:U \
    RRA:AVERAGE:0.5:1:600 \
    RRA:AVERAGE:0.5:6:700 \
    RRA:AVERAGE:0.5:24:775 \
    RRA:AVERAGE:0.5:288:797 \
    RRA:MIN:0.5:1:600 \
    RRA:MIN:0.5:6:700 \
    RRA:MIN:0.5:24:775 \
    RRA:MIN:0.5:288:797 \
    RRA:MAX:0.5:1:600 \
    RRA:MAX:0.5:6:700 \
    RRA:MAX:0.5:24:775 \
    RRA:MAX:0.5:288:797 \
    RRA:LAST:0.5:1:600 \
    RRA:LAST:0.5:6:700 \
    RRA:LAST:0.5:24:775 \
    RRA:LAST:0.5:288:797 \


But a look in the Graph i see this Debug info:


[list] RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Redheat - EinSensor" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=-10 \
--vertical-label="Temperatur" \
--slope-mode \
--font TITLE:8:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf \
--font AXIS:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf \
--font LEGEND:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf \
--font UNIT:7:/usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf \
DEF:a="/srv/www/cacti/rra/messpc_data_235.rrd":data:AVERAGE \
LINE3:a#FF3932:"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 10:49 am 
Offline
Cacti User
User avatar

Joined: Tue Feb 01, 2005 11:34 am
Posts: 60
SNMP Error is ok. I get this one too.

The Datasource looks ok also,
but the graph is different.
SNMP Error is ok. I get this one too.

The Datasource looks ok also,
but the graph is different.
Mine looks like this
Code:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Hitzkopf - BGS-Serverraum - Temp" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=-10 \
--vertical-label="Temperatur" \
--slope-mode \
Some lines are missing because the forum cuts my post otherwise


check if your downed host detection is set to ping only.
settings --> poller
if cacti doesnt get some snmp data from the host,
it thinks the host is down and doesnt run the scripts.

_________________
cacti 0.8.6j ** cactid 0.8.6d ** rrdtool 1.2.15
Debain ** Apache 2 ** PHP 4.3.0


Top
 Profile  
 
 Post subject: Re: php script for pcmeasure to run in cacti
PostPosted: Thu Mar 15, 2007 1:50 pm 
Offline

Joined: Thu Mar 15, 2007 1:37 pm
Posts: 1
Hi Ahab

Code:
<?php
if($argv[1] != '' && $argv[2] != '' && $argv[3] != ''){
   $hip = $argv[1];
   $com = $argv[2];
   $sen = $argv[3];
   $max_sensors = 12;
   if($sen > $max_sensors){
      echo "No Data from sensor ".($sen).". Number of sensors: ".$max_sensors." ";
   }else{
      $data = snmpget($hip, $com, ".1.3.6.1.4.1.14848.2.1.2.1.5.".$sen);
      $data = $data/10;
      echo "data:".$data;
   }
      
}else{
   echo "Usage: <path2php>\php\cli\php.exe <path2script>\messpc.php <ipAdr> <snmpcommunity> <sensor>"."\n";
   echo "Example: E:\php\cli\php.exe E:/inetpub/mrtgroot/cacti/scripts/messpc.php 192.168.13.250 pub 1";
}
?>


Many thanks for that - one question: isn't snmpget() supposed to have a version in the string, in order to work?

like the commandline :
snmpget 192.168.xxx.xxx -v 1 -c public 1.3.6.1.4.1.14848.2.1.2.1.5.1

which returns correctly:
SNMPv2-SMI::enterprises.14848.2.1.2.1.5.1 = INTEGER: 243

if i run php messpc.php 192.168.xxx.xxx public 1 in a shell, it returns
data:0

any idea if there is the snmp-version missing?

i do have a most recent ethernetbox with 2 temperature sensors (no humid) and a smoke detector.

cacti is 8.6, php 4.4.x on debian sarge 2.6.x

regards
simons


Top
 Profile  
 
 Post subject: php script for pcmeasure to run in cacti
PostPosted: Tue Mar 20, 2007 8:06 am 
Offline

Joined: Tue Mar 20, 2007 6:26 am
Posts: 1
The snmpget() in the php script returns everything after the "=" from the commandline snmpget. So when you $data/10; the result is 0 (because it not just the integer). If you remove the $data=$data/10; you will see the result like "INTEGER: 722".


Top
 Profile  
 
 Post subject: Re: php script for pcmeasure to run in cacti
PostPosted: Wed Nov 17, 2010 1:54 am 
Offline

Joined: Thu Oct 21, 2010 3:08 am
Posts: 3
Location: Germany Rösrath
Schönen guten Tag,

ich bräuchte auch einem Hilfe ! Ich habe die Templates für die Temperatur in eine eigene XML gepackt und hinzugefügt.

Dann habe ich unter DATA Sources einen Graf erstellt it diesem Redhead. mehr noch nicht.

Dann muss man ja die 3 Punkte

Index des Sensors
Snmp Community von Redheat
IP-Adresse von REDHEAT

ausfüllen. Nur wal muss ich als Index eintragen wenn ich den Port 1 ( Temperatur des Raumes) habe?

Bitte ich brauche das dringend.

Hier aus dem Log der Fehler

Code:
11/17/2010 07:57:57 AM - CMDPHP: Poller[0] WARNING: SNMP Get Timeout for Host:'35.101.11.150', and OID:'.1.3.6.1.2.1.1.1.0'


Top
 Profile  
 
 Post subject: Re: php script for pcmeasure to run in cacti
PostPosted: Fri Nov 19, 2010 3:29 am 
Offline

Joined: Thu Oct 21, 2010 3:08 am
Posts: 3
Location: Germany Rösrath
Ok fehler behoben. !!! die PHP datei muss angepasst werden. WErde den Quelltext mal Posten wenn Ihn einer braucht.

Ok I found the false !!! You must change something in the PHP File. I Could Post it when Somebody need this.

Sorry for my bad English :)

Schparc


Top
 Profile  
 
 Post subject: Re: php script for pcmeasure to run in cacti
PostPosted: Fri Mar 09, 2012 11:40 am 
Offline

Joined: Fri Mar 09, 2012 11:33 am
Posts: 1
Does anyone maybe have a nice step by step PDF like "how to add pcmeasure in cacti"

i've imported the templates but i dont know how to handle it...
i recieve nice responses when i test it with the snmpwalk.


PS: im running linux (redhat with cacti 0.8.7h)

thanks


Top
 Profile  
 
 Post subject: Re: php script for pcmeasure to run in cacti
PostPosted: Mon Mar 26, 2012 2:07 am 
Offline
Cacti Guru User

Joined: Thu Aug 05, 2010 2:04 am
Posts: 1573
Location: Japan
mischu wrote:
Does anyone maybe have a nice step by step PDF like "how to add pcmeasure in cacti"

i've imported the templates but i dont know how to handle it...
i recieve nice responses when i test it with the snmpwalk.


PS: im running linux (redhat with cacti 0.8.7h)

thanks

1) Import the template
2) Place the script (messpc1.php) at scripts/ directory
3) In 'Data Input Methods -> Redheat - EinSensor', change the script path from "E:\\php\\cli\\php.exe" to "php"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: kubix42, yelti and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group