diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index d408d9cf23..e161e65416 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,12 @@ +2013-04-21 Junichi Satoh + + * pandora_agent_installer: Added support for NetBSD. + + * NetBSD/pandora_agent, NetBSD/pandora_agent.conf: Added launcher + script and configuration file for NetBSD. + + Contributed by Hiroki SHIMIZU. Thanks! + 2013-04-17 Ramon Novoa * pandora_agent: Added support for sending multiple ip addresses. diff --git a/pandora_agents/unix/NetBSD/pandora_agent b/pandora_agents/unix/NetBSD/pandora_agent new file mode 100755 index 0000000000..b8213fceeb --- /dev/null +++ b/pandora_agents/unix/NetBSD/pandora_agent @@ -0,0 +1,51 @@ +#!/bin/sh + +# ********************************************************************** +# Pandora FMS Agent Daemon launcher for NetBSD +# (c) 2013 Hiroki SHIMIZU +# +# ********************************************************************** + +# PROVIDE: pandora_agent +# REQUIRE: LOGIN +# KEYWORD: shutdown + +# Add the following line to /etc/rc.conf to enable `pandora_agent': +# +# pandora_agent="YES" +# + +. "/etc/rc.subr" + +name="pandora_agent" +rcvar=${name} + +# read configuration and set defaults +pandora_agent=${pandora_agent:-"NO"} +load_rc_config "$name" + +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin + +command=/usr/local/bin/pandora_agent +command_args="/usr/local/etc/pandora &" + +pidfile=/var/run/$name.pid +required_files="/usr/local/etc/pandora/pandora_agent.conf" +start_postcmd=start_postcmd +stop_postcmd=stop_postcmd + +procname="/usr/pkg/bin/perl" + +start_postcmd() +{ + sleep 1 + PANDORA_PID=`pgrep -f none $name` + echo $PANDORA_PID > $pidfile +} + +stop_postcmd() +{ + rm -f $pidfile +} + +run_rc_command "$1" diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf new file mode 100644 index 0000000000..f1bfa1be2a --- /dev/null +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -0,0 +1,213 @@ +# Base config file for Pandora FMS agents +# Version 130420, NetBSD Version +# Licensed under GPL license v2, +# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas +# http://www.pandorafms.com + +# General Parameters +# ================== + +server_ip localhost +server_path /var/spool/pandora/data_in +temporal /tmp +logfile /var/log/pandora/pandora_agent.log +#include /etc/pandora/pandora_agent_alt.conf +#broker_agent name_agent + +# Interval in seconds, 300 by default +interval 300 + +# Debug mode only generate XML, and stop after first execution, +# and does not copy XML to server. +debug 0 + +# By default, agent takes machine name +#agent_name adama + +#Parent agent_name +#parent_agent_name parent_name + +# Agent description +#description Demo agent + +# Group assigned for this agent (descriptive, p.e: Servers) +#group Servers + +# Autotime: Enforce to server to ignore timestamp coming from this +# agent, used when agents has no timer or it's inestable. 1 to enable +# this feature +# autotime 1 + +# Timezone offset: Difference with the server timezone +#timezone_offset 0 + +# Agent position paramters +# Those parameters define the geographical position of the agent + +# latitude +#latitude 0 +# longitude +#longitude 0 +# altitude +#altitude 0 + +#Position description +#position_description Madrid, centro + +# By default agent try to take default encoding defined in host. +# encoding UTF-8 + +# Listening TCP port for remote server. By default is 41121 (for tentacle) +# if you want to use SSH use 22, and FTP uses 21. +server_port 41121 + +# Transfer mode: tentacle, ftp, ssh or local +transfer_mode tentacle + +# Server password (Tentacle or FTP). Leave empty for no password (default). +# server_pwd mypassword + +# Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default). +# server_ssl no + +# Extra options for the Tentacle client (for example, server_opts "-v -r 5"). +# server_opts + +# delayed_startup defines number of seconds before start execution +# for first time when startup Pandora FMS Agent +# delayed_startup 10 + +# Pandora nice defines priority of execution. Less priority means more intensive execution +# A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default) +# pandora_nice 0 + +# Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use +# of old style cron. You should add to crontab Pandora FMS agent script to use this mode. +# This is disabled by default, and is not recommended. Use Pandora FMS internal scheduler +# is much more safe. +# cron_mode + +# If set to 1 allows the agent to be configured via the web console (Only Enterprise version) +# remote_config 1 + +# If set to 1 start Drone Agent's Proxy Mode +# proxy_mode 1 + +# Max number of simmultaneus connection for proxy (by default 10) +# proxy_max_connection 10 + +# Proxy timeout (by default 1s) +# proxy_timeout 1 + +# Number of threads to execute modules in parallel +#agent_threads 1 + +# User the agent will run as +#pandora_user root + +# Secondary server configuration +# ============================== + +# If secondary_mode is set to on_error, data files are copied to the secondary +# server only if the primary server fails. If set to always, data files are +# always copied to the secondary server. +# secondary_mode on_error +# secondary_server_ip localhost +# secondary_server_path /var/spool/pandora/data_in +# secondary_server_port 41121 +# secondary_transfer_mode tentacle +# secondary_server_pwd mypassword +# secondary_server_ssl no +# secondary_server_opts + +# Module Definition +# ================= + +# System information + +# vmstat syntax depends on system configuration, please check before use it +module_begin +module_name cpu_user +module_type generic_data +module_interval 1 +module_exec vmstat 1 2 | tail -1 | awk '{ print $16 }' +module_max 100 +module_min 0 +module_description User CPU Usage (%) +module_end + +module_begin +module_name cpu_system +module_type generic_data +module_interval 1 +module_exec vmstat 1 2 | tail -1 | awk '{ print $17 }' +module_max 100 +module_min 0 +module_description System CPU Usage (%) +module_end + +module_begin +module_name cpu_idle +module_type generic_data +module_interval 1 +module_exec vmstat 1 2 | tail -1 | awk '{ print $18 }' +module_max 100 +module_min 0 +module_description CPU Idle (%) +module_end + +module_begin +module_name Load Average +module_type generic_data +module_exec uptime | cut -d "," -f 4 | cut -d ":" -f 2 | sed "s/ //g" +module_description Average process in CPU (Last minute) +module_end + +module_begin +module_name disk_root_free +module_type generic_data +module_exec df -kh / | tail -1 | awk '{ print 100-$5 }' +module_max 100 +module_min 0 +module_description Free disk Percentage of root partition +module_end + +module_begin +module_name memfree +module_type generic_data +module_exec vmstat -t 1 2 | tail -1 | awk '{print $12}' +module_description Unused RAM memory +module_end + +module_begin +module_name proctotal +module_type generic_data +module_exec ps -A | wc -l | sed "s/ //g" +module_end + +# Process information + +module_begin +module_name sshDaemon +module_type generic_proc +module_exec ps -A | grep sshd | grep -v "grep" | wc -l | sed "s/ //g" +module_end + +# Async data example + +module_begin +module_name LastLogin +module_type async_string +module_exec last | head -1 +module_end + +# Plugin example + +# This parses /var/log/auth.log file, under the module name "syslog" +# And search for "sshd" string into it, sending only that information. + +module_plugin grep_log /var/log/auth.log Syslog sshd + +# Plugin for inventory on the agent (Only Enterprise) + +# module_plugin inventory 1 cpu ram video nic hd cdrom software diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 5d6448dd6d..a1c4bb8b98 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -5,7 +5,7 @@ # (c) 2008-2010 Artica ST # (c) 2008-2010 Sancho Lerena # -# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux, FreeBSD) +# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux, FreeBSD, NetBSD) # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** @@ -47,6 +47,10 @@ then #PANDORA_PERL_DECODED_PATH=`echo $PANDORA_PERL_PATH | sed -e "s.\/.\\\\\/.g"` else PANDORA_PERL_PATH="perl" + if [ "$OS_NAME" = "NetBSD" ] + then + PANDORA_PERL_DECODED_PATH="/usr/pkg/bin/perl" + fi fi # Check for Perl 5.6.x or higher available @@ -61,7 +65,7 @@ then fi UNIX_KIND=`uname -s` -if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD | grep \"$UNIX_KIND\"`" ] +if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$UNIX_KIND\"`" ] then echo "This system: '$UNIX_KIND' is not supported by this script" echo "Please make the install yourself as it's described in documentation" @@ -113,6 +117,17 @@ uninstall () { TENTACLE_SERVER=/usr/local/bin/tentacle_server PANDORA_MAN=/usr/local/man fi + if [ "$OS_NAME" = "NetBSD" ] + then + PANDORA_HOME=/usr/local/share/pandora_agent + PANDORA_BIN=/usr/local/bin/pandora_agent + PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec + PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent + PANDORA_CFG=/usr/local/etc/pandora + TENTACLE=/usr/local/bin/tentacle_client + TENTACLE_SERVER=/usr/local/bin/tentacle_server + PANDORA_MAN=/usr/share/man + fi echo "Removing Pandora FMS Agent..." rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null @@ -191,6 +206,18 @@ install () { PANDORA_MAN=/usr/local/man fi + if [ "$OS_NAME" = "NetBSD" ] + then + PANDORA_HOME=/usr/local/share/pandora_agent + PANDORA_BIN=/usr/local/bin/pandora_agent + PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec + PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent + PANDORA_CFG=/usr/local/etc/pandora + TENTACLE=/usr/local/bin/tentacle_client + TENTACLE_SERVER=/usr/local/bin/tentacle_server + PANDORA_MAN=/usr/share/man + fi + echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION" if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ] then @@ -220,6 +247,10 @@ install () { then DAEMON_SCRIPT=FreeBSD/pandora_agent DAEMON_TEMP=pandora_agent_daemon_temp + elif [ "$OS_NAME" = "NetBSD" ] + then + DAEMON_SCRIPT=NetBSD/pandora_agent + DAEMON_TEMP=pandora_agent_daemon_temp else DAEMON_SCRIPT=pandora_agent_daemon DAEMON_TEMP=pandora_agent_daemon_temp @@ -240,7 +271,7 @@ install () { PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2` rm PANDORA_BASE.temp PANDORA_BASE.temp2 - if [ "$OS_NAME" = "FreeBSD" ] + if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ] then sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP mv $DAEMON_TEMP $DAEMON_SCRIPT @@ -285,7 +316,7 @@ install () { mkdir -p $PANDORA_BASE 2> /dev/null mkdir -p $PANDORA_BASE/var/log 2> /dev/null mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null - if [ "$OS_NAME" = "FreeBSD" ] + if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ] then mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null else @@ -322,7 +353,7 @@ install () { # Copying agent and securing it echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..." - + if [ "$PANDORA_PERL_DECODED_PATH" != "" ] then sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_agent > $PANDORA_BASE$PANDORA_BIN @@ -356,7 +387,23 @@ install () { fi echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..." - cp -r plugins $PANDORA_BASE$PANDORA_HOME + + if [ "$OS_NAME" = "NetBSD" ] + then + if [ ! -d $PANDORA_BASE$PANDORA_HOME/plugins ] + then + mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins + fi + for i in `ls -1 plugins` + do + sed s:/usr/bin/perl:/usr/pkg/bin/perl: plugins/$i > plugins/$i.tmp + cp plugins/$i.tmp $PANDORA_BASE$PANDORA_HOME/plugins/$i + rm plugins/$i.tmp + done + else + cp -r plugins $PANDORA_BASE$PANDORA_HOME + fi + chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins ln -s $PANDORA_BASE$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG @@ -397,7 +444,7 @@ install () { chmod 711 $PANDORA_BASE$PANDORA_LOG_DIR chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG - if [ "$OS_NAME" = "FreeBSD" ] + if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ] then chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP chmod -R 770 $PANDORA_BASE$PANDORA_TEMP @@ -410,7 +457,7 @@ install () { chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf - if [ "$OS_NAME" = "FreeBSD" ] + if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ] then echo "Linking start-up daemon script 'pandora_agent' on $OS_NAME"; else @@ -471,6 +518,14 @@ install () { chown root:wheel $PANDORA_STARTUP fi + if [ "$OS_NAME" = "NetBSD" ] + then + PANDORA_STARTUP=/etc/rc.d/pandora_agent + cp NetBSD/pandora_agent $PANDORA_STARTUP + chmod 555 $PANDORA_STARTUP + chown root:wheel $PANDORA_STARTUP + fi + echo "Done." echo " " echo "You have your startup script ready at $PANDORA_STARTUP" @@ -486,6 +541,9 @@ install () { if [ "$OS_NAME" = "FreeBSD" ] then echo "Define 'pandora_agent_enable=\"YES\"' in /etc/rc.conf to enable the daemon." + elif [ "$OS_NAME" = "NetBSD" ] + then + echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon." else echo "Check your startup configuration to be sure Pandora FMS Agent is ready " echo "to start automatically when system restarts":