Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1567

Přidáno uživatelem Michal Kliment před asi 12 roky(ů)

Do /vendors/monitoring/ pridany skripty a konfiguracni soubory pro monitoring.

Zobrazit rozdíly:

freenetis/branches/testing/application/vendors/monitoring/freenetis-monitoring.init.sh
#! /bin/bash
### BEGIN INIT INFO
# Provides: freenetis
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $network $syslog
# Should-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop freenetis monitoring daemon
# Description: FreeNetIS monitoring script.
### END INIT INFO
################################################################################
# #
# This script serves for monitoring from IS FreeNetIS #
# #
# Author Kliment Michal 2012 #
# Email kliment@freenetis.org #
# #
# Name freenetis-monitoring.init.sh #
# Version 0.9 #
# #
################################################################################
# Load variables from config file
CONFIG=/etc/freenetis/freenetis-monitoring.conf
# Name of monitoring daemon
MONITORD="freenetis-monitord"
# Path to monitoring daemon (without name)
MONITORD_PATH="/usr/sbin/"
# Load variables
if [ -f $CONFIG ]; then
. $CONFIG
else
echo "No config file - giving up :-(";
exit 0
fi
start_monitor()
{
# test if daemon is already started
if [ `ps aux | grep $MONITORD | grep -v grep | wc -l` -gt 0 ];
then
echo "Already started."
return 0
fi
echo -n "Starting FreenetIS monitor daemon: "
# max priority is set
if [ $MAX_PRIORITY -gt 0 ];
then
# create process for all priority from interval <0;MAX_PRIORITY>
for i in `seq 0 $MAX_PRIORITY`;
do
nohup $MONITORD_PATH$MONITORD $i 2> /dev/null &
done
else
# create one process for all priorities
nohup $MONITORD_PATH$MONITORD 2> /dev/null &
fi
# test if daemon is started
if [ `ps aux | grep $MONITORD | grep -v grep | wc -l` -gt 0 ];
then
echo "OK"
else
echo "FAILED!";
fi
}
stop_monitor()
{
# test if daemon is already stopped
if [ `ps aux | grep $MONITORD | grep -v grep | wc -l` -eq 0 ];
then
echo "Not running."
return 0
fi
echo -n "Stopping FreenetIS monitor daemon: "
# kill all processes
killall -q $MONITOR
# test if daemon is stopped
if [ `ps aux | grep $MONITORD | grep -v grep | wc -l` -eq 0 ];
then
echo "OK"
else
echo "FAILED!";
fi
}
status_monitor()
{
echo -n "FreenetIS monitor daemon is "
# test if daemon is already started
if [ `ps aux | grep $MONITORD | grep -v grep | wc -l` -gt 0 ];
then
echo "running."
else
echo "not running.";
fi
}
usage_monitor()
{
echo "usage: `echo $0` (start|stop|restart|status)"
}
case "$1" in
start)
start_monitor
exit 0
;;
stop)
stop_monitor
exit 0
;;
restart)
stop_monitor
start_monitor
exit 0
;;
status)
status_monitor
exit 0
;;
*)
usage_monitor
exit 0
;;
esac
exit 0
freenetis/branches/testing/application/vendors/monitoring/freenetis-monitord.sh
#!/bin/bash
################################################################################
# #
# This script serves for monitoring from IS FreeNetIS #
# #
# author Kliment Michal 2012 #
# email kliment@freenetis.org #
# #
# name freenetis-monitord.sh #
# version 0.9 #
# #
################################################################################
#Load variables from config file
CONFIG=/etc/freenetis/freenetis-monitoring.conf
# temporary file with list of IP addresses to monitor
HOSTS_INPUT=`mktemp`
# temporary file with result to send
HOSTS_OUTPUT=`mktemp`
FPING="/usr/bin/fping"
# Load variables
if [ -f $CONFIG ]; then
. $CONFIG
else
echo "No config file - giving up :-(";
exit 0
fi
# endless loop
while true;
do
# use fping to get ip addresses states
$FPING -e -f "$HOSTS_INPUT" 2>/dev/null | while read host
do
# ip address
ip=`echo $host | awk '{print $1}'`
# state of host (alive or unreachable)
state=`echo $host | awk '{print $3}'`
# latency of host (only for alive state)
lat=`echo $host | awk '{print $4}' | sed 's/(//'`
# do not add ampersand to beginning of file with result
if [ -s "$HOSTS_OUTPUT" ];
then
echo -n "&" >> "$HOSTS_OUTPUT";
fi
# add variables to file with result
echo "ip[]=$ip&state[]=$state&lat[]=$lat" >> "$HOSTS_OUTPUT"
done
# remove temporary file with IP addresses to monitor
rm "$HOSTS_INPUT"
echo "Sending result data back to FreenetIS..."
# send file with result back to FreenetIS
wget -qO- --post-file="$HOSTS_OUTPUT" "$HOSTS_OUTPUT_URL"
# remove temporary file with result
rm "$HOSTS_OUTPUT"
done
freenetis/branches/testing/application/vendors/monitoring/freenetis-monitoring.conf
################################################################################
# #
# This script serves for IS FreeNetIS (monitoring) #
# #
# author Kliment Michal 2011 #
# email kliment@freenetis.org #
# #
# name freenetis-monitoring.conf #
# version 0.9 #
# #
################################################################################
################################################################################
# G E N E R A L S E T T I N G S #
################################################################################
# Base PATH_FN to running FreenetIS instance
PATH_FN=http://localhost/freenetis
# Log file, change to /dev/null to disable logging
LOG_FILE=/var/log/freenetis-monitoring.log
# 0 = Monitoring will be run in 1 process for all priorities
# 1..N = Monitoring will be run in 1 process for each priority in interval <0;MAX_PRIORITY>
MAX_PRIORITY=0
# URL with IP addresses to monitor
HOSTS_INPUT_URL=$PATH_FN"/index.php/en/web_interface/monitoring_hosts/"
# URL to which we send result
HOSTS_OUTPUT_URL=$PATH_FN"/index.php/en/web_interface/monitoring_states/"

Také k dispozici: Unified diff