From df09714aa184a8c97a94420935762dca23432177 Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 14 Feb 2011 16:45:14 +0000 Subject: [PATCH] 2011-02-14 Sancho Lerena * OpenWRT: Special files for OpenWRT/Perl version. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3830 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/unix/ChangeLog | 4 + pandora_agents/unix/OpenWRT/INSTALL | 58 ++++++++++++++ .../unix/OpenWRT/pandora_agent_daemon | 77 +++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 pandora_agents/unix/OpenWRT/INSTALL create mode 100755 pandora_agents/unix/OpenWRT/pandora_agent_daemon diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 37e5283e39..c20e73f823 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,7 @@ +2011-02-14 Sancho Lerena + + * OpenWRT: Special files for OpenWRT/Perl version. + 2011-02-10 Ramon Novoa * pandora_agent: Detach threads to avoid excessive resource usage, diff --git a/pandora_agents/unix/OpenWRT/INSTALL b/pandora_agents/unix/OpenWRT/INSTALL new file mode 100644 index 0000000000..6975acdfbb --- /dev/null +++ b/pandora_agents/unix/OpenWRT/INSTALL @@ -0,0 +1,58 @@ +Perl Agent +=========== + +Dependencies +------------ + +This is the generic Unix package, developed in Perl. In order to use it, you need to install a few packages first. This will be done using opkg (command line packager tool): + +opkg install perl +opkg install perlbase-autoloader +opkg install perlbase-base +opkg install perlbase-config +opkg install perlbase-errno +opkg install perlbase-essential +opkg install perlbase-fcntl +opkg install perlbase-file +opkg install perlbase-hostname +opkg install perlbase-io +opkg install perlbase-posix +opkg install perlbase-selectsaver +opkg install perlbase-socket +opkg install perlbase-symbol +opkg install perlbase-sys +opkg install perlbase-tie +opkg install perlbase-xsloader +opkg install coreutils-nohup +opkg install perlbase-getopt + +Install procedure +----------------- + +Step 1 - Get the latest package and copy to /tmp, you can get the latest package at: + + http://sourceforge.net/projects/pandora/files/Pandora%20FMS%203.2/Stable%20release/Unix%20%28Tarball%29/pandorafms_agent_unix-3.2.tar.gz/download + +Note: You will get a special version of the launcher, you can get it from our SVN repository and replace the perl daemon launcher with this special version for OpenWRT. Just replace it after do the package install for the Unix/Perl generic agent. + +Step 2 - Install it + + cd /tmp + tar xvzf pandorafms_agent_unix-3.2.tar.gz + cd unix + ./pandora_agent --install + +Step 3 - Create the startup link to run pandora agent when device restarts + + ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/S99pandora_agent + +Step 4 - Customize the agent name and server_ip for this device + + vi /etc/pandora/pandora_agent.conf + +Alter line "agent_name" for the devicename you want + +Step 5 - Start it manually: + + /etc/init.d/pandora_agent_daemon start + diff --git a/pandora_agents/unix/OpenWRT/pandora_agent_daemon b/pandora_agents/unix/OpenWRT/pandora_agent_daemon new file mode 100755 index 0000000000..d804b5970c --- /dev/null +++ b/pandora_agents/unix/OpenWRT/pandora_agent_daemon @@ -0,0 +1,77 @@ +#!/bin/sh + +# Pandora FMS Embedded Agent, startup script +# Copyright (c) 2011 Artica ST, +# Tested on Busybox 1.13 +# v4.0 Build 110122 +# http://www.pandorafms.com + +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin +PANDORA_PATH=/etc/pandora +DAEMON=/usr/bin/pandora_agent +LOGFILE=/dev/null + +# This function replace pidof +# not working in the same way in different linux distros + +pidof_pandora() { + COLUMNS=250 + PANDORA_PID=`ps | grep $DAEMON | grep -v grep | head -1 | awk '{ print $1 }'` + echo $PANDORA_PID +} + +if [ ! -f $DAEMON ] +then + echo "Pandora FMS Agent not found at $DAEMON, please check setup" + exit +fi + +case "$1" in + start) + PANDORA_PID=`pidof_pandora` + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora FMS Agent is currently running on this machine with PID $PANDORA_PID" + echo "Cannot launch again. Aborting." + exit 1 + fi + nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & + sleep 1 + PANDORA_PID=`pidof_pandora` + echo "Pandora FMS Agent is now running with PID $PANDORA_PID" + ;; + + stop) + PANDORA_PID=`pidof_pandora` + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..." + exit 1 + else + echo "Stopping Pandora FMS Agent." + kill $PANDORA_PID > /dev/null 2>&1 + fi + ;; + + status) + PANDORA_PID=`pidof_pandora` + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Agent is not running." + else + echo "Pandora FMS Agent is running with PID $PANDORA_PID." + fi + exit 0 + ;; + + force-reload|restart) + $0 stop + sleep 2 + $0 start + ;; + + *) + echo "Usage: /etc/init.d/pandora_agent_daemon {start|stop|restart|status|force-reload}" + exit 1 +esac +