Page 1 of 1
Any nagios plugin which can detect host is a VM/physical
Posted: Thu Jul 07, 2016 4:40 am
by ericssonvietnam
Hi,
Is there any nagios plugin available which can detect if OS is running on a virtual box or physical server and revert back with some details of host machine too, in pref data.?
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Thu Jul 07, 2016 11:37 am
by tgriep
Have you searched the Nagios Exchange site to see if there is a plugin that meets what you are looking for?
https://exchange.nagios.org/index.php?o ... ord=vmware
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Thu Jul 07, 2016 11:50 pm
by ericssonvietnam
Already searched on exchange but no luck. In my env Vm are hosted on Hyp's. Just wanted a simple plugin which an detect it and report that OS is a Vm running of X product. (kind off)
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Fri Jul 08, 2016 9:45 am
by tgriep
I found a plugin that returns the operating system but not the hardware / VM it is running on.
You may have to write something to get what you want.
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Mon Jul 11, 2016 3:51 am
by ericssonvietnam
Thanks for the reply , i've written one simple bash steps to detect if OS is virtual or not.
Code: Select all
#!/bin/bash
SERVER_TYPE="null"
VIRT_WHAT=`which virt-what`
STAT=$?
if [ $STAT -ne 0 ] ;then
SERVER_TYPE="$SERVER_TYPE:Problem with "virtual-what" command on host"
else
SERVER_TYPE=`$VIRT_WHAT`
STAT=$?
if [ $STAT -eq 0 ] ; then
if [ -z "$SERVER_TYPE" ] ;then
SERVER_TYPE="Physical:$SERVER_TYPE '`/usr/sbin/dmidecode -t system|grep 'Manufacturer\|Product'| tr -d '\n'`'"
else
SERVER_TYPE="Virtual:$SERVER_TYPE '`/usr/sbin/dmidecode -t system|grep 'Manufacturer\|Product'|tr -d '\n'`'"
fi
fi
fi
echo "$SERVER_TYPE"
exit $STAT
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Mon Jul 11, 2016 9:09 am
by mcapra
Thanks for sharing your solution! Is it alright if we close this thread and mark the issue as resolved?
Re: Any nagios plugin which can detect host is a VM/physical
Posted: Mon Jul 11, 2016 11:08 pm
by ericssonvietnam
Yes..!