Page 1 of 1

A problem to check QNAP through SSH

Posted: Fri Sep 18, 2020 4:06 am
by davide.bonicelli
Hi, i've made a simple scritp to check if the syslog file on a nas is updated and locally (on the nas) is working.
This is the script:

Code: Select all

#!/bin/bash

z=`ls /share/CACHEDEV1_DATA/Public/messages -l | awk -F'administrators' '{print $2}' | awk '{print $3}' | cut -c 1-4`
y=`date | awk '{print $4}' | cut -c 1-4`

if [ "$z" = "$y" ]

then
        echo "Ricezione Syslog Funzionante (z=$z y=$y)"
        exit 0
else
        echo  "Attenzione, controllare funzionamento Syslog. (z=$z y=$y)"
        exit 1
fi
locally i got this result:

Code: Select all

Ricezione Syslog Funzionante (z=11:0 y=11:0)
But when i run the check from nagios with the command

Code: Select all

/usr/local/nagios/libexec/check_by_ssh -H xx.xx.xx.18 -C "/nagios/check_syslog.sh" -p 9022 --logname=admin
the result is

Code: Select all

Attenzione, controllare funzionamento Syslog. (z=18 y=11:0)
i always got z=18 and i don't undestand when it came from..
maybe the ip but i don't undestand
any idea?

Re: A problem to check QNAP through SSH

Posted: Fri Sep 18, 2020 3:32 pm
by mbellerue
First, when you ssh into the QNAP yourself, are you logging in as 'admin', just like the check_by_ssh plugin?

Second, I think we'll need to see the output of

Code: Select all

ls /share/CACHEDEV1_DATA/Public/messages -l
Maybe even get a better understanding of how files are populated there.

Re: A problem to check QNAP through SSH

Posted: Mon Sep 21, 2020 2:14 am
by davide.bonicelli
yes, i log with the user 'admin'.
this is the output from the nas

Code: Select all

[~] # ls /share/CACHEDEV1_DATA/Public/messages -l
-rw-r--r-- 1 admin administrators 3062601 2020-09-21 09:05 /share/CACHEDEV1_DATA/Public/messages
and this is from nagios

Code: Select all

[nagios@nagiosprod root]$ /usr/local/nagios/libexec/check_by_ssh -H x.x.x.18 -C "ls /share/CACHEDEV1_DATA/Public/messages -l" -p 9022 --logname=admin
-rw-r--r-- 1 admin administrators 3062601 Sep 21 09:05 /share/CACHEDEV1_DATA/Public/messages
that's interesting..like the nas seems to have deleted my script..ok i think i'll change the approach and make the check on the nagios side analyzing the result of the remote ls command..

Re: A problem to check QNAP through SSH

Posted: Mon Sep 21, 2020 4:31 pm
by cdienger
Sounds good. Please let us know if we can assist with anything further.

Re: A problem to check QNAP through SSH

Posted: Tue Sep 22, 2020 4:58 am
by davide.bonicelli
it works
thanks for the assist! :)

Re: A problem to check QNAP through SSH

Posted: Tue Sep 22, 2020 8:06 am
by scottwilkerson
davide.bonicelli wrote:it works
thanks for the assist! :)
Great!

Locking thread