A problem to check QNAP through SSH

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
davide.bonicelli
Posts: 134
Joined: Thu Feb 13, 2014 5:12 am

A problem to check QNAP through SSH

Post 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?
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: A problem to check QNAP through SSH

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
davide.bonicelli
Posts: 134
Joined: Thu Feb 13, 2014 5:12 am

Re: A problem to check QNAP through SSH

Post 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..
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: A problem to check QNAP through SSH

Post by cdienger »

Sounds good. Please let us know if we can assist with anything further.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
davide.bonicelli
Posts: 134
Joined: Thu Feb 13, 2014 5:12 am

Re: A problem to check QNAP through SSH

Post by davide.bonicelli »

it works
thanks for the assist! :)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: A problem to check QNAP through SSH

Post by scottwilkerson »

davide.bonicelli wrote:it works
thanks for the assist! :)
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked