2009-12-29 Sancho Lerena <slerena@artica.es>

* lib/PandoraFMS/Core.pm: Fixed problem generating events with
        character ' that makes SQL queries in console to fail.

        * util/plugin/webcheck_plugin.sh: Christmas extra :-). Plugin
        to check WEB content change (by MD5 stamp).



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2255 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-12-29 16:40:50 +00:00
parent 6c9a01cb59
commit 5318237f81
3 changed files with 90 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2009-12-29 Sancho Lerena <slerena@artica.es>
* lib/PandoraFMS/Core.pm: Fixed problem generating events with
character ' that makes SQL queries in console to fail.
* util/plugin/webcheck_plugin.sh: Christmas extra :-). Plugin
to check WEB content change (by MD5 stamp).
2009-12-28 Sancho Lerena <slerena@artica.es>
* lib/Config.pm: pandora_exec default at /usr/bin

View File

@ -814,7 +814,7 @@ sub pandora_create_agent ($$$$$$$$$$$) {
my $agent_id = db_insert ($dbh, 'INSERT INTO tagente (`nombre`, `direccion`, `comentarios`, `id_grupo`, `id_os`, `server_name`, `intervalo`, `id_parent`, `modo`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', $agent_name, $address, $description, $group_id, $os_id, $server_name, $interval, $parent_id);
pandora_event ($pa_config, "Agent '$agent_name' created by $server_name", $pa_config->{'autocreate_group'}, $agent_id, 2, 0, 0, 'new_agent', $dbh);
pandora_event ($pa_config, "Agent [$agent_name] created by $server_name", $pa_config->{'autocreate_group'}, $agent_id, 2, 0, 0, 'new_agent', $dbh);
return $agent_id;
}

View File

@ -0,0 +1,81 @@
#!/bin/bash
# WEB Content Stampg server pluin
# (c) Sancho Lerena 2010
# Default values
URL=""
HASH=""
TEST=0
TIMEOUT=10
function help {
echo -e ""
echo -e "WEB content stamp Plugin for Pandora FMS Plugin server. http://pandorafms.com"
echo -e "Syntax:"
echo -e "\t\t-u url For example: http://pandorafms.org/index.html"
echo -e "\t\t-m md5hash MD5 hash passed as parameter to check remote content"
echo -e "\t\t-g Use this parameter to get MD5 on command line"
echo -e "Samples:\n"
echo " ./webcheck_plugin.sh -u http://pandorafms.org -m 79ea72005e5505d99d2548e1b2189857"
echo ""
echo -e "Please note that -g parameter is used only in command line to get the valid MD5sum to use in the check"
exit
}
if [ $# -eq 0 ]
then
help
fi
# Sample of full exec
# wget http://192.168.70.103/pandora_console/index.php -O /dev/stdout -o /dev/null | md5sum
# Main parsing code
while getopts ":h:gm:u:" optname
do
case "$optname" in
"h")
help
;;
"m")
HASH=$OPTARG
;;
"u")
URL=$OPTARG
;;
"g")
TEST=1
;;
?)
help
;;
default)
help
;;
esac
done
if [ -z "$URL" ]
then
help
fi
if [ $TEST == 1 ]
then
wget $URL -T $TIMEOUT -O /dev/stdout -o /dev/null | md5sum | awk '{ print $1 }'
exit
fi
# execution
REAL_HASH=`wget $URL -T $TIMEOUT -O /dev/stdout -o /dev/null | md5sum | awk '{ print $1 }'`
if [ "$REAL_HASH" == "$HASH" ]
then
echo 1
else
echo 0
fi