|
|
| Author |
Message |
TheWitness Developer
Joined: 14 May 2002 Posts: 9719 Location: MI, USA
|
Posted: Tue May 24, 2005 4:10 pm Post subject: [HOWTO] Testing the PHP Script Server |
|
|
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  |
|
| Back to top |
|
 |
chris.y2k.r1
Joined: 07 Mar 2006 Posts: 30
|
Posted: Thu Apr 06, 2006 10:13 am Post subject: |
|
|
THAT!!!! Is good to know.
What are the symptoms of a problematic script server..... For us php dummies out there..? |
|
| Back to top |
|
 |
ymartin59
Joined: 17 Feb 2006 Posts: 40
|
Posted: Wed Nov 08, 2006 3:56 am Post subject: |
|
|
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" ? |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9719 Location: MI, USA
|
Posted: Wed Nov 08, 2006 6:58 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
dam11
Joined: 30 May 2007 Posts: 4 Location: Biarritz, France
|
Posted: Mon Jun 11, 2007 8:41 am Post subject: |
|
|
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).
Did I miss another step during the migration ?
Thanks for your answers.
PS : I'm using cacti-0.8.6j under Linux. |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9719 Location: MI, USA
|
Posted: Mon Jun 11, 2007 9:13 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
dam11
Joined: 30 May 2007 Posts: 4 Location: Biarritz, France
|
Posted: Mon Jun 11, 2007 10:21 am Post subject: |
|
|
Okay, I will try to explain
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). |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9719 Location: MI, USA
|
Posted: Mon Jun 11, 2007 11:20 pm Post subject: |
|
|
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
To exit.
TheWitness |
|
| Back to top |
|
 |
dam11
Joined: 30 May 2007 Posts: 4 Location: Biarritz, France
|
Posted: Tue Jun 12, 2007 3:36 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9719 Location: MI, USA
|
Posted: Tue Jun 12, 2007 7:19 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
dam11
Joined: 30 May 2007 Posts: 4 Location: Biarritz, France
|
Posted: Wed Jun 13, 2007 7:31 am Post subject: |
|
|
| Thanks fo your answers, I will continue my investigation... |
|
| Back to top |
|
 |
|