apex and apache sessions etc
This commit is contained in:
parent
66e20186f2
commit
b7a31e7c01
@ -8,42 +8,42 @@
|
||||
{
|
||||
"tag": "tablespace_usage",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/tablespaceUsage.sh;sleep 5;cat /tmp/tablespace_usage.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/tablespaceUsage.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "datafile_usage",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/datafileUsage.sh;sleep 5;cat /tmp/datafile_usage.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/datafileUsage.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "db_version_info",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/db_version_info.sh;sleep 5;cat /tmp/db_version_info.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/db_version_info.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apex_usage",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/apexUsage.sh;sleep 5;cat /tmp/apex_usage.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apexUsage.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apex_mail_queue",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/apex_mail_queue.sh;sleep 5;cat /tmp/apex_mail_queue.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apex_mail_queue.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apex_smtp_settings",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/apex_smtp_settings.sh;sleep 5;cat /tmp/apex_smtp_settings.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apex_smtp_settings.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apex_bot_hits",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/apexBots.sh;sleep 5;cat /tmp/apex_bots.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apexBots.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "top_redo_sql",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/topRedoSQL.sh;sleep 5;cat /tmp/top_redo_sql.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/topRedoSQL.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "top",
|
||||
@ -58,7 +58,7 @@
|
||||
{
|
||||
"tag": "process_finder",
|
||||
"type": "command",
|
||||
"content": "/opt/ticket-ai/src/scripts/processfinder.sh;sleep 5;cat /tmp/findsql.tmp"
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/processfinder.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "ords_config",
|
||||
@ -93,7 +93,27 @@
|
||||
{
|
||||
"tag": "journalctl",
|
||||
"type": "command",
|
||||
"content": "output=$(journalctl -p 3 -xb) && echo \"$output\""
|
||||
"content": "output=$(journalctl -p 3 -xb | tail -n 200) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apache_connections",
|
||||
"type": "command",
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apache_connections.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "os_session_summary",
|
||||
"type": "command",
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/os_session_summary.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "check_email_ports",
|
||||
"type": "command",
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/check_email_ports.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "apex_activity",
|
||||
"type": "command",
|
||||
"content": "output=$(/opt/ticket-ai/src/scripts/apex_activity.sh) && echo \"$output\""
|
||||
},
|
||||
{
|
||||
"tag": "postqueue",
|
||||
|
||||
9
src/scripts/apache_connections.sh
Executable file
9
src/scripts/apache_connections.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Count established connections on ports 80 and 443
|
||||
connections=$(netstat -an | grep ':80 ' | grep ESTABLISHED | wc -l)
|
||||
https_connections=$(netstat -an | grep ':443 ' | grep ESTABLISHED | wc -l)
|
||||
|
||||
echo "Active HTTP connections: $connections"
|
||||
echo "Active HTTPS connections: $https_connections"
|
||||
|
||||
@ -26,7 +26,7 @@ run_query() {
|
||||
ALTER SESSION SET CONTAINER = $container_name;
|
||||
|
||||
-- Print the container name for clarity
|
||||
PROMPT Bot Hits on APEX for container: $container_name;
|
||||
PROMPT Bot Hits on APEX in last 1 hour for container: $container_name;
|
||||
|
||||
SELECT
|
||||
AGENT,
|
||||
@ -86,5 +86,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
@ -76,5 +76,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
82
src/scripts/apex_activity.sh
Executable file
82
src/scripts/apex_activity.sh
Executable file
@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# File paths for output
|
||||
OUTPUT_FILE="/tmp/apex_activity.tmp"
|
||||
PDB_LIST_FILE="/tmp/pdb_list.tmp"
|
||||
> "$OUTPUT_FILE" # Clear the output file before starting
|
||||
touch $OUTPUT_FILE
|
||||
chown oracle $OUTPUT_FILE
|
||||
|
||||
# Function to execute the APEX User Hits query in a specific container
|
||||
run_query() {
|
||||
local container_name="$1"
|
||||
su - oracle -s /bin/bash -c "
|
||||
sqlplus -s / as sysdba <<EOF >> \"$OUTPUT_FILE\"
|
||||
whenever sqlerror exit sql.sqlcode;
|
||||
SET ECHO ON
|
||||
SET HEADING ON
|
||||
SET UNDERLINE '='
|
||||
SET FEEDBACK OFF
|
||||
SET LINESIZE 150
|
||||
SET PAGESIZE 100
|
||||
COLUMN WORKSPACE FORMAT A40
|
||||
COLUMN HIT_COUNT FORMAT 999999
|
||||
|
||||
-- Switch to the specified container
|
||||
ALTER SESSION SET CONTAINER = $container_name;
|
||||
|
||||
-- Print the container name for clarity
|
||||
PROMPT APEX Session Count in last 1 hour for container: $container_name;
|
||||
|
||||
SELECT
|
||||
WORKSPACE,
|
||||
COUNT(*) AS HIT_COUNT
|
||||
FROM
|
||||
APEX_WORKSPACE_ACTIVITY_LOG
|
||||
WHERE
|
||||
VIEW_DATE BETWEEN SYSDATE - (1/24) AND SYSDATE
|
||||
GROUP BY
|
||||
WORKSPACE
|
||||
ORDER BY
|
||||
HIT_COUNT DESC;
|
||||
|
||||
|
||||
exit;
|
||||
EOF
|
||||
"
|
||||
}
|
||||
|
||||
# Run the query for the CDB (root container)
|
||||
# echo "Gathering Hits for CDB (root container)..." >> "$OUTPUT_FILE"
|
||||
# run_query 'CDB\$ROOT'
|
||||
|
||||
# Get a list of all PDBs, excluding PDB$SEED, and write to a temporary file
|
||||
su - oracle -s /bin/bash -c "
|
||||
sqlplus -s / as sysdba <<'EOF'
|
||||
set heading off
|
||||
set feedback off
|
||||
set pagesize 0
|
||||
spool $PDB_LIST_FILE
|
||||
SELECT NAME FROM v\$pdbs WHERE NAME NOT IN ('PDB\$SEED');
|
||||
spool off
|
||||
exit;
|
||||
EOF
|
||||
"
|
||||
|
||||
# Verify that the PDB_LIST_FILE was created and contains data
|
||||
if [[ -f "$PDB_LIST_FILE" && -s "$PDB_LIST_FILE" ]]; then
|
||||
# Read each valid PDB name from the temporary file
|
||||
while IFS= read -r PDB; do
|
||||
PDB=$(echo "$PDB" | xargs) # Trim any leading/trailing whitespace
|
||||
if [[ -n "$PDB" ]]; then
|
||||
echo "Gathering APEX User Hits for PDB: $PDB..." >> "$OUTPUT_FILE"
|
||||
run_query "$PDB"
|
||||
fi
|
||||
done < "$PDB_LIST_FILE"
|
||||
else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
# Clean up the temporary file
|
||||
cat "$OUTPUT_FILE"
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
@ -75,5 +75,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
@ -88,5 +88,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
13
src/scripts/check_email_ports.sh
Executable file
13
src/scripts/check_email_ports.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
ports="25 465 587 143 110 993 995"
|
||||
file="/etc/sysconfig/iptables"
|
||||
|
||||
echo "Checking iptables rules for required ports:"
|
||||
for port in $ports; do
|
||||
if grep -q -- "--dport $port" $file; then
|
||||
echo "Port $port is allowed in $file"
|
||||
else
|
||||
echo "Port $port is NOT allowed in $file"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -83,5 +83,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
@ -92,5 +92,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
76
src/scripts/os_session_summary.sh
Executable file
76
src/scripts/os_session_summary.sh
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Declare an associative array for grouping
|
||||
declare -A summary
|
||||
|
||||
# Iterate through each running process
|
||||
while read -r process; do
|
||||
if [[ $process == ora_* || $process == oracle* ]]; then
|
||||
summary["Oracle"]=$((summary["Oracle"] + 1))
|
||||
elif [[ $process == php-fpm* ]]; then
|
||||
summary["PHP-FPM"]=$((summary["PHP-FPM"] + 1))
|
||||
elif [[ $process == httpd* ]]; then
|
||||
summary["HTTPD"]=$((summary["HTTPD"] + 1))
|
||||
elif [[ $process == sshd* ]]; then
|
||||
summary["SSHD"]=$((summary["SSHD"] + 1))
|
||||
elif [[ $process == systemd* ]]; then
|
||||
summary["SystemD"]=$((summary["SystemD"] + 1))
|
||||
elif [[ $process == zabbix* ]]; then
|
||||
summary["Zabbix"]=$((summary["Zabbix"] + 1))
|
||||
elif [[ $process == python* || $process == python3* ]]; then
|
||||
summary["Python"]=$((summary["Python"] + 1))
|
||||
elif [[ $process == node* ]]; then
|
||||
summary["Node.js"]=$((summary["Node.js"] + 1))
|
||||
elif [[ $process == bash* || $process == sh* ]]; then
|
||||
summary["Shell"]=$((summary["Shell"] + 1))
|
||||
elif [[ $process == java* ]]; then
|
||||
summary["Java"]=$((summary["Java"] + 1))
|
||||
elif [[ $process == tnslsnr* ]]; then
|
||||
summary["TNS Listener"]=$((summary["TNS Listener"] + 1))
|
||||
elif [[ $process == dovecot* || $process == postfix* || $process == saslauthd* ]]; then
|
||||
summary["Mail"]=$((summary["Mail"] + 1))
|
||||
elif [[ $process == NetworkManager* ]]; then
|
||||
summary["NetworkManager"]=$((summary["NetworkManager"] + 1))
|
||||
elif [[ $process == cron* || $process == crond* ]]; then
|
||||
summary["Cron"]=$((summary["Cron"] + 1))
|
||||
else
|
||||
summary["Uncategorized"]=$((summary["Uncategorized"] + 1))
|
||||
fi
|
||||
done < <(ps -eo comm=)
|
||||
|
||||
# Print the summary
|
||||
echo "Program-wise session summary:"
|
||||
for program in "${!summary[@]}"; do
|
||||
printf "%-15s %s\n" "$program" "${summary[$program]}"
|
||||
done
|
||||
|
||||
|
||||
|
||||
# Declare an associative array for user sessions
|
||||
declare -A user_sessions
|
||||
declare -A active_users
|
||||
|
||||
# Fetch loginctl session details and process them
|
||||
while read -r session user_id state; do
|
||||
# Get username from user ID using getent
|
||||
username=$(getent passwd "$user_id" | cut -d: -f1)
|
||||
# If username is valid, count sessions
|
||||
if [[ -n $username ]]; then
|
||||
user_sessions["$username"]=$((user_sessions["$username"] + 1))
|
||||
# Check if the session is active
|
||||
if [[ $state == "active" ]]; then
|
||||
active_users["$username"]=1
|
||||
fi
|
||||
fi
|
||||
done < <(loginctl list-sessions --no-legend | awk '{print $1, $2, $3}')
|
||||
|
||||
# Print the user-wise session summary
|
||||
echo "User-wise session summary from loginctl (with usernames):"
|
||||
printf "%-15s %-10s %-10s\n" "Username" "Sessions" "Connected"
|
||||
for username in "${!user_sessions[@]}"; do
|
||||
connected="No"
|
||||
if [[ ${active_users[$username]} -eq 1 ]]; then
|
||||
connected="Yes"
|
||||
fi
|
||||
printf "%-15s %-10s %-10s\n" "$username" "${user_sessions[$username]}" "$connected"
|
||||
done
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define the CPU usage threshold
|
||||
CPU_THRESHOLD=60
|
||||
CPU_THRESHOLD=50
|
||||
|
||||
# File path for output
|
||||
OUTPUT_FILE="/tmp/findsql.tmp"
|
||||
@ -51,3 +51,5 @@ EOF
|
||||
else
|
||||
echo "No Oracle processes consuming significant CPU" > "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
@ -24,3 +24,5 @@ EOF
|
||||
|
||||
# Notify user about the location of the output file
|
||||
echo "Database parameters have been saved to $OUTPUT_FILE"
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
@ -86,5 +86,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f "$PDB_LIST_FILE"
|
||||
|
||||
@ -103,5 +103,6 @@ else
|
||||
echo "No PDBs found or could not access v\$pdbs view" >> "$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
cat "$OUTPUT_FILE"
|
||||
# Clean up the temporary file
|
||||
rm -f
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user