Any nagios plugin which can detect host is a VM/physical

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Any nagios plugin which can detect host is a VM/physical

Post 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.?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Any nagios plugin which can detect host is a VM/physical

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: Any nagios plugin which can detect host is a VM/physical

Post 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)
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Any nagios plugin which can detect host is a VM/physical

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: Any nagios plugin which can detect host is a VM/physical

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Any nagios plugin which can detect host is a VM/physical

Post by mcapra »

Thanks for sharing your solution! Is it alright if we close this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: Any nagios plugin which can detect host is a VM/physical

Post by ericssonvietnam »

Yes..!
Locked