#!/bin/bash

# (c) 2008-2009 PandoraFMS.org Development Team
# This script is BSD Licensed.            

# This script is used to copy all received data in /var/spool/pandora/data_in 
# (default Pandora FMS incoming directory) to a remote Tentacle server. 

# Define here your Parameters

TIMEOUT=5
SERVER_IP=192.168.50.1

# Main code, do not alter

while [ 1 ]
do

	# Check before if I can connect to remote IP
	CAN_CONNECT=`ping -c 1 -q $SERVER_IP | grep " 0%" | wc -l`
	if [ "$CAN_CONNECT" == 1 ]
	then

		for myfile in `find /var/spool/pandora/data_in -type f`
		do
	
			tentacle_client -q -a $SERVER_IP $myfile
			rm -Rf $myfile

		done
	fi
	sleep $TIMEOUT

done