From 54d5c76b93dcf874d75f9b07360329ab2e268081 Mon Sep 17 00:00:00 2001 From: Edileuton Henrique de Oliveira <eho09@c3sl.ufpr.br> Date: Fri, 20 Dec 2013 11:15:13 -0200 Subject: [PATCH] agent: Change telecentro's references to point Signed-off-by: Edileuton Henrique de Oliveira <eho09@c3sl.ufpr.br> --- agent/Makefile.in | 4 +- agent/bin/datasid-agent.sh | 26 +++++----- agent/bin/datasid-network-usage.sh | 6 +-- .../collected-data/point-info.tree | 48 +++++++++++++++++++ .../net-collected-data/id-point.tree | 39 +++++++++++++++ 5 files changed, 105 insertions(+), 18 deletions(-) create mode 100755 agent/gen-scripts/collected-data/point-info.tree create mode 100755 agent/network-scripts/net-collected-data/id-point.tree diff --git a/agent/Makefile.in b/agent/Makefile.in index f73768f..da56f3a 100644 --- a/agent/Makefile.in +++ b/agent/Makefile.in @@ -54,7 +54,7 @@ FILES = bin/datasid-agent.sh bin/datasid-client.sh \ bin/datasid-builtin-wget \ conf/datasid.conf \ gen-scripts/collected-data/agent-version.tree \ - gen-scripts/collected-data/telecentro-info.tree \ + gen-scripts/collected-data/point-info.tree \ gen-scripts/collected-data/interfaces.tree \ gen-scripts/collected-data/machine-type.tree \ gen-scripts/collected-data/user-history.tree \ @@ -69,7 +69,7 @@ FILES = bin/datasid-agent.sh bin/datasid-client.sh \ network-scripts/net-collected-data/agent-version.tree \ network-scripts/net-collected-data/bandwidth-usage.tree \ network-scripts/net-collected-data/interfaces.tree \ - network-scripts/net-collected-data/telecentro-id.tree + network-scripts/net-collected-data/id-point.tree .PHONY: all all: bin/datasid-xml-generator bin/datasid-gsoap-client bin/datasid-builtin-wget diff --git a/agent/bin/datasid-agent.sh b/agent/bin/datasid-agent.sh index ed8bf2b..74cefcf 100755 --- a/agent/bin/datasid-agent.sh +++ b/agent/bin/datasid-agent.sh @@ -26,7 +26,7 @@ # 2 - Error to edit crontab # 3 - Error when updating # 4 - Error to collect system data -# 5 - Error to download telecentroInfo +# 5 - Error to download pointInfo # 6 - Error when loading configuration # 7 - Error to send collected data @@ -85,8 +85,8 @@ function checkUpdate() # there wasn't one or if it was different. function schedule() { - if test -f "${CONFDIR}/telecentroInfo"; then - MIN=$(( 10#$(grep superid ${CONFDIR}/telecentroInfo | awk -F'=' '{print $2}' | sed "s/[^0-9]//g") % 60 )) + if test -f "${CONFDIR}/pointInfo"; then + MIN=$(( 10#$(grep idpoint ${CONFDIR}/pointInfo | awk -F'=' '{print $2}' | sed "s/[^0-9]//g") % 60 )) else MIN=$(( $RANDOM % 60 )) fi @@ -162,23 +162,23 @@ fi date +"%F %T - Update process terminated successfully." -# Download telecentroInfo from webservice -if ! ${PREFIX}/bin/datasid-wget.sh 192.168.0.253/api/datasid -O ${DATADIR}/telecentroInfo -t $UPDATETRIES -T 10; then - date +"%F %T - Error while downloading telecentroInfo." +# Download pointInfo from webservice +if ! ${PREFIX}/bin/datasid-wget.sh 192.168.0.253/api/datasid -O ${DATADIR}/pointInfo -t $UPDATETRIES -T 10; then + date +"%F %T - Error while downloading pointInfo." # exit 5 else # Check if a change has occurred in the webservice - if ! test -f ${CONFDIR}/telecentroInfo -a '$(md5sum ${DATADIR}/telecentroInfo)' = '$(md5sum ${CONFDIR}/telecentroInfo)'; then - date +"%F %T - Getting new telecentroInfo" - mv -f ${DATADIR}/telecentroInfo ${CONFDIR}/telecentroInfo + if ! test -f ${CONFDIR}/pointInfo -a '$(md5sum ${DATADIR}/pointInfo)' = '$(md5sum ${CONFDIR}/pointInfo)'; then + date +"%F %T - Getting new pointInfo" + mv -f ${DATADIR}/pointInfo ${CONFDIR}/pointInfo fi fi -rm -f ${DATADIR}/telecentroInfo +rm -f ${DATADIR}/pointInfo -# Check if telecentroInfo is configured -if ! test -f ${CONFDIR}/telecentroInfo; then - date +"%F %T - telecentroInfo not found in ${CONFDIR}/telecentroInfo, waiting configuration." +# Check if pointInfo is configured +if ! test -f ${CONFDIR}/pointInfo; then + date +"%F %T - pointInfo not found in ${CONFDIR}/pointInfo, waiting configuration." exit 8 fi diff --git a/agent/bin/datasid-network-usage.sh b/agent/bin/datasid-network-usage.sh index 9d32995..7b7ad81 100755 --- a/agent/bin/datasid-network-usage.sh +++ b/agent/bin/datasid-network-usage.sh @@ -79,9 +79,9 @@ exec >> ${LOGFILE} 2>&1 date +"%F %T - Start of network usage execution." -# Check if telecentroInfo is configured -if ! test -f ${CONFDIR}/telecentroInfo; then - date +"%F %T - telecentroInfo not found in ${CONFDIR}/telecentroInfo, waiting configuration." +# Check if pointInfo is configured +if ! test -f ${CONFDIR}/pointInfo; then + date +"%F %T - pointInfo not found in ${CONFDIR}/pointInfo, waiting configuration." exit 8 fi diff --git a/agent/gen-scripts/collected-data/point-info.tree b/agent/gen-scripts/collected-data/point-info.tree new file mode 100755 index 0000000..450c083 --- /dev/null +++ b/agent/gen-scripts/collected-data/point-info.tree @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre +# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +# +# This file is part of collect-agent +# +# collect-agent is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +# set PREFIX +export PREFIX="$(readlink -f "$(dirname $0)/../../")" + +# run datasid-common.sh +source "$(readlink -f "$(dirname $0)/../../")/bin/datasid-common.sh" > /dev/null 2>&1 || exit 1 + +if test -z "${PREFIX}"; then + exit 2 +fi + +# Telecentro data that will be collected +COLLECTDATA=( idpoint=idponto +user_count=usuarios ) + +index=0; + +# Collect point's info +while [ $index != ${#COLLECTDATA[@]} ] +do + tagName=$(echo ${COLLECTDATA[$index]} | awk -F'=' '{print $1}') + collect=$(echo ${COLLECTDATA[$index]} | awk -F'=' '{print $2}') + value=$(cat ${CONFDIR}/pointInfo | grep $collect | awk -F'=' '{print $2}') + # Check if the data exists + index=$(($index + 1)) + test -z "${value}" && exit $(($index + 2)) + printf "<$tagName>$value</$tagName>" +done diff --git a/agent/network-scripts/net-collected-data/id-point.tree b/agent/network-scripts/net-collected-data/id-point.tree new file mode 100755 index 0000000..78c935c --- /dev/null +++ b/agent/network-scripts/net-collected-data/id-point.tree @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre +# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +# +# This file is part of collect-agent +# +# collect-agent is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +# set PREFIX +export PREFIX="$(readlink -f "$(dirname $0)/../../")" + +# run datasid-common.sh +source "$(readlink -f "$(dirname $0)/../../")/bin/datasid-common.sh" > /dev/null 2>&1 || exit 1 + +if test -z "${PREFIX}"; then + exit 2 +fi + +# Check if pointInfo exists +test -f ${CONFDIR}/pointInfo || exit 3 + +# Collect point id +IDPOINT=$(grep "idponto" ${CONFDIR}/pointInfo | awk -F'=' '{print $2}') +test -z ${IDPOINT} && exit 4 + +echo $IDPOINT -- GitLab