Commit 5dd522f4 authored by Vinicius Ruoso's avatar Vinicius Ruoso

Added last_contact script and two status states

We are adding a last_contact script to create a collumn on web page that
contains the time of the last information receive from some host.

Additionally, the longoffline and offline_ping states has been included to
control hosts that are offline by a long time and the host we can't connect
but we can ping.

Also, the autogen configuration file has been changed to be able to create
the correct Makefile to those new features. The README has been adapted to
new scripts too.
Signed-off-by: default avatarVinicius Ruoso <vkr07@c3sl.ufpr.br>
parent 3d5dbeb3
......@@ -40,3 +40,6 @@ contrário o Makefile não irá instalar estes estados.
Para instalar os scripts, primeiro utilize o autogen para gerar o arquivo
Makefile, e então rode:
$ make PREFIX=$DIRETORIO_RAIZ_SDI
Cuidado ao utilizar purge: o comando "status" será removido e será
necessário resgatar a versão original.
......@@ -9,3 +9,5 @@ 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
last_contact:onconnect.d hourly.d:999-last_contact
status:onconnect.d:010-status
#!/bin/bash
printf "LAST_CONTACT+SET\n"
function last_contact_updatedata()
{
UPDATA=""
}
function last_contact_www()
{
NOW=$(LC_ALL=pt_BR.UTF-8 date +"%d %b %Y %H:%M")
PSORTCUSTOM="$(date +%s)"
PVALUE="$NOW"
}
function getcolumninfo()
{
WEBINTERFACE=true
COLNAME="Último contato"
}
#!/bin/bash
printf "STATUS+ONLINE\n"
function status_updatedata()
{
UPDATA="$*"
}
function status_www()
{
if test "$*" = "ONLINE"; then
PSTATUS=green
PSTATETYPE="status_longoffline_st:false online:true offline:false"
PSTATETYPE="$PSTATETYPE status_offline_ping_st:false"
else
STATES=""
if test -f $DATAPATH/last_contact; then
LAST=$(tail -1 $DATAPATH/last_contact)
# 1 week = 604800 seconds
if (( $(date +%s)-$LAST > 604800 )); then
STATES="status_longoffline_st:true"
else
STATES="status_longoffline_st:false"
fi
fi
PSTATUS=red
if ping -c5 "$HOST" &> /dev/null; then
PSTATETYPE="$STATES online:false offline:false"
PSTATETYPE="$PSTATETYPE status_offline_ping_st:true"
else
PSTATETYPE="$STATES online:false offline:true"
PSTATETYPE="$PSTATETYPE status_offline_ping_st:false"
fi
fi
PVALUE="$*"
}
function getcolumninfo()
{
WEBINTERFACE=true
COLNAME=Status
}
function longoffline_getstateinfo()
{
STITLE="Sem acesso remoto por uma semana ou mais"
SDESCRIPTION="Escolas sem acesso por uma semana ou mais"
SDEFCOLUMNS="ID,NRE,Cidade,Escola,Uptime,Status,Último Contato"
SSUMARY="%d escolas sem acesso por uma semana ou mais"
}
function offline_ping_getstateinfo()
{
STITLE="Sem acesso remoto mas responde ping"
SDESCRIPTION="Escolas offline respondendo ping"
SDEFCOLUMNS="ID,NRE,Cidade,Escola,Uptime,Status,Último contato"
SSUMARY="%d escolas sem acesso remoto mas responde ping"
}
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