From 4ae2df8dedf4971f0d544894b085d467b5c998f3 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 17 May 2022 13:42:38 +0200 Subject: [PATCH 01/32] #8939 comment optimization --- pandora_console/include/functions_events.php | 15 +++++++++------ .../include/lib/Dashboard/Widgets/events_list.php | 5 ++++- pandora_console/operation/events/events.php | 8 +++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 934d7c27bc..f37e30fc11 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1476,16 +1476,19 @@ function events_get_all( $group_selects = ''; if ($group_by != '') { if ($count === false) { - $group_selects = ',COUNT(id_evento) AS event_rep, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
") AS comments, - MAX(utimestamp) as timestamp_last, - MIN(utimestamp) as timestamp_first, - MAX(id_evento) as max_id_evento'; - $idx = array_search('te.user_comment', $fields); if ($idx !== false) { unset($fields[$idx]); } + + $group_selects = sprintf( + ',COUNT(id_evento) AS event_rep, + %s + MAX(utimestamp) as timestamp_last, + MIN(utimestamp) as timestamp_first, + MAX(id_evento) as max_id_evento', + ($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
") AS comments,' : '' + ); } } else { $idx = array_search('te.user_comment', $fields); diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index e0c1bfe3cf..06416cecb4 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -596,7 +596,6 @@ class EventsListWidget extends Widget 'te.event_type', 'te.id_alert_am', 'te.criticity', - 'te.user_comment', 'te.tags', 'te.source', 'te.id_extra', @@ -612,6 +611,10 @@ class EventsListWidget extends Widget 'tg.nombre as group_name', ]; + if (empty($filter['search']) === false || empty($filter['user_comment']) === false) { + $fields[] = 'te.user_comment'; + } + $home_url = $config['homeurl']; if ((bool) \is_metaconsole() === false diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 5f3a733318..113dfc9b53 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -286,7 +286,6 @@ if (is_ajax() === true) { 'te.event_type', 'te.id_alert_am', 'te.criticity', - 'te.user_comment', 'te.tags', 'te.source', 'te.id_extra', @@ -303,6 +302,13 @@ if (is_ajax() === true) { 'ta.direccion', ]; + if (strpos($config['event_fields'], 'user_comment') !== false + || empty($user_comment) === false + || empty($search) === false + ) { + $fields[] = 'te.user_comment'; + } + $order = get_datatable_order(true); if (is_array($order) === true && $order['field'] === 'mini_severity') { From a78eb719958e80d1a5c6e073fc2a80f7f7365665 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 25 May 2022 13:00:04 +0200 Subject: [PATCH 02/32] #9019 Fixed id_user in active directory --- pandora_console/include/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ca0c9dad7d..64fa0bce93 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2262,7 +2262,14 @@ function check_login($output=true) || (isset($_SESSION['merge-request-user-trick']) === true && $_SESSION['merge-request-user-trick'] === $_SESSION['id_usuario']) ) { - $config['id_user'] = $_SESSION['id_usuario']; + if (isset($config['auth']) === true && $config['auth'] === 'ad' && is_user($_SESSION['id_usuario'])) { + // User name in active directory is case insensitive. + // Get the user name from database. + $user_info = get_user_info($_SESSION['id_usuario']); + $config['id_user'] = $user_info['id_user']; + } else { + $config['id_user'] = $_SESSION['id_usuario']; + } return true; } From d9ad4977fa523a3689108fc47a4fbf4f55d055aa Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 1 Jun 2022 13:01:40 +0200 Subject: [PATCH 03/32] make open cisco ipsla plugin compatible with snmp v3 --- pandora_plugins/cisco_ipsla/pandora_ipsla.sh | 685 +++++++++++++++++++ 1 file changed, 685 insertions(+) create mode 100644 pandora_plugins/cisco_ipsla/pandora_ipsla.sh diff --git a/pandora_plugins/cisco_ipsla/pandora_ipsla.sh b/pandora_plugins/cisco_ipsla/pandora_ipsla.sh new file mode 100644 index 0000000000..976548f40b --- /dev/null +++ b/pandora_plugins/cisco_ipsla/pandora_ipsla.sh @@ -0,0 +1,685 @@ +#!/bin/bash +# IPSLA remote Plugin for Pandora FMS +# (c) ArticaST 2014 + + +# Default values +COMMUNITY="public" +TAG_TABLE_CACHE="/tmp/ipsla_cache" + +function help { + echo -e "Cisco IP SLA Server Plugin for Pandora FMS. http://pandorafms.com" + echo -e "Syntax:\n\n-c -t -v [other options]\n" + echo -e "\t\t-c community" + echo -e "\t\t-t target" + echo -e "\t\t-v version" + echo -e "Other options\n"; + echo -e "\t\t-s show defined tags and indexes" + echo -e "\t\t-l " + echo -e "\t\t-u " + echo -e "\t\t-a " + echo -e "\t\t-A " + echo -e "\t\t-x " + echo -e "\t\t-X " + echo -e "\t\t-g " + echo -e "\t\t-m \n" + echo -e "Modules can be: \n" + echo -e "\tICPIF - Calculated Planning Impairment Factor for specified tag" + echo -e "\tMOS - Mean Opinion Score" + echo -e "\tPacket_Out_of_Sequence - Packets arriving out of sequence " + echo -e "\tPacket_Late_Arrival - Packets arriving late" + echo -e "\tvAerage_Jitter - Average jitter is the estimated average jitter observed in the last XX RTP packets" + echo -e "\tPacketLossSD - Packet loss from source to destination" + echo -e "\tPacketLossDS - Packet loss from destination to source" + echo -e "\tPacketLost - The number of packets that are lost for which we cannot determine the direction " + echo -e "\tNegativesSD - The sum of number of all negative jitter values from packets sent from source to destination " + echo -e "\tNegativesDS - The sum of number of all negative jitter values from packets sent from destination to source" + echo -e "\tPositivesSD - The sum of number of all positive jitter values from packets sent from source to destination" + echo -e "\tPositivesDS - The sum of number of all positive jitter values from packets sent from source to destination" + echo -e "\tRTTMax - Max Round Trip Time" + echo -e "\tRTTMin - Min Round Trip Time" + echo -e "\tOperNumOfRTT - The number of successful round trips" + echo -e "\tOperPacketLossSD - Packet loss from source to destination for jitter tests" + echo -e "\tOperPacketLossDS - Packet loss from destination to source for jitter tests" + echo -e "\tRttOperSense - A sense code for the completion status of the latest RTT operation." + echo -e "\tRttOperCompletionTime - The completion time of the latest RTT operation successfully completed." + echo -e "\tRttOperTime - The value of the agent system time at the time of the latest RTT operation." + echo -e "\tRttOperAddress - A string which specifies the address of the target." + echo -e "\tHTTPOperRTT - Round Trip Time taken to perform HTTP operation. This value is the sum of DNSRTT, TCPConnectRTT and TransactionRTT." + echo -e "\tHTTPOperDNSRTT Round Trip Time taken to perform DNS query within the HTTP operation." + echo -e "\tHTTPOperTCPConnectRTT - Round Trip Time taken to connect to the HTTP server." + echo -e "\tIcmpJitterAvgJitter The average of positive and negative jitter values in Source-to-Destionation and Destination-to-Source direction." + echo -e "\tHTTPOperTransactionRTT - Round Trip Time taken to download the object specified by the URL." + + echo "" + exit +} + +function show_tags { + TAG_TABLE_CACHE=$TAG_TABLE_CACHE.$TARGET + + # If not exist the cache, then create it + if [ ! -f "$TAG_TABLE_CACHE" ] + then + snmpwalk -v 1 -Onq -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + cat $TAG_TABLE_CACHE | awk '{ print $2 }' | tr -d "\"" | grep -ve '^$' + exit +} + +function get_index { + cat $TAG_TABLE_CACHE.$TARGET | grep $1 | grep -o "[0-9]*\s" +} + +# This function requires two arguments. MODULE_TYPE TAG +function get_module { + MODULE_TYPE=$1 + TAG=$2 + INDICE=`get_index $TAG` + + if [ $version != "v3" ] + + then + + if [ "$MODULE_TYPE" == "ICPIF" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` + fi + if [ "$MODULE_TYPE" == "MOS" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` + fi + if [ "$MODULE_TYPE" == "Packet_Out_of_Sequence" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Packet_Late_Arrival" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Average_Jitter" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossSD" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossDS" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLost" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesSD" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesDS" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesSD" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesDS" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMax" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMin" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperNumOfRTT" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossSD" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossDS" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperSense" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperTime" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperAddress" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperRTT" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperDNSRTT" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTCPConnectRTT" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` + fi + + if [ "$MODULE_TYPE" == "IcmpJitterAvgJitter" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTransactionRTT" ] + then + VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` + fi + fi + + if [ $version == "v3" ] + + #if snmp v3 snmpget with v3 + then + if [ $auth == "authPriv" ] + # if authpriv snmpget with all parameters + then + if [ "$MODULE_TYPE" == "ICPIF" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` + fi + if [ "$MODULE_TYPE" == "MOS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` + fi + if [ "$MODULE_TYPE" == "Packet_Out_of_Sequence" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Packet_Late_Arrival" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Average_Jitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLost" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMax" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMin" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperNumOfRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperSense" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperAddress" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperDNSRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTCPConnectRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` + fi + + if [ "$MODULE_TYPE" == "IcmpJitterAvgJitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTransactionRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` + fi + fi + if [ $auth == "authNoPriv" ] + then + if [ "$hash1" ] + then + if [ "$MODULE_TYPE" == "ICPIF" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` + fi + if [ "$MODULE_TYPE" == "MOS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` + fi + if [ "$MODULE_TYPE" == "Packet_Out_of_Sequence" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Packet_Late_Arrival" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Average_Jitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLost" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMax" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMin" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperNumOfRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperSense" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperAddress" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperDNSRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTCPConnectRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` + fi + + if [ "$MODULE_TYPE" == "IcmpJitterAvgJitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTransactionRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` + fi + else + if [ "$MODULE_TYPE" == "ICPIF" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` + fi + if [ "$MODULE_TYPE" == "MOS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` + fi + if [ "$MODULE_TYPE" == "Packet_Out_of_Sequence" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Packet_Late_Arrival" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` + fi + + if [ "$MODULE_TYPE" == "Average_Jitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PacketLost" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` + fi + + if [ "$MODULE_TYPE" == "NegativesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` + fi + + if [ "$MODULE_TYPE" == "PositivesDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMax" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RTTMin" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperNumOfRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossSD" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + fi + + if [ "$MODULE_TYPE" == "OperPacketLossDS" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperSense" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperTime" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperAddress" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperDNSRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTCPConnectRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` + fi + + if [ "$MODULE_TYPE" == "IcmpJitterAvgJitter" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` + fi + + if [ "$MODULE_TYPE" == "HTTPOperTransactionRTT" ] + then + VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` + fi + + fi + + fi + fi + + echo -n $VALOR + exit 0 +} + +if [ -z "`which snmpwalk`" ] +then + echo "ERROR: snmpwalk is not in the path. Exiting..." + exit -1 +fi + +if [ $# -eq 0 ] +then + help +fi + +# Main parsing code + +while getopts ":hc:t:v:l:u:a:A:x:X:sm:g:" optname + do + case "$optname" in + "h") + help + ;; + "c") + COMMUNITY=$OPTARG + ;; + "t") + TARGET=$OPTARG + ;; + "v") + version=$OPTARG + ;; + "l") + auth=$OPTARG + ;; + "u") + user=$OPTARG + ;; + "a") + hash1=$OPTARG + ;; + "A") + hash1pass=$OPTARG + ;; + "x") + hash2=$OPTARG + ;; + "X") + hash2pass=$OPTARG + ;; + "g") + TAG=$OPTARG + ;; + "s") + show_tags + ;; + "m") + get_module $OPTARG $TAG + ;; + ?) + help + ;; + default) + help + ;; + + esac +done + +# Execution +echo "DEBUG" + +exit 0 From dc8c073f83424b70016b2578557d0f4e83c981c6 Mon Sep 17 00:00:00 2001 From: rafael Date: Mon, 20 Jun 2022 08:56:53 +0200 Subject: [PATCH 04/32] adding full snmpv3 support for cisco ipsla open plugin --- pandora_plugins/cisco_ipsla/pandora_ipsla.sh | 197 ++++++++++++++----- 1 file changed, 146 insertions(+), 51 deletions(-) mode change 100644 => 100755 pandora_plugins/cisco_ipsla/pandora_ipsla.sh diff --git a/pandora_plugins/cisco_ipsla/pandora_ipsla.sh b/pandora_plugins/cisco_ipsla/pandora_ipsla.sh old mode 100644 new mode 100755 index 976548f40b..729bf40828 --- a/pandora_plugins/cisco_ipsla/pandora_ipsla.sh +++ b/pandora_plugins/cisco_ipsla/pandora_ipsla.sh @@ -14,7 +14,7 @@ function help { echo -e "\t\t-t target" echo -e "\t\t-v version" echo -e "Other options\n"; - echo -e "\t\t-s show defined tags and indexes" + echo -e "\t\t-s show defined tags for cisco ipsla device and exit" echo -e "\t\t-l " echo -e "\t\t-u " echo -e "\t\t-a " @@ -23,12 +23,12 @@ function help { echo -e "\t\t-X " echo -e "\t\t-g " echo -e "\t\t-m \n" - echo -e "Modules can be: \n" + echo -e "Available Modules list: \n" echo -e "\tICPIF - Calculated Planning Impairment Factor for specified tag" echo -e "\tMOS - Mean Opinion Score" echo -e "\tPacket_Out_of_Sequence - Packets arriving out of sequence " echo -e "\tPacket_Late_Arrival - Packets arriving late" - echo -e "\tvAerage_Jitter - Average jitter is the estimated average jitter observed in the last XX RTP packets" + echo -e "\tAverage_Jitter - Average jitter is the estimated average jitter observed in the last XX RTP packets" echo -e "\tPacketLossSD - Packet loss from source to destination" echo -e "\tPacketLossDS - Packet loss from destination to source" echo -e "\tPacketLost - The number of packets that are lost for which we cannot determine the direction " @@ -50,167 +50,212 @@ function help { echo -e "\tHTTPOperTCPConnectRTT - Round Trip Time taken to connect to the HTTP server." echo -e "\tIcmpJitterAvgJitter The average of positive and negative jitter values in Source-to-Destionation and Destination-to-Source direction." echo -e "\tHTTPOperTransactionRTT - Round Trip Time taken to download the object specified by the URL." + echo -e "" + echo -e " Example execution" + echo -e " snmp version 3: ./pandora_ipsla.sh -t -v 3 -l authPriv -u pandorafms -a MD5 -A pandorafms -x AES -X pandorafms -g jitter -m Average_Jitter" + echo -e " snmp version 2c: ./pandora_ipsla.sh -t -v 2c -c public -g jitter -m Average_Jitter" + echo "" exit } function show_tags { - TAG_TABLE_CACHE=$TAG_TABLE_CACHE.$TARGET + local TAG_TABLE_CACHE=$TAG_TABLE_CACHE.$TARGET + + if [ $version != "3" ] + then + snmpwalk -v 1 -Onq -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + if [ $version == "3" ] + #if snmp v3 snmpget with v3 + then + if [ $auth == "authPriv" ] + # if authpriv snmpget with all parameters + then + snmpwalk -v 3 -Onq -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + if [ $auth == "authNoPriv" ] + then - # If not exist the cache, then create it - if [ ! -f "$TAG_TABLE_CACHE" ] - then - snmpwalk -v 1 -Onq -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE - fi + snmpget -v 3 -Onq -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + fi + cat $TAG_TABLE_CACHE | awk '{ print $2 }' | tr -d "\"" | grep -ve '^$' exit } +function update_tags { + local TAG_TABLE_CACHE=$TAG_TABLE_CACHE.$TARGET + + if [ $version != "3" ] + then + snmpwalk -v 1 -Onq -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + if [ $version == "3" ] + #if snmp v3 snmpget with v3 + then + if [ $auth == "authPriv" ] + # if authpriv snmpget with all parameters + then + snmpwalk -v 3 -Onq -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + if [ $auth == "authNoPriv" ] + then + + snmpget -v 3 -Onq -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.1.1.3 > $TAG_TABLE_CACHE + fi + fi + + +} + function get_index { - cat $TAG_TABLE_CACHE.$TARGET | grep $1 | grep -o "[0-9]*\s" + cat $TAG_TABLE_CACHE.$TARGET | grep "\"$1\"" | grep -o "[0-9]*\s" } # This function requires two arguments. MODULE_TYPE TAG function get_module { MODULE_TYPE=$1 TAG=$2 + update_tags INDICE=`get_index $TAG` - if [ $version != "v3" ] + if [ $version != "3" ] then if [ "$MODULE_TYPE" == "ICPIF" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.43.$INDICE` fi if [ "$MODULE_TYPE" == "MOS" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.42.$INDICE` fi if [ "$MODULE_TYPE" == "Packet_Out_of_Sequence" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.28.$INDICE` fi if [ "$MODULE_TYPE" == "Packet_Late_Arrival" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.30.$INDICE` fi if [ "$MODULE_TYPE" == "Average_Jitter" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.46.$INDICE` fi if [ "$MODULE_TYPE" == "PacketLossSD" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` fi if [ "$MODULE_TYPE" == "PacketLossDS" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` fi if [ "$MODULE_TYPE" == "PacketLost" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.29.$INDICE` fi if [ "$MODULE_TYPE" == "NegativesSD" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.12.$INDICE` fi if [ "$MODULE_TYPE" == "NegativesDS" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.22.$INDICE` fi if [ "$MODULE_TYPE" == "PositivesSD" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.7.$INDICE` fi if [ "$MODULE_TYPE" == "PositivesDS" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.17.$INDICE` fi if [ "$MODULE_TYPE" == "RTTMax" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.5.$INDICE` fi if [ "$MODULE_TYPE" == "RTTMin" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.4.$INDICE` fi if [ "$MODULE_TYPE" == "OperNumOfRTT" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.1.$INDICE` fi if [ "$MODULE_TYPE" == "OperPacketLossSD" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.26.$INDICE` fi if [ "$MODULE_TYPE" == "OperPacketLossDS" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` - fi - - if [ "$MODULE_TYPE" == "RttOperSense" ] - then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` fi if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` + fi + + if [ "$MODULE_TYPE" == "RttOperSense" ] + then + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` fi if [ "$MODULE_TYPE" == "RttOperTime" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.5.$INDICE` fi if [ "$MODULE_TYPE" == "RttOperAddress" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.6.$INDICE` fi if [ "$MODULE_TYPE" == "HTTPOperRTT" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.1.$INDICE` fi if [ "$MODULE_TYPE" == "HTTPOperDNSRTT" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.2.$INDICE` fi if [ "$MODULE_TYPE" == "HTTPOperTCPConnectRTT" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.3.$INDICE` fi if [ "$MODULE_TYPE" == "IcmpJitterAvgJitter" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.4.1.44.$INDICE` fi if [ "$MODULE_TYPE" == "HTTPOperTransactionRTT" ] then - VALOR=`snmpget -$version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` + VALOR=`snmpget -v $version -Oqv -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.1.1.4.$INDICE` fi fi - if [ $version == "v3" ] + if [ $version == "3" ] #if snmp v3 snmpget with v3 then @@ -300,12 +345,12 @@ function get_module { VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperSense" ] + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] then VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + if [ "$MODULE_TYPE" == "RttOperSense" ] then VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -x $hash2 -X $hash2pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` fi @@ -432,12 +477,12 @@ function get_module { VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperSense" ] + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] then VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + if [ "$MODULE_TYPE" == "RttOperSense" ] then VALOR=`snmpget -v 3 -l $auth -u $user -a $hash1 -A $hash1pass -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` fi @@ -560,12 +605,12 @@ function get_module { VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.5.2.1.27.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperSense" ] + if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] then VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.1.$INDICE` fi - if [ "$MODULE_TYPE" == "RttOperCompletionTime" ] + if [ "$MODULE_TYPE" == "RttOperSense" ] then VALOR=`snmpget -v 3 -l $auth -u $user -c $COMMUNITY $TARGET 1.3.6.1.4.1.9.9.42.1.2.10.1.2.$INDICE` fi @@ -610,7 +655,7 @@ function get_module { fi fi - echo -n $VALOR + echo -n $VALOR | awk '{print $NF}' exit 0 } @@ -664,10 +709,10 @@ while getopts ":hc:t:v:l:u:a:A:x:X:sm:g:" optname TAG=$OPTARG ;; "s") - show_tags + SHOWTAGS=1 ;; "m") - get_module $OPTARG $TAG + MODULE=$OPTARG ;; ?) help @@ -680,6 +725,56 @@ while getopts ":hc:t:v:l:u:a:A:x:X:sm:g:" optname done # Execution +[ "$SHOWTAGS" ] && echo "Showing avaliables ipsla tags for the device $TARGET" && show_tags + +[ -z "$TARGET" ] && echo "Error missing target ip definition please use -t to difine it or -h to see help" && exit 1 +[ -z "$MODULE" ] && echo "Error missing module definition please use -m to difine it or -h to see help" && exit 1 +[ -z "$TAG" ] && echo "Error missing tag definition please use -g to difine it or -h to see help" && exit 1 +[ -z "$version" ] && echo "Error missing snmp version definition please use -v to difine it or -h to see help" && exit 1 + + +get_module $MODULE $TAG echo "DEBUG" exit 0 + +#RttOperSense +# 0:other +# 1:ok +# 2:disconnected +# 3:overThreshold +# 4:timeout +# 5:busy +# 6:notConnected +# 7:dropped +# 8:sequenceError +# 9:verifyError +# 10:applicationSpecific +# 11:dnsServerTimeout +# 12:tcpConnectTimeout +# 13:httpTransactionTimeout +# 14:dnsQueryError +# 15:httpError +# 16:error +# 17:mplsLspEchoTxError +# 18:mplsLspUnreachable +# 19:mplsLspMalformedReq +# 20:mplsLspReachButNotFEC +# 21:enableOk +# 22:enableNoConnect +# 23:enableVersionFail +# 24:enableInternalError +# 25:enableAbort +# 26:enableFail +# 27:enableAuthFail +# 28:enableFormatError +# 29:enablePortInUse +# 30:statsRetrieveOk +# 31:statsRetrieveNoConnect +# 32:statsRetrieveVersionFail +# 33:statsRetrieveInternalError +# 34:statsRetrieveAbort +# 35:statsRetrieveFail +# 36:statsRetrieveAuthFail +# 37:statsRetrieveFormatError +# 38:statsRetrievePortInUse \ No newline at end of file From 35a2d59151b9d597e600d92ff2f88bf9aa7d4646 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 23 Jun 2022 11:56:47 +0200 Subject: [PATCH 05/32] adding log event plugin --- pandora_plugins/Log_event/getEvent.ps1 | 112 +++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 pandora_plugins/Log_event/getEvent.ps1 diff --git a/pandora_plugins/Log_event/getEvent.ps1 b/pandora_plugins/Log_event/getEvent.ps1 new file mode 100644 index 0000000000..19d4237421 --- /dev/null +++ b/pandora_plugins/Log_event/getEvent.ps1 @@ -0,0 +1,112 @@ +################################################################################ +# get Event +################################################################################ +# Copyright (c) 2020 Artica Soluciones Tecnologicas S.L +# Jose Antonio Almendros +################################################################################ +# +# usage: getEvent.exe -command "get_event.exe [event_source] [log_name] [interval] [*nodatalist] [*sendlog]" +# +################################################################################ + +param ( +[switch]$h = $false, +[switch]$nodatalist = $false, +[switch]$sendlog = $false +) + +if (($h -eq $true) -or ($($Args.Count) -le 2)){ + echo "Plugin to get events from the last N minutes" + echo "Usage:" + echo "getEvent.exe [event_source] [log_name] [interval] *[-nodatalist] *[-sendlog]`n" + echo "event_source:`t`tfield Source of the Event" + echo "log_name:`t`tfield Log Name of the Event" + echo "interval:`t`ttime interval from events will be extracted (in minutes)" + echo "nodatalist [optional]:`tshows all output in same module data" + echo "sendlog [optional]:`tsends logs to log server" + echo "Artica ST @ 2020" + exit +} + + +$source = $args[0] +$logname = $args[1] +$interval = $args[2] + + +if (($nodatalist -eq $false) -and ($sendlog -eq $false)) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders + $result = foreach ($Log in $Logs) + { + + if ($Log) + { + echo "" + echo "`r`n" + } + + + } + + echo "" + echo "$source Events" + echo "async_string" + echo "" + echo $result + echo "" + echo "Logs with log name $logname in source $source" + echo "" + } + +else + { + if ($sendlog -eq $false) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders | Out-String + $result = foreach ($Log in $Logs) + { + + echo $Log + echo "`r`n" + + + } + + echo "" + echo "$source Events" + echo "async_string" + echo "" + echo "Logs with log name $logname in source $source" + echo "" + } + } + +if ($sendlog -eq $true) + { + $Logs = get-EventLog -Source $source -LogName $logname -After $((get-date).AddMinutes(-$interval)) | ft -HideTableHeaders | Out-String + $result = foreach ($Log in $Logs) + { + + if ($Log) + { + echo "" + echo "`n" + } + + + } + + echo "" + echo "$source Events" + echo "" + echo $result + echo "" + echo "" + } \ No newline at end of file From 90c5155c1c0d7a5e7586352577de1610def54dfb Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 28 Jun 2022 11:26:08 +0200 Subject: [PATCH 06/32] #8939 conflict resolved 2 --- pandora_console/include/lib/Dashboard/Widgets/events_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index 395b7bbc93..8b1325ed66 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -605,7 +605,7 @@ class EventsListWidget extends Widget } if (empty($filter['search']) === false || empty($filter['user_comment']) === false) { - $fields[] = 'te.user_comment'; + $fields[] = 'user_comment'; } // Get column names. From fe46bb92359c35d8d486710627d9249622c80d30 Mon Sep 17 00:00:00 2001 From: Calvo Date: Thu, 30 Jun 2022 11:24:17 +0200 Subject: [PATCH 07/32] Addded pandora_version and build_version globals --- pandora_console/include/global_config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/global_config.php b/pandora_console/include/global_config.php index d23c6994a6..b14c2b0ae5 100644 --- a/pandora_console/include/global_config.php +++ b/pandora_console/include/global_config.php @@ -1,5 +1,7 @@ Date: Thu, 30 Jun 2022 17:17:05 +0200 Subject: [PATCH 08/32] modal sound events pandora_enterprise#9095 --- pandora_console/include/ajax/events.php | 7 +++ .../include/javascript/pandora_events.js | 48 +++++++++++++++++++ .../operation/events/sound_events.php | 3 +- pandora_console/operation/menu.php | 19 +++++++- 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 77d9647a4b..2f55052f93 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -55,6 +55,7 @@ if (! check_acl($config['id_user'], 0, 'ER') return; } +$drawConsoleSound = (bool) get_parameter('drawConsoleSound', false); $process_buffers = (bool) get_parameter('process_buffers', false); $get_extended_event = (bool) get_parameter('get_extended_event'); $change_status = (bool) get_parameter('change_status'); @@ -2225,6 +2226,12 @@ if ($process_buffers === true) { return; } +if ($drawConsoleSound === true) { + $output = 'WIP'; + echo $output; + return; +} + if ($get_events_fired) { global $config; $filter_id = (int) get_parameter('filter_id', 0); diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index ab276cda9e..d5d09d112a 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1028,3 +1028,51 @@ function process_buffers(buffers) { }); } } + +function openSoundEventModal(settings) { + settings = JSON.parse(atob(settings)); + + // Check modal exists and is open. + if ( + $("#modal-sound").hasClass("ui-dialog-content") && + $("#modal-sound").dialog("isOpen") + ) { + return; + } + + // Initialize modal. + $("#modal-sound") + .dialog({ + title: settings.title, + resizable: false, + modal: true, + position: { my: "right top", at: "right bottom", of: window }, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 600, + height: 600, + open: function() { + $.ajax({ + method: "post", + url: settings.url, + data: { + page: settings.page, + drawConsoleSound: 1 + }, + dataType: "html", + success: function(data) { + console.log(data); + }, + error: function(error) { + console.error(error); + } + }); + }, + close: function() { + $(this).dialog("destroy"); + } + }) + .show(); +} diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index ac80788a7f..adbb82890f 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -342,7 +342,8 @@ var test_sound = false; function test_sound_button() { if (!test_sound) { $("#button_try").attr('src', '../../images/icono_test.png'); - $('body').append("