Cacti 1.2.6 - Script Server - ss_win_mssql.php

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

Moderators: Developers, Moderators

Post Reply
Highway
Posts: 9
Joined: Thu Apr 19, 2007 2:18 pm

Cacti 1.2.6 - Script Server - ss_win_mssql.php

Post by Highway »

My system is running on Centos 7 with PHP 5.4.16, MariaDB 5.5.64.

I've recently upgraded my cacti server to 1.2.6 from 0.8.8h and now executing ss_win_mssql.php results in a NULL output.

Code: Select all

2019/11/04 18:16:41 - SPINE: Poller[1] PID[1036] WARNING: Invalid Response, Device[57] HT[1] DS[1425] SCRIPT: /usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql '10.bb.cc.dd':'1433' bckrsttroughput 'nagios' '############', output:
2019/11/04 18:16:41 - SPINE: Poller[1] PID[1036] Device[57] HT[1] DS[1424] SS[0] SERVER: /usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql '10.bb.cc.dd':'1433' bckrsttroughput 'nagios' '#############', output: U
I tried running it through the script_server.php:

Code: Select all

[root@JAX4CACTI02 cacti]# php script_server.php
PHP Script Server has Started - Parent is cmd
/usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql '10.bb.cc.dd':'1433' bckrsttroughput 'nagios' '################'

The execution just returns a blank line.

However, if I run it manually,

Code: Select all

[root@JAX4CACTI02 cacti]# time php -q /usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php '10.bb.cc.dd':'1433' bckrsttroughput 'nagios' '################'
bckrsttroughput:1353142132736

real    0m5.506s
user    0m0.032s
sys     0m0.018s
On Cacti, I can re-classify the script as a script/command instead of script/server and modify the input string to include 'php -q' at the beginning and it works.

Just trying to understand why it's not working now.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Cacti 1.2.6 - Script Server - ss_win_mssql.php

Post by netniV »

When you run it under script server, you may want to have it turn error logging on in your function call, but also to write log data to a file to ensure that the function is actually being called.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Highway
Posts: 9
Joined: Thu Apr 19, 2007 2:18 pm

Re: Cacti 1.2.6 - Script Server - ss_win_mssql.php

Post by Highway »

Additional Information:

Data Input Method
Windows - SQL Server - Backup/Restore I/O (Script Server)
<path_cacti>/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql <hostname>:<port> bckrsttroughput <user> <password>

Based on the function ss_win_mssql,

Code: Select all

function ss_win_mssql ($hostname, $cmd, $username = NULL, $password = NULL) {
        print "hostname=$hostname | cmd=$cmd | username=$username | password=$password\n"; # debugging purposes
        list($host, $port) = explode(':', $hostname);
        $port = ($port == '' ? '1433' : $port);
        $username = ($username == NULL ? 'cactistats' : $username);
        $password = ($password == NULL ? 'CHANGEME' : $password);

        $ret = '';

        if (! $link = mssql_connect($host.':'.$port, $username, $password) )
                return;

        list($server_version) = mssql_fetch_row(mssql_query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)"));
.
.
.
The parameter hostname is supposed to be both host and port separated by a colon. When I instructed the script to print out the hostname, all I get is the IP address with no port association.

Code: Select all

2019/11/06 18:15:36 - SPINE: Poller[1] PID[4007] WARNING: Invalid Response, Device[61] HT[1] DS[1460] SCRIPT: /usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql '10.bb.cc.dd':'1433' bckrsttroughput 'nagios' '############', output: hostname=10.bb.cc.dd | cmd=:1433
2019/11/06 18:15:36 - ERROR PHP NOTICE: Undefined offset: 1 in file: /var/lib/cacti/scripts/custom-scripts/ss_win_mssql.php  on line: 19
2019/11/06 18:15:36 - ERROR PHP WARNING: mssql_connect(): message: Login failed for user 'bckrsttroughput'. (severity 14) in file: /var/lib/cacti/scripts/custom-scripts/ss_win_mssql.php  on line: 26
When I run it through the script_server.php, the output is as expected.

Code: Select all

bash-4.2$ php -q /usr/share/cacti/script_server.php
PHP Script Server has Started - Parent is cmd
/usr/share/cacti/scripts/custom-scripts/ss_win_mssql.php ss_win_mssql 10.bb.cc.dd:1433 bckrsttroughput nagios ###########
hostname=10.bb.cc.dd:1433
bckrsttroughput:2971591786496
[code]

It's the automation that doesn't seem to be passing the parameters correctly.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests