#!/bin/bash export BBPROG=linux-version.bash COLUMN="version" DATE=$(date +'%Y-%m-%d %T') FILE='/etc/redhat-release' scriptVersion='0.1' # examples from /etc/redhat-release # rhel 5.11: Red Hat Enterprise Linux Server release 5.11 (Tikanga) # centos 6.7: CentOS release 6.7 (Final) if [ -z $BBHOME ] ; then echo "BBHOME is not set... exiting" exit 1 fi if [ ! -d "$BBTMP" ] ; then # GET DEFINITIONS IF NEEDED echo "*** LOADING XYMONCLIENT.CFG ***" . $BBHOME/etc/xymonclient.cfg # INCLUDE STANDARD DEFINITIONS fi if [[ ! -f ${FILE} ]] then COLOR='red' DESC="${FILE} not found -- is this a redhat type machine?" else COLOR='green' text=$(cat ${FILE}) osOne=$(echo ${text} | awk '{print tolower($1)}') osNum=$(echo ${text} | tr -d '[:alpha:]' | tr -d '()' | tr -d '[:space:]') major=$(echo ${osNum} | awk -F '.' '{print $1}') latest=$(curl http://repo.hpc.lsu.edu/files/linux/${osOne}-${major}.txt 2>/dev/null) if [[ "${latest}" != "${osNum}" ]] then COLOR='yellow' fi if [[ 'centos' == "${osOne}" ]] then os='CentOS' major=$(echo ${osNum} | awk -F '.' '{print $1}') else if [[ 'red' == "${osOne}" ]] then os='Red Hat' else os='unknown' version='unknown' COLOR='clear' fi fi fi EXTRA=$(uname -a) DESC="
${text} - latest is ${latest}
${EXTRA}" scriptInfo="

linux-version extension for xymon, version: ${scriptVersion}" # echo "machine=${MACHINE}" LINE="status ${MACHINE}.${COLUMN} ${COLOR} ${DATE} ${DESC} ${scriptInfo}" # echo $BB $BBDISP "$LINE" $BB $BBDISP "$LINE"