Pandora FMS community forums

Full Version: apache_plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hola a todos, estoy empezando con Pandora FMS, para un pequeño proyecto; estoy probando con un Turnkey Lamp para que me sirva los datos del server-status de apache, he habilitado el servidor de apache para que muestre el estado del servidor al localhost, al servidor de pandora y a otra ip del equipo anfitrión (me muestra el estado correctamente), buscando por los plugins disponibles en la web https://pandorafms.com/library/apache-pe...ce-plugin/ he descargado el plugin, lo he puesto en /etc/pandora/plugins y lo he llamado desde el fichero de configuración de agente como indica; pero a la hora de que muestre los datos en el servidor de pandora, los módulos aparecen como no inicializados y los dos unicos que me aparecen como inicializados, aparecen a cero.

Alguien me podría dar alguna indicación para hacer que funcione.

Muchas gracias de antemano

adjunto el fichero de configuración del plugin

#!/bin/bash
# Apache monitorization plugin for Pandora FMS agent
# Author: Manuel A. Gulín Bejarano
# Version: 1.1
# Date: 19/03/2013
#
# This program 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 3 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, see <http://www.gnu.org/licenses/>.

function help {
        echo -e "Apache monitorization agent plugin for Pandora FMS agent. http://pandorafms.com"
        echo -e "Apache need the server status module active and accessible from localhost without password"
        echo -e "Syntax:"
        echo -e "\t\t$0 <mod_status_url>"
        exit
}

if [ $# -ne 1 ]
then
        help
        exit -1
fi

## Info about server - all retrieved with one query, later it's going to be appropiately parsed
ASTAT="`wget -q -O - "$@" --no-check-certificate $1?auto`"
FSTAT="`wget -q -O - "$@" --no-check-certificate $1`"

# Info about CPU usage
AF_CPUULOAD=`echo $FSTAT  | grep -o "CPU Usage: u[0-9]*.[0-9]* s[0-9]*.[0-9]*" | awk '{print $3}' | cut -d"u" -f2 | tail --lines=1`
AF_CPUSLOAD=`echo $FSTAT  | grep -o "CPU Usage: u[0-9]*.[0-9]* s[0-9]*.[0-9]*" | awk '{print $4}' | cut -d"s" -f2 | tail --lines=1`

# Info about performance
AP_REQSEC=`echo $ASTAT | grep -o "ReqPerSec: [0-9.]*" | awk '{print $2}'`
AP_BPS=`echo $ASTAT | grep -o "BytesPerSec: [0-9]*" | awk '{ print $2}'`
AP_TOTACC=`echo $ASTAT | grep -o "Total Accesses: [0-9]*" | awk '{print $3}'`

# Info about apache processes
AP_BUSY=`echo $ASTAT | grep -o "BusyWorkers: [0-9]*" | awk '{print $2}'`
AP_IDLE=`echo $ASTAT | grep -o "IdleWorkers: [0-9]*" | awk '{print $2}'`

# Info about uptime
AP_UPTIME=`echo $ASTAT | grep -o "Uptime: [0-9]*" | grep -o [0-9]*`
AF_REBOOT=`echo $FSTAT | grep -o "<dt>Restart Time: [a-zA-Z]*, [0-9]*-[a-zA-Z]*-[0-9]* [0-9:]* [a-zA-Z]*" | grep -o "[a-zA-Z]*, [0-9]*-[a-zA-Z]*-[0-9]* [0-9:]* [a-zA-Z]*" | tail --lines=1`
AF_RELOADS=`echo $FSTAT | grep -o "Parent Server Generation: [0-9]*" | grep -o [0-9]* | tail --lines=1`

# Some useful info
AP_TOTAL=$((AP_BUSY+AP_IDLE))
AP_TOTAL_MIN_WARN=`echo $AP_TOTAL | awk '{print ($1*0.80)}'`
AP_TOTAL_MAX_WARN=`echo $AP_TOTAL | awk '{print ($1*0.89)}'`
AP_TOTAL_MIN_CRIT=`echo $AP_TOTAL | awk '{print ($1*0.90)}'`


#########################################################################################################
# UPTIME INFO MODULES
#########################################################################################################
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Restart time]]></name>"
echo -e "\t<description><![CDATA[Restart time]]></description>"
echo -e "\t<type>async_string</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AF_REBOOT]]></data>"
#echo -e "\t<crontab>0 * * * *</crontab>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Uptime]]></name>"
echo -e "\t<description><![CDATA[Uptime since reboot (sec)]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_UPTIME]]></data>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Reloads]]></name>"
echo -e "\t<description><![CDATA[Config reloads since reboot]]></description>"
echo -e "\t<type>async_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AF_RELOADS]]></data>"
#echo -e "\t<crontab>0 * * * *</crontab>"
echo -e "\t</module>"

#########################################################################################################
# PERFORMANCE INFO MODULES
#########################################################################################################
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Total accesses]]></name>"
echo -e "\t<description><![CDATA[Total accesses since reboot]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_TOTACC]]></data>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Request per second]]></name>"
echo -e "\t<description><![CDATA[Request per second since reboot]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_REQSEC]]></data>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Bytes per second]]></name>"
echo -e "\t<description><![CDATA[Bytes per second since reboot]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_BPS]]></data>"
echo -e "\t</module>"

#########################################################################################################
# CPU USAGE INFO MODULES
#########################################################################################################
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: User CPU usage]]></name>"
echo -e "\t<description><![CDATA[User space CPU usage]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AF_CPUULOAD]]></data>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: System CPU usage]]></name>"
echo -e "\t<description><![CDATA[System space CPU usage]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AF_CPUSLOAD]]></data>"
echo -e "\t</module>"

#########################################################################################################
# APACHE PROCESSES INFO MODULES
#########################################################################################################
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Busy workers]]></name>"
echo -e "\t<description><![CDATA[Number of busy workers]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<max>$AP_TOTAL</max>"
echo -e "\t<min_warning>$AP_TOTAL_MIN_WARN</min_warning>"
echo -e "\t<max_warning>$AP_TOTAL_MAX_WARN</max_warning>"
echo -e "\t<min_critical>$AP_TOTAL_MIN_CRIT</min_critical>"
echo -e "\t<max_critical>$AP_TOTAL</max_critical>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_BUSY]]></data>"
echo -e "\t</module>"

echo -e "\t<module>"
echo -e "\t<name><![CDATA[Apache: Idle workers]]></name>"
echo -e "\t<description><![CDATA[Number of idle workers]]></description>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<min>0</min>"
echo -e "\t<max>$AP_TOTAL</max>"
echo -e "\t<disabled>0</disabled>"
echo -e "\t<data><![CDATA[$AP_IDLE]]></data>"
echo -e "\t</module>"

######################################################

Fichero de configuración del pandora_agent.conf


# Base config file for Pandora FMS agents
# Version 7.0NG.718, GNU/Linux
# Licensed under GPL license v2,
# Copyright © 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

# General Parameters
# ==================

server_ip     192.168.0.17
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 renames XML in the temp folder and continues running
debug         1    

# Optional. UDP Server to receive orders from outside
# By default is disabled, set 1 to enable
# Set port (41122 by default)
# Set address to restrict who can order a agent restart (0.0.0.0 = anybody)
#
udp_server 0
udp_server_port 41122
udp_server_auth_address 0.0.0.0

# By default, agent takes machine name
agent_name de42283582a256d66b62288559d67a019d194b27b035ffe8170e6140b82e78eb

# To define agent name by specific command, define 'agent_name_cmd'.
# (In the following example, agent name is 'hostname_IP')
# If set to __rand__ the agent will generate a random name.
#agent_name_cmd  LANG=C; /bin/echo -n `hostname`; /bin/echo -n "_"; /bin/echo `/sbin/ifconfig eth0 | /bin/grep 'inet addr' | /usr/bin/awk '{print $2;}' | /usr/bin/cut -d: -f2`
agent_name_cmd __rand__

# Group assigned for this agent (descriptive, p.e: Servers)
group Servers

# address: Enforce to server a ip address to this agent
# You can also try to detect the first IP using "auto", for example
address auto


# 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

# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache

# timeout in seconds for file transfer programs execution (30 by default)
#transfer_timeout 30

# 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 0

# 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 pandora

# Enable or disable XML buffer.
# If you are in a secured environment and want to enable the XML buffer you
# should consider changing the temporal directory, since /tmp is world writable.
xml_buffer 1

# Minimum available bytes in the temporal directory to enable the XML buffer
temporal_min_size 1024

# Agent mode: Learn (default), No-learn, Autodisable
# agent_mode autodisable

# eHorus agent configuration file path:
# The agent will create a custom field named eHorusID that contains
# the eHorus agent's identifying key
ehorus_conf /etc/ehorus/ehorus_agent.conf


# Module Definition
# =================

# System information

# Could change depending on linux distro and vmstat command version
module_begin
module_name CPU Load
module_type generic_data
module_interval 1
module_exec vmstat 1 2 | tail -1 | awk '{ print $13 }'
module_max 100
module_min 0
module_description User CPU Usage (%)
module_min_warning 70
module_max_warning 90
module_min_critical 91
module_max_critical 100
module_unit %
module_group System
module_end

# Could change depending on linux distro and vmstat command version
module_begin
module_name CPU IOWait
module_type generic_data
module_interval 1
module_exec vmstat 1 2 | tail -1 | awk '{ print $16 }'
module_min_warning 10
module_min_critical 16
module_unit %
module_description Too much IOwait means IO bottleneck and performance problems. Check also LoadAVG.
module_group System
module_end

# Get load average
module_begin
module_name Load Average
module_type generic_data
module_exec cat /proc/loadavg | cut -d' ' -f1
module_description Average process in CPU (Last minute)
module_group System
module_end

# Basic info about TCP Connection
module_begin
module_name TCP_Connections
module_type generic_data
module_exec netstat -an | grep tcp | grep -v LIST | wc -l
module_description Total number of TCP connections active
module_group Networking
module_end

# This plugin detects all disk and report used space (%)

module_plugin pandora_df_used

# This plugin detects system free memory and used swap (in %)

module_plugin pandora_mem_used

# This plugin will get the network usage (bytes/sec)

module_plugin pandora_netusage

module_plugin /etc/pandora/plugins/apache_plugin_orignal url=192.168.0.22




Muchas gracias y un saludo.
Buenos días algarca:

Puedes probar a ejecutar el plugin en sí, ya que muchos de ellos para que funcionen bien necesitas ejecutar algunos parámetros.


Ejemplo:


Estamos en la carpeta /etc/pandora/plugins con un plugin llamado hola.pl

Prueba a ejecutar ./hola.pl

Si tiene alguna opción de parametros, se desplegará una ayuda.



Si sigues teniendo dudas o problemas, no dudes en contactar conmigo.


Un cordial saludo,

fraguas.
(03-21-2018, 08:54 AM)fraguas Wrote: [ -> ]Buenos días algarca:

Puedes probar a ejecutar el plugin en sí, ya que muchos de ellos para que funcionen bien necesitas ejecutar algunos parámetros.


Ejemplo:


Estamos en la carpeta /etc/pandora/plugins con un plugin llamado hola.pl

Prueba a ejecutar ./hola.pl

Si tiene alguna opción de parametros, se desplegará una ayuda.



Si sigues teniendo dudas o problemas, no dudes en contactar conmigo.


Un cordial saludo,

fraguas.

Buenas tardes fraguas, ante todo agradecerte tu respuesta; tenias razón el parámetro que le había puesto no era el correcto, invocando el plugin desde el pandora_agent "module_plugin /etc/pandora/plugins/apache_plugin_orignal http://localhost/server-status" se inicializan todos los módulos y comienzan a dar los valores.
Me he estado complicando y la solución era evidente.

Muchas gracias

Un saludo

algarca.
Buenos días  algarca:

Me alegra haberte ayudado.

Si en un futuro, tienes dudas o te surge algún problema, no dudes en contactar conmigo.


Un cordial saludo,


fraguas.