Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Mon Jun 26, 2017 2:03 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: [HOWTO] Testing the PHP Script Server
PostPosted: Tue May 24, 2005 4:10 pm 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
All,

If you are having problems with the PHP Script Server, please follow the instructions below:

1) Start PHP Script Server

Use the following command to start the script server: "php <path_cacti>/script_server.php"

You wll receive a message from PHP indicating "PHP Script Server Started Properly". If you get any warning messages, then you have to fix them right away.

2) Obtain a Script Command from the Poller Cache

a) To do this Goto System Utilities->View Poller Cache
b) Search for "Action: 2"
c) Copy the portion of the script starting with the full path and working
to the end of line. For example:
Quote:
c:\wwwroot\cacti086\scripts\ss_host_cpu.php ss_host_cpu localhost public 2 161 500 get usage 0


3) Execute the Script Server Command

Paste the command from 2c into your Script Server window and press enter.

You should receive an output statement. If not, please correct any warnings or script errors before proceeding.

4) To End the Script Server session

Type "quit" in the Script Server window and press enter.

Important Note:
For older versions of PHP < 4.3.3, you should be able to execute the command cut from setp 2c directly to a command line prefixed by "php" and run that script stand alone.

TheWitness :D

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:13 am 
Offline

Joined: Tue Mar 07, 2006 11:39 pm
Posts: 31
THAT!!!! Is good to know.

What are the symptoms of a problematic script server..... For us php dummies out there..?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 3:56 am 
Offline

Joined: Fri Feb 17, 2006 7:42 am
Posts: 40
Hello,
I would like to know what are advantages of the method "script server" compared to "snmp query" ?
When I compare "net-snmp_disk.xml" description and "ss_host_disk.php" design, and according to the poller cache information, I think the "net-snmp_disk" should be faster to process than script server 'host_disk" because cmd.php or cactid can collect value from a single OID directly without invoking a script. Am I right ?

When designing a new data collector, is it better to use "snmp query" (when possible of course ) or "script server" ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 6:58 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
SNMP Queries will always be orders of magnitude faster especially using Cactid due to the fact that we are using RAW protocol with SNMP vs. a script that essentially does the same. The Script Server speeds up scripts when compared to a native shell or perl call however.

TheWitness

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 8:41 am 
Offline

Joined: Wed May 30, 2007 2:39 am
Posts: 4
Location: Biarritz, France
Hello,

I've got a problem with the migration from an existing PHP script to Script Server method, I just follow the doc steps ("Migration of Existing PHP Scripts to Script Server") and my graphs are stopped (nothing in the poller cache).
So, I have to manually create new graphs with the script server method, it goes very well (results tested with the CLI script_server.php are right compared to stand alone script).
The opposite transition works fine (from stand alone script to script server). :o
Did I miss another step during the migration ?

Thanks for your answers.

PS : I'm using cacti-0.8.6j under Linux.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 9:13 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
I would have to see specificatlly what you did. It does work though. Prior to migration, you should always test your script as both script and non-script. The nice thing about the script itself, it should work both ways. Once you have that done, and graphing, you can change your data input method to be script server. Last step is to re-populate your poller cache.

TheWitness

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 10:21 am 
Offline

Joined: Wed May 30, 2007 2:39 am
Posts: 4
Location: Biarritz, France
Okay, I will try to explain :wink:
This is the verbose query for qos_plug.php :
Code:
+ Running data query [10].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/public/cacti/resource/script_queries/class_qos.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /var/www/public/cacti/scripts/qos_plug.php class *.*.*.* comm 2 index'
+ Executing script query '/usr/bin/php -q /var/www/public/cacti/scripts/qos_plug.php class *.*.*.* comm 2 query index'
....

Here a request from poller cache :
Code:
Script: /usr/bin/php -q /var/www/public/cacti/scripts/qos_plug.php class  *.*.*.* comm 2 get cbQosCMDropByte 2.class-default
RRD: /var/www/public/cacti/rra/routeur_cisco_1_cmpostpolicybyte_76.rrd


And this is the verbose query for ss_qos_plug.php :
Code:
+ Running data query [10].
+ Found type = '6 '[script query].
+ Found data query XML file at '/var/www/public/cacti/resource/script_server/class_qos.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /var/www/public/cacti/scripts/ss_qos_plug.php class *.*.*.* comm 2 index'
+ Executing script query '/usr/bin/php -q /var/www/public/cacti/scripts/ss_qos_plug.php class *.*.*.* comm 2 query index'
....

Poller :
Code:
Script Server: /var/www/public/cacti/scripts/ss_qos_plug.php ss_qos_plug class *.*.*.* comm 2 get cbQosCMDropByte 2.class-default
RRD: /var/www/public/cacti/rra/routeur_cisco_1_cmpostpolicybyte_76.rrd


112 items, 16 rows in the two cases. There is no difference between the results.
When the ss_qos_plug.php is running and when I change to qos_plug.php, there is no problem, Cacti continue to graph, the poller cache is correctly rebuilt.

But in the other direction, when I rebuild poller cache, nothing happens (the poller requests disappear), so I have to delete Data Sources and create new graphs with old rrd files (to keep history).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 11:20 pm 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
The "plller" quote you showed is actually the "poller cache". So from that, it would, in fact, appear to be being added. However, it is likely not running for some reason. Have you tested outside of the poller yet:

The scneario would be as follows:

Code:
cd /var/www/html/cacti
php -q script_server.php


Response would be "Scrpt Server Started, Parent is cmd.php"

Then enter:

Code:
/var/www/public/cacti/scripts/ss_qos_plug.php ss_qos_plug class *.*.*.* comm 2 get cbQosCMDropByte 2.class-default


Response should be, what you expect, on 1 line not empty lines. Then type

Code:
quit


To exit.

TheWitness

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 3:36 am 
Offline

Joined: Wed May 30, 2007 2:39 am
Posts: 4
Location: Biarritz, France
I already followed this scenario and the result seems to be right, no empty line, no other character, just the requested value.

That's the cacti log for the two scripts :

Quote:
CMDPHP: Poller[0] Host[2] DS[77] SERVER: /var/www/public/cacti/scripts/ss_qos_plug.php ss_qos_plug class *.*.*.* comm 2 get cbQosCMPrePolicyByte 2.class-default, output: 1492297591

Quote:
CMDPHP: Poller[0] Host[6] DS[109] CMD: /usr/bin/php -q /var/www/public/cacti/scripts/qos_plug.php class *.*.*.* comm 2 get cbQosCMPrePolicyByte 2.class-default, output: 1492323609


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 7:19 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
So, everything "should" be working. Do you see any issues when you run "php -q poller.php" from a command line? If you get that information in your log, then the only thing to break the graph would be an rrdupdate issue that you would be able to see by running "php -q poller.php".

TheWitness

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 7:31 am 
Offline

Joined: Wed May 30, 2007 2:39 am
Posts: 4
Location: Biarritz, France
Thanks fo your answers, I will continue my investigation...


Top
 Profile  
 
 Post subject: Re: [HOWTO] Testing the PHP Script Server
PostPosted: Mon Apr 03, 2017 5:13 am 
Offline

Joined: Wed May 04, 2016 7:56 am
Posts: 15
Hi,

I have a system on Cacti 0.8.8a in VM environment. I have created a clone of the same and upgraded Cacti from 0.8.8a to 0.8.8d on it. After upgrade every thing is working fine except few script server queries. I am getting NAN value on all the graphs that are getting data from these script server queries. On my Cacti 0.8.8a server when I tested poller cache query manually I got correct result against a get query (see below).

Quote:
[root@seth cacti]$php script_server.php
PHP Script Server has Started - Parent is cmd
/tools/cacti-0.8.8a/scripts/ss_globalStats.php ss_globalStats TEST-01 2413 get ActiveEpsBearer global
608896
quit
PHP Script Server Shutdown request received, exiting


But when I tried same test on new Cacti version on clone system.

Quote:
PHP Script Server has Started - Parent is cmd
/tools/cacti-0.8.8d/scripts/ss_globalStats.php ss_globalStats TEST-01 2413 get ActiveEpsBearer global

quit
PHP Script Server Shutdown request received, exiting
608966You have mail in /var/spool/mail/root


So here result of get is coming after "quit", don't know why. This has resulted NAN value on all the graphs.
Is there any problem with my below code?

Please help me to troubleshoot this issue.

Code:
        } elseif ($cmd == "get") {
                $arg = $arg1;
                $index = $arg2;

                foreach ( $arrmeasInfo as $measInfo ) {

                        //print_r(${$measInfo.'_values'});

                        if ( isset(${$measInfo.'_types'}[$arg]) ) {
                                print ${$measInfo.'_values'}[${$measInfo.'_types'}[$arg]][$index];
                        }
                }
        } else {
        }


I am using below:

Cacti 0.8.8d
Spine 0.8.8a [0.8.8d did not worked after compilation so I have used old spine 0.8.8a as per suggestion from a Cacti forum]
Plugin Architecture Version: 3.1
Cacti Multipoller server 0.8.8d


Top
 Profile  
 
 Post subject: Re: [HOWTO] Testing the PHP Script Server
PostPosted: Mon May 08, 2017 9:15 am 
Offline

Joined: Wed May 04, 2016 7:56 am
Posts: 15
It has been resolved now after changing the print command with return. It was working on Cacti 0.8.8a but now need to use return for "get" function in the server script on Cacti 0.8.8d or Cacti 0.8.8e. Now this issue is resolved.


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 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