Remote monitoring with SSH

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

Moderators: Developers, Moderators

Post Reply
Thorinson
Posts: 2
Joined: Tue Feb 15, 2005 12:33 pm

Remote monitoring with SSH

Post by Thorinson »

Hi,

I'm new to Cacti and have already searched the whole forum but can't find any solution for my SSH problem.

I'm trying to get disk space data from a remote-host using SSH and a perl script. All machines are running under linux.
If I call the command "/usr/bin/ssh root@aHost -C /usr/local/cacti/scripts/diskused.pl aPartition" at the shell, it returns the right values (total:12345678 used:23456789). Using Cacti the following can be read in my cacti.log:
"WARNING: Result from CMD not valid. Partial Result:
CMD: /usr/bin/ssh root@aHost -C /usr/local/cacti/scripts/diskused.pl /, output: U".
I've checked the Maximum Value of my Data Source Item, but it's big enough to hold the returned value.

Here's the perl script:

Code: Select all

#!/usr/bin/perl

$ret = `df --block-size=1024 -P $ARGV[0] | grep -v Filesystem`;
$ret =~ s/($ARGV[0])(.* )(.*[0-9])(.* )(.*[0-9])(.* )(.*[0-9])(.* )(.*[0-9])%(.* )//;

print "total:$3 used:$5";
What could be the problem ?

Tnx in advance,
Thorinson
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Check that the user that the poller is running as has the public private keys setup and that there is an entry in known_hosts for that users. Otherwise, it could be prompting, either to save the host key, or for a password.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Thorinson
Posts: 2
Joined: Tue Feb 15, 2005 12:33 pm

Post by Thorinson »

I've already placed a public key on that host and as I mentioned above the command works when using the shell. There's no promting, neither for a key, nor for a password. It must be another problem ... but tnx.
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

You may want to add in the full path to df and grep in your script.

If that doesn't work, a couple debugging tricks you can try are adding an

Code: Select all

`/usr/bin/touch /tmp/ssh-works`;
Then wait a polling interval, if that file's in /tmp afterwards then ssh works.

And what you could do at that point is write a quick wrapper that calls your ssh command, outputting to a file, and then cats the last line of that file (which should be your print command.) like:

Code: Select all

#!/bin/sh
/usr//bin/ssh  user@host -C /usr/local/cacti/scripts/diskused.pl / 2>&1 > /tmp/sshoutput
tail -1 /tmp/sshoutput
And if it works, it works. if not, you've got the full output saved in a file that you can view. Dirty, but should be helpful
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest