Search
j0ke.net Open Build Service
>
Projects
>
internetx
>
nagios-plugins-virtuozzo
> check_virtuozzo_vm
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_virtuozzo_vm of Package nagios-plugins-virtuozzo
#!/bin/bash export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin #set -x # process excludes EXCLUDEFILE=/etc/vzlist.exclude if [ -f ${EXCLUDEFILE} ] ; then EXCLUDE=" | grep -v -i -E '(" RUN=0 for LINE in `cat ${EXCLUDEFILE} | grep -v -E '(^$|^#)'` ; do RUN=1 EXCLUDE="${EXCLUDE}${LINE}|" done if [ "${RUN}" == "1" ] ; then EXCLUDE=`echo ${EXCLUDE} | sed -e s@"|$"@")'"@` else EXCLUDE="" fi else EXCLUDE="" fi # real environment VZLIST=`/usr/sbin/vzlist -a -H ${EXCLUDE} | awk '{print $1";"$2";"$3";"$4";"$5 }'` if [ $? -ne 0 ] ; then echo "vzlist error" exit 2 fi # development environment #VZLIST=`cat vzlist | awk '{print $1";"$2";"$3";"$4";"$5 }'` OUTPUT="All VMs OK" EXITCODE=0 VZCNT=0 for LINE in ${VZLIST} ; do CTID=`echo ${LINE} | awk -F\; '{print $1}'` NPROC=`echo ${LINE} | awk -F\; '{print $2}'` STATUS=`echo ${LINE} | awk -F\; '{print $3}'` IP_ADDR=`echo ${LINE} | awk -F\; '{print $4}'` HOST_NAME=`echo ${LINE} | awk -F\; '{print $5}'` if [ "${STATUS}" != "running" ] ; then if [ ${VZCNT} -eq 0 ] ; then OUTPUT="Problems found: ${CTID} => ${HOST_NAME}/${IP_ADDR} => ${STATUS}" else OUTPUT="$OUTPUT , ${CTID} => ${HOST_NAME}/${IP_ADDR} => ${STATUS}" fi VZCNT=`/usr/bin/expr ${VZCNT} + 1` if [ "${STATUS}" == "stopped" ] ; then if [ ${EXITCODE} -le 1 ] ;then EXITCODE=1 fi elif [ "${STATUS}" == "mounted" ] ; then EXITCODE=2 else EXITCODE=3 fi else : fi done 2>&1 echo ${OUTPUT} exit ${EXITCODE}