@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Inventory System
# Author: Carsten Schoene
-# $LastChangedDate: 2014-11-28 15:44:14 +0100 (Fri, 28 Nov 2014) $
-# $Rev: 9550 $
+# $LastChangedDate: 2015-07-24 12:30:57 +0200 (Fri, 24 Jul 2015) $
+# $Rev: 10423 $
#
# Default options (can be changed by inventory-system.conf)
DEBUG="yes"
@@ -265,7 +265,7 @@
function get_system_productname {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
case `get_system_type` in
- xen-dom0|baremetal|kvm|vmware)
+ xen-dom0|baremetal|kvm|vmware|lxc)
PRODNAME=`${DMIDECODE} -s system-product-name`
;;
*)
@@ -350,7 +350,7 @@
function get_system_serial {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
case `get_system_type` in
- xen-dom0|baremetal|kvm|vmware)
+ xen-dom0|baremetal|kvm|vmware|lxc)
SYSSERIAL=`${DMIDECODE} -s system-serial-number`
;;
*)
@@ -365,8 +365,8 @@
function get_system_cpu {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
CPU=`${LSHW} -quiet -C processor | ${GREP} "product:" | ${SORT} -u | ${AWK} -F"product: " '{ print $NF}' | ${HEAD} -n1 | ${SED} -e 's@\s\+@ @g'`
- if [ -n "`echo ${CPU} | ${GREP} -i -E '(O.E.M.|OEM)'`" ] ; then
- CPU=`${LSHW} -quiet -C processor | ${GREP} "version:" | ${SORT} -u | ${AWK} -F"version: " '{ print $NF}' | ${HEAD} -n1 | ${SED} -e 's@\s\+@ @g'`
+ if [ -n "`echo ${CPU} | ${GREP} -i -E '(O.E.M.|OEM|^Xeon$|^Emulex)'`" ] ; then
+ CPU=`${LSHW} -quiet -C processor | ${GREP} "version:" | ${SORT} -u | ${AWK} -F"version: " '{ print $NF}' | ${GREP} -v -E '(^[0-9])' | ${HEAD} -n1 | ${SED} -e 's@\s\+@ @g'`
fi
debug "SYSTEM-CPU: ${CPU}"
echo ${CPU}
@@ -377,7 +377,7 @@
[ "`is_disabled $FUNCNAME`" == "1" ] && return
INSTMEM=0
case `get_system_type` in
- xen|xen-domU|openvz)
+ xen|xen-domU|openvz|lxc)
INSTMEM=`${CAT} /proc/meminfo | ${GREP} "^MemTotal:" | ${AWK} '{print int($2/1024)}'`
;;
*)
@@ -423,8 +423,13 @@
else
RD=`echo ${ROOTDEV} | ${SED} -r 's@(/dev/x?[hsv]d[a-z]).*@\1@'`
fi
- # / 1000 nicht / 1024 bei physikalischen Festplatten
- SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print $(NF-1)/1000/1000 }'`
+ SECCHECK=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${GREP} sectors$`
+ if [ -z "${SECCHECK}" ] ; then
+ # / 1000 nicht / 1024 bei physikalischen Festplatten
+ SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print $(NF-1)/1000/1000 }'`
+ else
+ SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print $(NF-3)/1000/1000 }'`
+ fi
debug "SYSTEM-ROOT-DEV: ${RD}"
debug "SYSTEM-ROOTDEV-SIZE: ${SIZE}"
echo ${SIZE}
@@ -475,7 +480,14 @@
RD=${BL_ROOTDISK}
fi
# / 1000 nicht / 1024 bei physikalischen Festplatten
- SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print int($(NF-1)/1000/1000) }'`
+ SECCHECK=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${GREP} sectors$`
+ if [ -z "${SECCHECK}" ] ; then
+ # / 1000 nicht / 1024 bei physikalischen Festplatten
+ SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print $(NF-1)/1000/1000 }'`
+ else
+ SIZE=`LANG=C ${FDISK} -l ${RD} 2>/dev/null | ${GREP} "^Disk /" | ${AWK} '{print $(NF-3)/1000/1000 }'`
+ fi
+
debug "SYSTEM-ROOT-DEV: ${RD}"
debug "SYSTEM-ROOTDEV-SIZE: ${SIZE}"
echo ${SIZE}
@@ -486,7 +498,12 @@
# get all (v)disks with sizes
function get_system_disk_sizes {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
- DEV_SIZES=`LANG=C ${FDISK} -l 2>/dev/null | ${GREP} "^Disk /" | ${SORT} | ${AWK} '{print $2","int($(NF-1)/1000/1000)}' | ${SED} -e 's@:,@,@' | ${GREP} -E '(/dev/cciss/c[0-9]d[0-9]|/dev/x?[hsv]d[a-z],[0-9]{1,9})'`
+ SECCHECK=`LANG=C ${FDISK} -l 2>/dev/null | ${GREP} "^Disk /" | ${GREP} sectors$`
+ if [ -z "${SECCHECK}" ] ; then
+ DEV_SIZES=`LANG=C ${FDISK} -l 2>/dev/null | ${GREP} "^Disk /" | ${SORT} | ${AWK} '{print $2","int($(NF-1)/1000/1000)}' | ${SED} -e 's@:,@,@' | ${GREP} -E '(/dev/cciss/c[0-9]d[0-9]|/dev/x?[hsv]d[a-z],[0-9]{1,9})'`
+ else
+ DEV_SIZES=`LANG=C ${FDISK} -l 2>/dev/null | ${GREP} "^Disk /" | ${SORT} | ${AWK} '{print $2","int($(NF-3)/1000/1000)}' | ${SED} -e 's@:,@,@' | ${GREP} -E '(/dev/cciss/c[0-9]d[0-9]|/dev/x?[hsv]d[a-z],[0-9]{1,9})'`
+ fi
debug "SYSTEM-DEVS-SIZES: ${DEV_SIZES}"
echo ${DEV_SIZES}
}
@@ -495,7 +512,7 @@
function get_system_manufacturer {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
case `get_system_type` in
- xen-dom0|baremetal|kvm|vmware)
+ xen-dom0|baremetal|kvm|vmware|lxc)
SYSMANUF=`${DMIDECODE} -s system-manufacturer`
;;
*)
@@ -522,7 +539,7 @@
function get_system_biosversion {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
case `get_system_type` in
- xen-dom0|baremetal|kvm|vmware)
+ xen-dom0|baremetal|kvm|vmware|lxc)
BIOSV=`${DMIDECODE} -s bios-version`
;;
*)
@@ -646,7 +663,14 @@
${GREP} -i -E '([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})'`
fi
if [ -z "${MAC}" ] ; then
- MAC="none"
+ ${IPMITOOL} lan print 2 >/dev/null 2>&1
+ if [ $? == 0 ] ; then
+ MAC=`${IPMITOOL} lan print 2 | ${GREP} -E '(^MAC Address)' | ${AWK} '{print tolower($NF)}' | \
+ ${GREP} -i -E '([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})'`
+ fi
+ if [ -z "${MAC}" ] ; then
+ MAC="none"
+ fi
fi
else
MAC="none"
@@ -673,7 +697,13 @@
MGMTIP=`${IPMITOOL} lan print 1 | ${GREP} -E '(^IP Address) ' | ${AWK} '{print $NF}'`
fi
if [ -z "${MGMTIP}" ] ; then
- MGMTIP="none"
+ ${IPMITOOL} lan print 2 >/dev/null 2>&1
+ if [ $? == 0 ] ; then
+ MGMTIP=`${IPMITOOL} lan print 2 | ${GREP} -E '(^IP Address) ' | ${AWK} '{print $NF}'`
+ fi
+ if [ -z "${MGMTIP}" ] ; then
+ MGMTIP="none"
+ fi
fi
else
MGMTIP="none"
|