Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
<?php
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
/* display No errors */
error_reporting(0);
if (isset($config)) {
include_once(dirname(__FILE__) . "/../lib/snmp.php");
}
if (!isset($called_by_script_server)) {
include_once(dirname(__FILE__) . "/../include/global.php");
include_once(dirname(__FILE__) . "/../lib/snmp.php");
array_shift($_SERVER["argv"]);
print call_user_func_array("test", $_SERVER["argv"]);
}
function test() {
$a = 100;
$b = $a / 10;
Print $b;
}
?>
and here are the results when I run it through the command line:
C:\Users\admstatmon>php d:\apache2.2\htdocs\cacti\script_server.php
PHP Script Server has Started - Parent is cmd
d:\apache2.2\htdocs\cacti\scripts\ss_test.php test
10U
quit
PHP Script Server Shutdown request received, exiting
the Script Server doesn't care about anything that is directly printed from within the function. It needs the values to be returned.
Changing it from print $b; to return $b fixes it.
Technical Support
General Information
Date Wed, 02 Mar 2016 13:35:32 -0500
Cacti Version 0.8.8f
Cacti OS win32
SNMP Version NET-SNMP version: 5.5
RRDTool Version RRDTool 1.4.x
Hosts 4
Graphs 34
Data Sources Script - Script Server (PHP): 16
Script Query - Script Server: 18
Total: 34
Poller Information
Interval 60
Type cmd.php
Items Action[2]: 72
Total: 72
Concurrent Processes 8
Max Threads 4
PHP Servers 4
Script Timeout 25
Max OID 10
Last Run Statistics Time:12.0814 Method:cmd.php Processes:8 Threads:N/A Hosts:5 HostsPerProcess:1 DataSources:72 RRDsProcessed:30
PHP Information
PHP Version 5.5.20
PHP OS WINNT
PHP uname Windows NT MIHQDBMONITOR01 6.3 build 9200 (Windows Server 2012 R2 Standard Edition) AMD64
PHP SNMP Installed
max_execution_time 60
memory_limit 512M