I have to monitor a VM, runned in a Windows Server 2008 environment, using VirtualBox. I use Nagios to do the monitoring job. This process is executed in an Ubuntu Server environment.
The communication between Nagios and the Windows machine relies on NRPE (Nagios Remote Protocol Executor). I installed NSClient++ on the Windows machine and wrote a script which runs a VBoxManage command to check the state of the VM.
Here is the script:
@ECHO off "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo "win732" --machinereadable > C:\Users\root\etat_machine.txt FOR /F "tokens=* delims= " %%a in ('FINDSTR /I "win732" C:\Users\root\etat_machine.txt ^| FIND /C /I "win732"') do ( set res=%%a ) IF %res% == 1 goto ok IF %res% == 0 goto err :err ECHO WARNING: VM DOWN EXIT /B 1 :ok ECHO OK: VM UP EXIT /B 0
If I run this script directly on the Windows server (./check_vm.bat), the etat_machine.txt file contains VMState="running" and the script returns VM UP. If the script is executed through NRPE, it contains VMState="poweroff", although the VM is running.
Has somebody an explanation? I checked the user executing the script and in both cases, it is root. So I don't think it is a permission problem... Or maybe a permission on the NSClient service then...