[Check_mk (english)] Problem with script check_by_ssh ..... (Return code of 255 is out of bounds)

1 --> In the remoteserver, which user I have to create user with that
permission to run the script that I require. (nagios user)

Depends on what your run script does - this can't be known to anyone
on the list. All I can say is it's the user configured as "remoteuser"
in your nagios command.

2 --> And in my monitoring machine what can i do to to fix the problem,
because i cant execute the command like nagios user.

If your remotehost is monitored by cmk agent, too, take your remote
script as local check instead of using check_by_ssh.
If the host is not monitored via cmk agent and you're stuck to
check_by_ssh do these steps to check if command can be used and
probably fix if not:

1.) connect to terminal of monitoring server and issue this as root
user (effectively executes command as nagios user, just like nagios
itself):
     sudo -u nagios '/usr/local/lib/nagios/plugins/check_by_ssh -H
"ipremoteserver" -l "userremoteserver" -C /home/nagios/hardware.sh -E'
2.) if command fails because a password is needed do this (in short,
should you not be able to understand what to do you should search the
web on how to do this, it's totally out of scope of this list or cmk):
    * create rsa keypair for nagios user on monitoring server
    * append pub part to ~/.ssh/authorized_keys of remoteuser on remotehost
3.) repeat step 1 - this should work now.

Regards,
Marcel

···

best regards

2013/10/23 Francisco Gomez Leo <pacogomezleo@gmail.com>

the question is that i cant execute the command like nagios user , because
when i do su - nagios nothing happens , i still be a root user. How can i
check it , the user can not be use to access by ssh, so ...

2013/10/23 Marcel Schulte <schulte.marcel@gmail.com>

What exactly fails? What is the command output?

We can't help without getting such infomation. Just 'it fails' is by far
not enough...

sent from my SGS3

Am 23.10.2013 16:16 schrieb "Francisco Gomez Leo" >>> <pacogomezleo@gmail.com>:

I cant , but of course that is the fail , how can i fix them ?

2013/10/23 Marcel Schulte <schulte.marcel@gmail.com>

I always said it's the user!

Connect to your monitoring server, become root and change user to the
nagios one:

su - <nagiosuser>

...then issue the command and watch it failing.

Marcel

sent from my SGS3

Am 23.10.2013 15:51 schrieb "Francisco Gomez Leo" >>>>> <pacogomezleo@gmail.com>:

How can i do it , my nagios user dosent have permision to access by
ssh in my nagios server. But i mean that the problem is the user because
when I use the terminal i always use root , and when nagios execute the
pluging maybe use the use nagios ...

2013/10/23 Marcel Schulte <schulte.marcel@gmail.com>

Francisco,

Open a terminal and execute the command as Nagios user. Does that
work?

Regards,
Marcel

sent from my SGS3

Am 23.10.2013 15:29 schrieb "Francisco Gomez Leo" >>>>>>> <pacogomezleo@gmail.com>:

How can i get that the string that it returns can i show it in my
checkmk inteface , because always show me (Return code of 255 is out of
bounds) CRIT

2013/10/23 Francisco Gomez Leo <pacogomezleo@gmail.com>

but i connect perfectly ....

2013/10/23 Marcel Schulte <schulte.marcel@gmail.com>

If using root user the public part of root's cert is used for the
connection. Nagios most likely does not run as root so you must
setup
Nagios' user's pub part for the connection and it should work.

HTH,
Marcel

2013/10/23 Francisco Gomez Leo <pacogomezleo@gmail.com>:
> when i execute the command by terminal , i used root user ,
> /usr/local/lib/nagios/plugins/check_by_ssh -H "ipremoteserver"
> -l
> "userremoteserver" -C /home/nagios/hardware.sh -E the
> "userremoteserver" has
> access with rsa certificates and no password is needed , if he
> dont the
> command wouldn´t works in the terminal of my monitoringserver.
>
> Thanks for the answer
>
>
> 2013/10/23 Marcel Schulte <schulte.marcel@gmail.com>
>>
>> Hi Francisco,
>>
>> when you execute the command in terminal - as which user do you
>> do
>> that? Nagios executes all plugins as the user it runs as...
>>
>> Looks as if the script does not need a password for the ssh
>> user so
>> this should work with rsa certificates or similar. The used
>> user is
>> very important then as the public cert of the user is taken to
>> authenticate.
>>
>> HTH,
>> Marcel
>>
>> 2013/10/23 Francisco Gomez Leo <pacogomezleo@gmail.com>:
>> > Hi , i used check_by_ssh to execute another script in a
>> > remote server,
>> > this
>> > works when i execute the command in the shell but it dosent
>> > works when I
>> > tried to used it with check_mk, that script always return
>> > (Return code
>> > of
>> > 255 is out of bounds) "critical" , in the check_mk
>> > interface ...
>> >
>> >
>> > define command{ command_name check_nas_server command_line
>> > /usr/local/lib/nagios/plugins/check_by_ssh -H
>> > "ipremoteserver" -l
>> > "userremoteserver" -C /home/nagios/hardware.sh -E }
>> >
>> >
>> > it should be return 0 or 1 , and a echo message ....
>> >
>> >
>> > Could you help me ? , the userremoteserver has nopassword
>> > access to the
>> > remote server , and is correct.
>> >
>> > thank regards
>> >
>> > _______________________________________________
>> > checkmk-en mailing list
>> > checkmk-en@lists.mathias-kettner.de
>> > http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
>> >
>
>