Chapter 12. PHP Script Server
The PHP Script Server is a new feature in Cacti 0.8.6. This new feature allows for the rapid execution of PHP based
Data Queries in Cacti. The Script Server process is launched by the poller during every polling cycle. It listens for
commands from the poller, executes them, and then waits for an quit signal.
The reason that it is so fast is that PHP is started in memory only one time, and for every Data Query called, it's code
is interpreted only once. The resulting Data Query binaries are therefore very efficient. Using the Script Server process
over the traditional POPEN process nets a 20+ fold speed improvement in Cacti.
Since PHP scripts are so powerful, this new feature in Cacti, makes it an excellent choice for collecting non SNMP and
SNMP based data.
12.1. Using the Script Server
Cacti 0.8.6 contains two sample script server routines. They are for the collection of HostMib CPU and Disk Partition
information. These two examples are based off the traditional POPEN version of the HostMib functions found in
earlier versions of Cacti.
For new installs, the HostMib functions are defaulted to using the PHP Script Server, therefore, you don't need to do
anything to use it.
For upgrades, you must make several changes to start using the PHP Script Server for the HostMib CPU and HostMib
Partitions Data Queries. To migrate you must follow the step below.
12.2. Upgrade Steps for the Example HostMib Data Queries
If you are using the two built in script queries, "SNMP Get Mounted Partitions" and "SNMP Get Processor Infor
mation", you can migrate to the PHP Script Server using the steps below:
1. Verify the existence of New Data Input Method Go to Data Input Methods, verify that you see the "Get Script
Server Data (Indexed)" Data Input Method exists and that it is using the "Script Query Script Server" method.
2. Disable the Poller Goto Settings >Poller and uncheck the Poller Enabled checkbox. Press Save.
3. Update Your Data Queries Go to Data Queries and Edit the two Data Queries below. Change both their
Data Input Method to "Get Script Server Data (Indexed)" and in the XML path replace "script_query" with
"script_server" as shown below:
a. SNMP Get Mounted Partitions
<
path_cacti
>
/resource/script_server/host_disk.xml
b. SNMP Get Processor Information
<
path_cacti
>
/resource/script_server/host_cpu.xml
4. Update Your Data Templates Goto Data Templates, locate the following two data templates and change their
data input method to "Get Script Server Data (Indexed)".
a. Host MIB Hard Drive Space
b. Host MIB CPU Utilization
5. Re Enable the Poller Go to Settings >Poller and check the Poller Enabled checkbox. Press Save.
Following those steps should complete your migration to the new PHP Script Server for the two example HostMIB
Data Queries.
12.3. Migration of Existing PHP Scripts to Script Server
If you have other PHP scripts that you wish to migrate, you must follow the steps below to migrate your scripts to the
PHP Script Server required format.
27
<
New Page 1
Php Mysql Web Hosting