Problem with PHP script

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Problem with PHP script

Post by woueb »

Hello,
I'm facing a huge problem on a Cacti fresh install : all SNMP checks are working fine, but each PHP check return an error

I have these messages in Cacti log file

Code: Select all

10/20/2010 11:55:02 PM - CMDPHP: Poller[0] Host[12] DS[137] SERVER: /var/www/cacti/scripts/ss_netsnmp_memory.php 172.20.1.104:2:mysnmpcommunity:::::::161:500, [b]output: WARNING: Function does not exist[/b]
10/20/2010 11:55:02 PM - CMDPHP: Poller[0] Host[12] DS[137] WARNING: Result from SERVER not valid. Partial Result: WARNING: Function do
10/20/2010 11:55:02 PM - PHPSVR: Poller[0] WARNING: Function does not exist
10/20/2010 11:55:02 PM - PHPSVR: Poller[0] DEBUG: PID[13441] CTR[0] INC: 'ss_netsnmp_memory.php' FUNC: '172.20.1.104:2:mysnmpcommunity:::::::161:500' PARMS: '' 
But when I execute the php from the command line I have a result :

Code: Select all

php -q /var/www/cacti/scripts/ss_netsnmp_memory.php 172.20.1.104:2:mysnmpcommunity:::::::161:500
totalReal:515332 availReal:6420 totalSwap:1048568 availSwap:1027812 memBuffer:20324 memCached:267500 usedReal:221088 usedSwap:20756
Cacti is Version 0.8.7g

Thank You !
Last edited by woueb on Mon Nov 08, 2010 12:12 pm, edited 2 times in total.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with PHP script

Post by gandalf »

Please provide the source code of that script
R.
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

Thank you,
please find the file attached.

All of my PHP scripts provide me the same output.
Attachments
ss_netsnmp_memory.txt
(8.66 KiB) Downloaded 70 times
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

Hello,
I did additionnal testings.

I tried with spine instead of cmd.php, I have the same error.

I tried as another user in the cli, I don't have any error :

Code: Select all

[ (184) 17:58:44 ] server:/var/www/cacti# sudo -u apache php /var/www/cacti/scripts/ss_netsnmp_memory.php 172.20.1.104:2:mysnmpcommunity:::::::161:500
totalReal:515332 availReal:6484 totalSwap:1048568 availSwap:1029060 memBuffer:243852 memCached:106660 usedReal:158336 usedSwap:19508
[ (185) 18:10:57 ] server:/var/www/cacti# sudo -u cacti php /var/www/cacti/scripts/ss_netsnmp_memory.php 172.20.1.104:2:mysnmpcommunity:::::::161:500
totalReal:515332 availReal:6484 totalSwap:1048568 availSwap:1029060 memBuffer:243852 memCached:106660 usedReal:158336 usedSwap:19508
Here are the informations.

Code: Select all

General Information
Date 	Mon, 08 Nov 2010 18:10:18 +0100
Cacti Version 	0.8.7g
Cacti OS 	unix
SNMP Version 	NET-SNMP version: 5.3.2.2
RRDTool Version 	RRDTool 1.4.x
Hosts 	25
Graphs 	52
Data Sources 	Script/Command: 12
SNMP: 51
SNMP Query: 18
Script - Script Server (PHP): 1
Total: 82
Poller Information
Interval 	300
Type 	cmd.php
Items 	Action[0]: 93
Action[1]: 12
Action[2]: 1
Total: 106
Concurrent Processes 	1
Max Threads 	1
PHP Servers 	1
Script Timeout 	25
Max OID 	10
Last Run Statistics 	Time:1.2549 Method:cmd.php Processes:1 Threads:N/A Hosts:26 HostsPerProcess:26 DataSources:106 RRDsProcessed:81
PHP Information
PHP Version 	5.1.6
PHP OS 	Linux
PHP uname 	Linux frademon01.adelis.prod 2.6.18-194.8.1.el5 #1 SMP Thu Jul 1 19:07:06 EDT 2010 i686
PHP SNMP 	Installed
max_execution_time 	120
memory_limit 	128M
Thank you
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with PHP script

Post by gandalf »

Please show us the parameters used when defining this Data Input Method. Did you define a plain script or a script server script?
R.
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

gandalf wrote:Please show us the parameters used when defining this Data Input Method. Did you define a plain script or a script server script?
R.
Hello,
it's a Script - Script Server PHP

And the parameters are :

Code: Select all

<path_cacti>/scripts/ss_netsnmp_memory.php <hostname>:<snmp_ver>:<snmp_community>:<snmp3_username>:<snmp3_password>:<snmp3_authprot>:<snmp3_privpass>:<snmp3_privprot>:<snmp3_context>:<snmp_port>:<snmp_timeout>
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with PHP script

Post by gandalf »

Fine, but I meant to show us a screenshot of the Data Input Method as available under the related menu entry
R.
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

gandalf wrote:Fine, but I meant to show us a screenshot of the Data Input Method as available under the related menu entry
R.
Ok, please find the screenshot attached.

Thank you,
Romain.
Attachments
data-input-method.png
data-input-method.png (26.08 KiB) Viewed 1527 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with PHP script

Post by gandalf »

Please replace ":" by " " for the command definition. When calling the DIM, cacti will append all named parameters, seperated by blanks (not colons).
R.
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

Hello Gandalf,
thank you for the reply : with the same command, but the ":" replaced by " ", I still have the problem.
I don't think I sould remove theses ":".

In the PHP script, I have a line in the beginning.

Code: Select all

$protocol_array = explode(":", $protocol_bundle);
And, if I test with the ":" in the command line, it's working :

Code: Select all

[ (190) 19:27:31 ] server:/var/www/cacti# php /var/www/cacti/scripts/ss_netsnmp_memory.php 172.20.1.104:2:mycommunity:::::::161:500
totalReal:515332 availReal:6332 totalSwap:1048568 availSwap:1029148 memBuffer:260812 memCached:98556 usedReal:149632 usedSwap:19420
woueb
Posts: 8
Joined: Fri Oct 30, 2009 5:40 pm

Re: Problem with PHP script

Post by woueb »

Hello,
I've made additionnal testing.

I've created/reinstalled a new Cacti from scratch.
The problem seems that I'm not able to create RRD file for my PHP script.

Example :

Code: Select all

/usr/bin/rrdtool create /var/www/cacti/rra/fradephp01_apache_cpuload_146.rrd --step 300  DS:apache_cpuload:GAUGE:600:0:100 RRA::0.5:1:600 RRA:AVERAGE:0.5:1:500 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797
ERROR: Unrecognized consolidation function
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with PHP script

Post by gandalf »

RRA::0.5:1:600
misses the consolidation function
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest