From 42da504c2168edfa307f9e3b5e0737d9a3815893 Mon Sep 17 00:00:00 2001 From: darode Date: Wed, 16 Mar 2011 11:25:33 +0000 Subject: [PATCH] 2011-03-16 Dario Rodriguez * util/plugin/integria_plugin/, util/plugin/integria_plugin/plugin_definition.ini, util/plugin/integria_plugin/integria_plugin.sh, util/plugin/integria_plugin/README: Created integria plugin for Pandora. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4097 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 ++ .../util/plugin/integria_plugin/README | 25 +++++ .../plugin/integria_plugin/integria_plugin.sh | 96 +++++++++++++++++++ .../integria_plugin/plugin_definition.ini | 14 +++ 4 files changed, 142 insertions(+) create mode 100644 pandora_server/util/plugin/integria_plugin/README create mode 100755 pandora_server/util/plugin/integria_plugin/integria_plugin.sh create mode 100644 pandora_server/util/plugin/integria_plugin/plugin_definition.ini diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2d05c2d761..1e20c4424f 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2011-03-16 Dario Rodriguez + + * util/plugin/integria_plugin/, + util/plugin/integria_plugin/plugin_definition.ini, + util/plugin/integria_plugin/integria_plugin.sh, + util/plugin/integria_plugin/README: Created integria plugin for Pandora. + 2011-03-16 Dario Rodriguez * util/plugin/babel_plugin/babel_plugin.sh: Fixed an error in help text diff --git a/pandora_server/util/plugin/integria_plugin/README b/pandora_server/util/plugin/integria_plugin/README new file mode 100644 index 0000000000..722a2fe0b0 --- /dev/null +++ b/pandora_server/util/plugin/integria_plugin/README @@ -0,0 +1,25 @@ +############################################ +# # +# Integria Plugin for Pandora FMS # +# # +############################################ + +This plugin provide access to Integria API to gather data to be monitored +with Pandora FMS. + +This plugin has the following requirements: + +1.- You need a Integira installed with the API enable. + +2.- This plugin was developed to collect single data not arrays of values + so you only can collect for example the number of incidents open. + You can NOT monitor all incidents you need to specify a parameter of + one ot them indicent + +If you need more information about plugin parameters just type: + +$> ./integria_plugin -h + +You can see more information about Integria API at: + +http://www.openideas.info/wiki/index.php?title=Integria diff --git a/pandora_server/util/plugin/integria_plugin/integria_plugin.sh b/pandora_server/util/plugin/integria_plugin/integria_plugin.sh new file mode 100755 index 0000000000..e2f0aee935 --- /dev/null +++ b/pandora_server/util/plugin/integria_plugin/integria_plugin.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# Integria Plugin for Pandora FMS +# This plugin uses Integria API +# (c) Dario Rodriguez 2011 + +INTEGRIA_CONSOLE_PATH="" +USER="" +KEY="" +REQUEST="" +PARAMS="" +TOKEN="," + +# Help menu + +function help { + echo -e "Integria Plugin for Pandora FMS. http://pandorafms.com" + echo -e "Syntax:" + echo -e "\t\t-c : integria console path" + echo -e "\t\t-u : user" + echo -e "\t\t[-k] : API key (required if key is set on integria console)" + echo -e "\t\t-r : request" + echo -e "\t\t[-f] : parameters (default '')" + echo -e "\t\t[-s] : separator token (default ',')" + echo -e "Samples:" + echo " ./integria_plugin.sh -c http://127.0.0.1/integria -u user -r get_stats -f total_incidents" + echo "" + exit +} + +# Show help if there is no parameters + +if [ $# -eq 0 ] +then + help +fi + +# Main parsing code + +while getopts ":hc:u:k:r:f:s:" optname + do + case "$optname" in + "h") + help + ;; + "c") + INTEGRIA_CONSOLE_PATH=$OPTARG + ;; + "u") + USER=$OPTARG + ;; + "k") + KEY=$OPTARG + ;; + "r") + REQUEST=$OPTARG + ;; + "f") + PARAMS=$OPTARG + ;; + "s") + TOKEN=$OPTARG + ;; + ?) + help + ;; + default) + help + ;; + + esac +done + +# Create API call + +API_CALL=$INTEGRIA_CONSOLE_PATH"/include/api.php?user="$USER"&pass="$KEY"&op="$REQUEST"¶ms="$PARAMS"&token="$TOKEN + +# Execute call with wget +DATE=`date +%s%N` +FILE_OUTPUT="temp$DATE" + +wget $API_CALL -o /dev/null -O "$FILE_OUTPUT" + +# Check if wget was OK + +if [ $? -eq 0 ]; then + output=`cat "$FILE_OUTPUT"` + + # Check if API call returns some valuer not + + if [ "$output" != "" ]; then + echo -n $output + fi + +fi + +rm "$FILE_OUTPUT" diff --git a/pandora_server/util/plugin/integria_plugin/plugin_definition.ini b/pandora_server/util/plugin/integria_plugin/plugin_definition.ini new file mode 100644 index 0000000000..5d6011e8ef --- /dev/null +++ b/pandora_server/util/plugin/integria_plugin/plugin_definition.ini @@ -0,0 +1,14 @@ +; This is a sample configuration file +; Comments start with ';', as in php.ini + +[plugin_definition] +name = Integria Plugin +filename = integria_plugin.sh +description = This plugin allow the integration between Pandora FMS and Integria. +timeout = 300 +ip_opt = -c +user_opt = -u +port_opt = +pass_opt = +plugin_type = 0 +total_modules_provided = 0