Commit 24d09de8 authored by Vinicius Ruoso's avatar Vinicius Ruoso

Created script to retrieve information about schools nobreak's

Diagnose the nobreak's states are an important task. If a energy failure
happens, and the nobreak isn't there, the filesystem can be severely
corrupted/damaged.

This script, and associate states, will be a warn to schools that haven't
installed their nobreak's properly.

Also, an entry to autogen.conf has been added.
Signed-off-by: default avatarVinicius Ruoso <vkr07@c3sl.ufpr.br>
parent 7a480274
......@@ -8,3 +8,4 @@ prd_name:onconnect.d:006-prd_name
prd_version:onconnect.d daily.d:012-prd_version
prd_raid:onconnect.d hourly.d:020-prd_raid
prd_fixraid:hourly.d:019-prd_fixraid
prd_nobreak:hourly.d:030-prd_nobreak
#!/bin/bash
# function to check if some IP is the nobreak
function isnobreak(){
IP=$1
snmpwalk -v 1 -c public $IP .1.3.6.1.2.1 |grep -q -i "apc"
return $?
}
# function to search the nobreak on the network
function searchnobreak(){
PING="ping -c 1 -W 1"
FOUND="false"
# look in default IP - name is in /etc/hosts
if $PING nobreak &> /dev/null && isnobreak nobreak; then
printf "PRD_NOBREAK+OK\n"
# look in default IP - there is not name in /etc/hosts
elif $PING 192.168.1.200 &> /dev/null && isnobreak 192.168.1.200; then
if ! grep -q nobreak /etc/hosts; then
printf "PRD_NOBREAK+NOTINHOSTS\n"
fi
# looking for IP - was not found yet
else
for ((i=150; i>=100; i--)); do
if $PING 192.168.1.$i &> /dev/null; then
if isnobreak 192.168.1.$i; then
printf "PRD_NOBREAK+NOTDEFAULT+192.168.1.$i\n"
FOUND="true"
break
fi
fi
done
test "$FOUND" = "false" && printf "PRD_NOBREAK+NO\n"
fi
}
searchnobreak
function prd_nobreak_updatedata()
{
UPDATA="$*"
}
function prd_nobreak_www()
{
STAT="$*"
if test "$STAT" = "NOTINHOSTS"; then
PSTATETYPE="prd_nobreak_notinhosts.st:true"
PSTATETYPE="$PSTATETYPE prd_nobreak_notdefault.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_no.st:false"
PSTATUS=gray
STAT="FALHA /etc/hosts"
elif test "$STAT" = "NO"; then
PSTATETYPE="prd_nobreak_notinhosts.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_notdefault.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_no.st:true"
PSTATUS=red
STAT="AUSENTE"
elif grep -q "NOTDEFAULT" <<< "$STAT"; then
PSTATETYPE="prd_nobreak_notinhosts.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_notdefault.st:true"
PSTATETYPE="$PSTATETYPE prd_nobreak_no.st:false"
PSTATUS=gray
IP=$(cut -d+ -f2 <<< "$STAT")
STAT="IP RUIM: $IP"
else
PSTATETYPE="prd_nobreak_notinhosts.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_notdefault.st:false"
PSTATETYPE="$PSTATETYPE prd_nobreak_no.st:false"
fi
PVALUE="$STAT"
}
function getcolumninfo()
{
WEBINTERFACE=true
COLNAME=Nobreak
}
function getstateinfo()
{
STITLE="Nobreak nao encontrado"
SDESCRIPTION="Escolas sem nobreak"
SDEFCOLUMNS="ID,NRE,Cidade,Escola,Status,Nobreak"
SSUMARY="%d escolas sem nobreak"
}
function getstateinfo()
{
STITLE="Nobreak em endereco errado"
SDESCRIPTION="Escolas com nobreak em endereco errado"
SDEFCOLUMNS="ID,NRE,Cidade,Escola,Status,Nobreak"
SSUMARY="%d escolas com nobreak em endereco errado"
}
function getstateinfo()
{
STITLE="Nobreak nao tem entrada no /etc/hosts"
SDESCRIPTION="Escolas com nobreak, mas sem entrada no /etc/hosts"
SDEFCOLUMNS="ID,NRE,Cidade,Escola,Status,Nobreak"
SSUMARY="%d escolas com nobreak, mas sem entrada no /etc/hosts"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment