0

I would like to ask you for any hint regarding following issue.

I'm using external scripts for checks in Zabbix 2.2. I try to develop some script which will get timestamp of certain file on remote storage. The script is working fine in CLI of the Zabbix server, but in Zabbix I see 0 (zero) value only.

I identified that the main issue is in the line with ssh command where I try to connect to remote storage and get the information.

The scripts look like:

TIMESTAMP_REMOTE_FILE=$(ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -i $KEY_FILE "$REMOTE_USER"@"$HOSTNAME" "stat --format='%Y' $FILE ") echo TIMESTAMP_REMOTE_FILE 

The output in linux console looks like:

[user1@hostname1 externalscripts]$ sudo -u zabbixsrv ./days_since_last_backup.sh 1436745682 [user1@hostname1 externalscripts]$ 

But in Zabbix (Latest values) it looks like:

Timestamp Value 2015.Jul.13 15:04:25 0 

When I change the value TIMESTAMP_REMOTE_FILE for some certain value (example 100000), the value is visible in Zabbix as well.

Timestamp Value 2015.Jul.13 16:04:25 100000 

Have somebody been facing the same issue like me? Has got somebody any hint how to solve it?

6
  • Are you sure you passed the correct file name in zabbix? Commented Jul 13, 2015 at 15:28
  • Are sure that item setting "Type of information" is text? Commented Jul 13, 2015 at 15:37
  • Are you sure, that the zabbix user has the permission to access the ssh keyfile? Commented Jul 13, 2015 at 15:56
  • yes, I'm sure that zabbix is using the key file - in case that I change the permissions or ownership then the script is asking for password of the key (AFAIK because he cannot access it correctly). Commented Jul 14, 2015 at 7:04
  • To Jan Garaj: yes, in Zabbix I'm using for debugging purposes type of information as text. I expect that when the script will be executed correctly, I will change it. Commented Jul 14, 2015 at 7:06

1 Answer 1

0

So I examined the described issue more in deep. I've enabled logging on to file by using

TIMESTAMP_REMOTE_FILE=$( ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -i $KEY_FILE "$REMOTE_USER"@"$HOSTNAME" "stat --format='%Y' $FILE " > /tmp/zabbix_script.log ) echo TIMESTAMP_REMOTE_FILE 

There was quite clearly stated that the ssh command is trying to find out the file with private key. Because the script is run from command line from directory where the script is located, no issue appeared there.

Thank all of you for contributing ... every hint is counting

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.