I created check in KVM virtualized host to get list of available VM's in KVM hypervisor using below command.
$ cat /usr/local/nagios/libexec/check_kvm
#!/bin/sh
val=`virsh list --all | sed '1,2d' | sed '/^$/d'| awk '{print $2":"$3}'`
echo "VM List is" - $val
exit 0
Executing the script locally fetch the data as below.
# sh /usr/local/nagios/libexec/check_kvm
VM List is - oy06b:running .......
While, fetching the data from nagios server using nrpe, I am unable to get VM list. I am getting as below "VM List is" and $val is not showing.
/usr/local/nagios/libexec/check_nrpe -H <Host IP> -c check_kvm
VM List is -
Please advice....