[solved] Problem with Script Server

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

Moderators: Developers, Moderators

Post Reply
Toddles18
Posts: 22
Joined: Fri Feb 20, 2009 1:28 pm

[solved] Problem with Script Server

Post by Toddles18 »

I'm attempting to create a script server script, however I'm getting a u at the end of my results everytime.

I've created an extremely basic test based on the script server walkthrough here http://docs.cacti.net/manual:087:3a_adv ... ipt_server

Here is my ss_test.php file

Code: Select all

<?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:

Code: Select all

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
any idea why I'm getting that U?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

That's which version of cacti? PIA applied and patched?
Reinhard
Toddles18
Posts: 22
Joined: Fri Feb 20, 2009 1:28 pm

Post by Toddles18 »

Cacti Version - 0.8.7d
Plugin Architecture - 2.4
Poller Type - Cactid v
Server Info - Windows NT 6.0
Web Server - Apache/2.2.11 (Win32) PHP/5.2.8
PHP - 5.2.8
PHP Extensions - bcmath, calendar, com_dotnet, ctype, session, filter, ftp, hash, iconv, json, odbc, pcre, Reflection, date, libxml, standard, tokenizer, zlib, SimpleXML, dom, SPL, wddx, xml, xmlreader, xmlwriter, apache2handler, gd, mysql, snmp, sockets, sqlsrv
MySQL - 5.1.31-community
RRDTool - 1.2.26
SNMP - e system cannot find the path specified.
Plugins
  • Global Plugin Settings (settings - v0.5)
    PHP Network Weathermap (weathermap - v0.95b)
    Host Info (hostinfo - v0.2)
    Network Tools (tools - v0.3)
    Login Page Mod (loginmod - v1.0)
    Documents (docs - v0.1)
    Syslog Monitoring (syslog - v0.5.2)
    Update Checker (update - v0.4)
    Router Configs (routerconfigs - v0.1)
It should be all patched. my cacti install is from BSOD's most recent installer.
Toddles18
Posts: 22
Joined: Fri Feb 20, 2009 1:28 pm

Post by Toddles18 »

I figured it out.

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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests