Hi James,<div><br></div><div>Excuse me for answering so far! </div><div><br></div><div>It's correct, I'm doing these checks for a Xenserver host; In fact, these checks are for several Citrix Xenservers (more than 30).</div>
<div><br></div><div>That you wrote in the first paragraph, already did. I created a local Nagios user on the Xenserver host with its ssh keys and on the Nagios server in the same way:</div><div><br></div><div style="text-align:center">
###############</div><div><div style="text-align:center">##Nagios server##</div><div style="text-align:center">###############</div><div><b>root@nagioserver:~# cat /etc/passwd | grep -i nagios</b></div><div><b>nagios:x:106:116::/var/lib/nagios:/bin/bash</b></div>
</div><div><b><br></b></div><div><b>nagios@nagioserver:~/.ssh$ ls -l</b></div><div><div><b>-rw-r--r-- 1 nagios nagios  399 2012-08-14 12:37 authorized_keys</b></div><div><b>-rw------- 1 nagios nagios 1675 2012-08-14 11:11 id_rsa</b></div>
<div><b>-rw-r--r-- 1 nagios nagios  402 2012-08-14 11:11 id_rsa.pub</b></div><div><b>-rw-r--r-- 1 nagios nagios  442 2012-08-14 11:08 known_hosts</b></div></div><div><br></div><div><div style="text-align:center">###############</div>
<div><div style="text-align:center">##XENSERVER##</div><div style="text-align:center">###############</div></div></div><div style="text-align:left"><div><b>[root@ORL-XEN-02 ~]# cat /etc/passwd | grep -i nagi</b></div><div>
<b>nagios:$1$vBr1twsi$6AL.hoMnGK8T1WgZ0.Ov2/:500:500::/home/nagios:/bin/bash</b></div><div><b><br></b></div><div><div><b>[nagios@ORL-XEN-02 .ssh]$ ls -l</b></div><div><b>-rw------- 1 nagios nagios  402 Aug 14 12:51 authorized_keys</b></div>
<div><b>-rw------- 1 nagios nagios 1671 Aug 14 12:57 id_rsa</b></div><div><b>-rw-r--r-- 1 nagios nagios  399 Aug 14 12:57 id_rsa.pub</b></div><div><b>-rw-r--r-- 1 nagios nagios  788 Aug 14 13:00 known_hosts</b></div></div>
</div><div><br></div><div>Also I use the "xentop" command to get the CPU results in my script, but I had to set the sudoers file in the Xenserver because the "xentop" command only root is be able to execute it.</div>
<div><br></div><div>This is the script and sudoers file.</div><div><br></div><div><div><b>#!/bin/bash</b></div><div><b>CRITICAL_CPU='95'</b></div><div><b>WARNING_CPU='80'</b></div><div><b><br></b></div><div>
<b>#Porcentage de CPU en uso</b></div><div><b>cpu_stat=$(sudo /usr/sbin/xentop -bi2 | grep Domain-0 | awk '{print $4}' | tail -1 | cut -d '.' -f1)</b></div><div><b>#cpu_stat='80'</b></div><div><b><br>
</b></div><div><b>#Evaluamos estado</b></div><div><b>if [ $cpu_stat -ge $CRITICAL_CPU ] ; then</b></div><div><b>echo “CRITICAL:CPU%= $cpu_stat”</b></div><div><b>exit 2</b></div><div><b>elif [ $cpu_stat -ge $WARNING_CPU ] ; then</b></div>
<div><b>echo “WARNING: CPU%= $cpu_stat”</b></div><div><b>exit 1</b></div><div><b>else</b></div><div><b>echo “OK:CPU%= $cpu_stat”</b></div><div><b>exit 0</b></div><div><b>fi</b></div></div><div><br></div><div>######################################################</div>
<div><br></div><div><div><b>## Allow root to run any commands anywhere</b></div><div><b>root      ALL=(ALL)       ALL</b></div><div><b>nagios  ALL=(ALL)       NOPASSWD:ALL</b></div></div><div><b><br></b></div><div><b><br>
</b></div><div>By the terminal, all works fine:</div><div><br></div><div>From Nagios server</div><div><div><b><br></b></div><div><b>nagios@nagioserver:~$ /usr/lib/nagios/plugins/check_by_ssh -l nagios -H 172.16.31.2 -C "/usr/lib/nagios/plugins/check_Xencpu" -i /var/lib/nagios/.ssh/id_rsa</b></div>
<div><b>“OK:CPU%= 3”</b></div></div><div><br></div><div>From Xenserver</div><div><br></div><div><div><b>[nagios@ORL-XEN-02 plugins]$ ./check_Xencpu </b></div><div><b>“OK:CPU%= 5”</b></div></div><div><br></div><div>In your second paragraph, What did you want to say with the resource.cfg? Do you have an example? I don't understand very well.</div>
<div><br></div><div>Finally, the service definition is passing 4 arguments as the command definition.</div><div><br></div><div><b style="line-height:20px"><span style="font-size:9pt;font-family:Helvetica,sans-serif">command_line /usr/lib/nagios/plugins/check_by_ssh (1)-l '$ARG1$' (2)-H '$HOSTADDRESS$' (3)-C '$ARG2$' (4)-i '$ARG3$'</span></b></div>
<div><b>check_command    check_by_ssh_xentop!(1)root!(2)ipxenserver!(3)/usr/lib/nagios/plugins/check_Xencpu.sh!(4)/root/.ssh/id_rsa!</b></div><div><b><br></b></div><div><br></div><div>Help me!!! LOL xD</div><div><br></div>
<div>Eduardo</div><div><br></div><div><br></div><div><br><div class="gmail_quote">2012/8/16 James Osbourn <span dir="ltr"><<a href="mailto:james.osbourn@citrix.com" target="_blank">james.osbourn@citrix.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I see that you are talking to a XenServer host.  I am performing something similar.  What I have had to do to achieve results is to create a local Nagios user on the XenServer host which has SSH keys to allow the server Nagios user to connect and avoid using any root SSH keys which the Nagios user is unlikely to be able to read.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Once you have connected to the XenServer host check that the Nagios user can execute the commands you are running.  If you are simply looking at the dom0 as if it was a host and checking items such as cpu, memory or disk usage then you should not have a problem.  If you are executing XenServer xe commands then you will need to pass a username and password that has access to the XenServer to run these commands.  This will be root or another account that has been granted access.  You can store these values in the resources.cfg file and pass them in your command definition.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I have also noticed that your service definition is passing 4 arguments, where your command definition is only using 3 arguments and the hostaddress.  It would be worth checking to make sure that you are passing the correct arguments from your service and command definitions to your remote host.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">James<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Eduardo Montes de Oca S. [mailto:<a href="mailto:edrendar@gmail.com" target="_blank">edrendar@gmail.com</a>] <br>
<b>Sent:</b> 15 August 2012 18:52</span></p><div class="im"><br><b>To:</b> <a href="mailto:nagios-users@lists.sourceforge.net" target="_blank">nagios-users@lists.sourceforge.net</a><br><b>Subject:</b> [Nagios-users] Issues with check_by_ssh<u></u><u></u></div>
<p></p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi list,<u></u><u></u></p><div><div class="h5"><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I have some issues with the plugin "check_by_ssh". In particular, there is one error:<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">When I run a shell script located in another server, from the Nagios server using the check_by_ssh plugin, I don't have any errors and I can see the result of the script, like this:<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><b><a href="mailto:root@TSM-SRV-V-114" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";text-decoration:none">root@nagioserver#</span></a></b><b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> /usr/lib/nagios/plugins/check_by_ssh -l root -H "ipxenserver" -C /usr/lib/nagios/plugins/check_Xencpu<br>
“OK:CPU%= 3”</span></b><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#5e6066">But, by any strange reason, when I configure the check for Nagios presents the results in its interface, I have the error:</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#5e6066"><img border="0" src="cid:image001.png@01CD7B8F.4994F110" alt="Imágenes integradas 1"></span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#5e6066">I have made the ssh authorization keys in both servers (Nagios and Xen), I configured the users, permissions,etc. And I can't to do this work it.</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#5e6066">Could someone help me solve this problem????</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#5e6066">This is a part of my definition files:</span><u></u><u></u></p>
</div><div><div><p class="MsoNormal" style="line-height:15.0pt"><b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">#XENServer<u></u><u></u></span></b></p></div></div><div><div><p class="MsoNormal" style="line-height:15.0pt">
<b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">define command {<u></u><u></u></span></b></p></div><div><p class="MsoNormal" style="line-height:15.0pt"><b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">               command_name check_by_ssh_xentop<u></u><u></u></span></b></p>
</div><div><p class="MsoNormal" style="line-height:15.0pt"><b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">               command_line /usr/lib/nagios/plugins/check_by_ssh -l '$ARG1$' -H '$HOSTADDRESS$' -C '$ARG2$' -i '$ARG3$'<u></u><u></u></span></b></p>
</div><div><p class="MsoNormal" style="line-height:15.0pt"><b><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">               }<u></u><u></u></span></b></p></div><div><div><p class="MsoNormal">
<b>#Hypervisor check</b><u></u><u></u></p></div><div><p class="MsoNormal"><b>        define service{</b><u></u><u></u></p></div><div><p class="MsoNormal"><b>                use                              generic-service</b><u></u><u></u></p>
</div><div><p class="MsoNormal"><b>                host_name                  ORLANDO </b><u></u><u></u></p></div><div><p class="MsoNormal"><b>                service_description     Hypervisor CPU</b><u></u><u></u></p></div>
<div><p class="MsoNormal"><b>                check_command         check_by_ssh_xentop!root!ipxenserver!/usr/lib/nagios/plugins/check_Xencpu.sh!/root/.ssh/id_rsa!</b><u></u><u></u></p></div><div><p class="MsoNormal"><b>                }</b><u></u><u></u></p>
</div></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div>
<p class="MsoNormal">Regards!<u></u><u></u></p></div><div><p class="MsoNormal"><span style="color:#888888"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="color:#888888"><u></u> <u></u></span></p></div>
<div><p class="MsoNormal"><span style="color:#888888">-- <u></u><u></u></span></p></div><div><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Franklin Gothic Medium","sans-serif";color:#888888">IC.</span></b><b><span style="font-size:10.0pt;font-family:"Franklin Gothic Medium","sans-serif";color:#888888"> Eduardo Montes de Oca Sánchez<br>
</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#888888">Skype: edrendar<br>Gmail: <a href="mailto:edrendar@gmail.com" target="_blank">edrendar@gmail.com</a><br>MSN: <a href="mailto:ed_montesdeoca@hotmail.com" target="_blank">ed_montesdeoca@hotmail.com</a><br>
Movil: 5523419886</span><span style="color:#888888"><u></u><u></u></span></p></div><p class="MsoNormal"><span style="color:#888888"><a href="https://linuxcounter.net/cert/549074.png" target="_blank">https://linuxcounter.net/cert/549074.png</a></span><u></u><u></u></p>
</div></div></div></div></div></div></div><br>------------------------------------------------------------------------------<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<br>
will include endpoint security, mobile security and the latest in malware<br>
threats. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><b style="font-family:Tahoma;font-size:13px"><font face="Franklin Gothic Medium">IC.</font></b><font face="Franklin Gothic Medium" style="font-size:13px"><font face="Franklin Gothic Medium"><b> Eduardo Montes de Oca Sánchez<br>
</b></font></font><span style="font-family:Tahoma;font-size:13px">Skype: edrendar</span><br style="font-family:Tahoma;font-size:13px"><span style="font-family:Tahoma;font-size:13px">Gmail: <a href="mailto:edrendar@gmail.com" target="_blank">edrendar@gmail.com</a></span><br style="font-family:Tahoma;font-size:13px">
<span style="font-family:Tahoma;font-size:13px">MSN: <a href="mailto:ed_montesdeoca@hotmail.com" target="_blank">ed_montesdeoca@hotmail.com</a></span><br style="font-family:Tahoma;font-size:13px"><span style="font-family:Tahoma;font-size:13px">Movil: 5523419886</span><br>
</div><a href="https://linuxcounter.net/cert/549074.png" target="_blank">https://linuxcounter.net/cert/549074.png</a><br>
</div>