spine 0.8.7g not returning a script result

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

From CLI:

Code: Select all

/usr/bin/perl /webroot/cacti-0.8.7g/scripts/openldap_operations.pl -h 192.168.1.1 -p 389 -D uid=me,dc=myldap -W  secret-password -t 5 -v 3
bind-initiated:262734 bind-completed:262734 unbind-initiated:53423 unbind-completed:53423 search-initiated:929400 search-completed:929399 compare-initiated:17 compare-completed:17 modify-initiated:0 modify-completed:0 modrdn-initiated:0 modrdn-completed:0 add-initiated:0 add-completed:0 delete-initiated:0 delete-completed:0 abandon-initiated:0 abandon-completed:0 extended-initiated:273291 extended-completed:273291 
from cacti.log:

Code: Select all

10/01/2010 11:37:02 PM - SPINE: Poller[0] Host[15] TH[1] DS[305] SCRIPT: perl /webroot/cacti-0.8.7g/scripts/openldap_operations.pl -h 192.168.1.1 -p 389 -D uid=me,dc=myldap -W  secret-password -t 5 -v 3, output: 0
User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

Should this work?

Code: Select all

<path_php_binary> -q <path_cacti>/scripts/ss_get_mysql_stats.php --host <hostname> --items a8,a9 --user <username> --pass <password> --port <port>
or do I need to change <path_php_binary> to /usr/bin/php for all the mysql Data Input Methods?
User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

I had the hostname set to something other than localhost in the device that is configured to graph the MySQL information so the scripts were not able to connet to mysqld.
I apologize for the wild goose chase. The mysql scripts are now working properly.

It was mentioned that there is an easy fix for the openldap_operations.pl script.

What would that be?

Thanks you for your help.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: spine 0.8.7g not returning a script result

Post by TheWitness »

Echo everything in one echo statement and not in multiple. That is a requirement per the documentation. I don't wait on EOF to close the script. So, you have one chance to output. Spine takes no prisoners.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

TheWitness wrote:Echo everything in one echo statement and not in multiple. That is a requirement per the documentation. I don't wait on EOF to close the script. So, you have one chance to output. Spine takes no prisoners.
I'm no Perl expert, but it looks like that is what the script is doing. This is the bottom part of the openldap_operations.pl Perl script:

Code: Select all

foreach ($search->entries) {
        my $cn = lc($_->get_value('cn'));
        my $initiated = $_->get_value('monitorOpInitiated');
        my $completed = $_->get_value('monitorOpCompleted');
        $initiated = "U" unless defined $initiated;
        $completed = "U" unless defined $completed;
        print "$cn-initiated:$initiated ";
        print "$cn-completed:$completed ";
}

print "\n";
which outputs the following from command line. It looks like everything is printed out successively without a linebreak until the very end before the script exits.

Code: Select all

[cactiuser@webserver scripts]$ perl /webroot/cacti-0.8.7g/scripts/openldap_operations.pl -h 192.168.1.1 -p 389 -D uid=mel,dc=gus -W  password -t 5 -v 3
bind-initiated:364216 bind-completed:364216 unbind-initiated:60473 unbind-completed:60473 search-initiated:1156259 search-completed:1156258 compare-initiated:18 compare-completed:18 modify-initiated:3 modify-completed:3 modrdn-initiated:0 modrdn-completed:0 add-initiated:1 add-completed:1 delete-initiated:0 delete-completed:0 abandon-initiated:0 abandon-completed:0 extended-initiated:377302 extended-completed:377302 
[[cactiuser@webserver scripts]$
I believe the output appears on 3-4 lines because it is getting wrapped in my terminal.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: spine 0.8.7g not returning a script result

Post by TheWitness »

To make it work in spine, there should only be 1 print statement in the whole file. So, assign the output in the loop to a variable and at the very end, echo to the terminal using a print of that variable.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

OK I modified the script to create an empty string, loop through all variables, append each one to the string, and then print the string ONCE before exiting:

Code: Select all

my $stuff = "";
foreach ($search->entries) {
        my $cn = lc($_->get_value('cn'));
        my $initiated = $_->get_value('monitorOpInitiated');
        my $completed = $_->get_value('monitorOpCompleted');
        $initiated = "U" unless defined $initiated;
        $completed = "U" unless defined $completed;
        $stuff = $stuff . "$cn-initiated:$initiated " . "$cn-completed:$completed ";
}
print "$stuff";
The output looks Ok on the command line, but SPINE poller is still complaining about an empty result.

Code: Select all

10/06/2010 12:04:02 PM - SPINE: Poller[0] Host[15] Description[bl1231] ERROR: Empty result [blah]: 'usr/bin/perl /webroot/cacti-0.8.7g/scripts/openldap_operations.pl -h 192.168.1.1 -p 389 -D uid=me,dc=us -W passwordt -t 5 -v 3
[/color]
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: spine 0.8.7g not returning a script result

Post by TheWitness »

Your missing the first slash on "/usr/bin/perl".

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
classen
Cacti User
Posts: 116
Joined: Thu Nov 12, 2009 3:07 pm

Re: spine 0.8.7g not returning a script result

Post by classen »

doh :oops:
The openldap script is now working.
Thanks so much for your help.
laerg
Posts: 19
Joined: Sat Jul 02, 2005 7:12 pm

Re: spine 0.8.7g not returning a script result

Post by laerg »

TheWitness wrote:Echo everything in one echo statement and not in multiple. That is a requirement per the documentation. I don't wait on EOF to close the script. So, you have one chance to output. Spine takes no prisoners.

TheWitness
'lo,

I've also just upgraded spine and cacti to 0.8.7g ... I couldn't find any mention of this new "only 1 print statement" in the Changelog, maybe you're referring to other documentation ? I've had to adapt some of the perl scripts after upgrading, some of them even improved a bit !

spine multithreading is great btw :)

grtz,
gert
vpanos
Posts: 4
Joined: Fri Nov 05, 2010 12:24 am

Re: spine 0.8.7g not returning a script result

Post by vpanos »

I am using cacti spine 0.8.7 compiled from source and also had problems with openldap_operations.pl and another shell script.

The problem with both scripts was the trailing space in the output of the scripts, it was something like that "bind-initiated:... completed:0 ". When I changed the scripts to remove that space character it was ok.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest