refactor(monitoring): parse process list via awk
Update grep pipelines to include awk command. This ensures only the process identifier is captured instead of the full status line.
This commit is contained in:
@@ -30,7 +30,7 @@ if [ $sapcontrol_status -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Check for non-GREEN processes (skip header lines)
|
||||
non_green_processes=$(echo "$process_list" | tail -n +6 | grep -v 'GREEN' | grep -v '^$')
|
||||
non_green_processes=$(echo "$process_list" | tail -n +6 | grep -v 'GREEN' | grep -v '^$' | awk -F', ' '{print $1}')
|
||||
|
||||
if [ -n "$non_green_processes" ]; then
|
||||
log_message "$SCRIPT_NAME" "ALERT: One or more HANA processes are not running!"
|
||||
@@ -40,7 +40,7 @@ if [ -n "$non_green_processes" ]; then
|
||||
fi
|
||||
|
||||
# Verify we actually got process data
|
||||
green_processes=$(echo "$process_list" | tail -n +6 | grep 'GREEN')
|
||||
green_processes=$(echo "$process_list" | tail -n +6 | grep 'GREEN' | awk -F', ' '{print $1}')
|
||||
if [ -z "$green_processes" ]; then
|
||||
log_message "$SCRIPT_NAME" "WARNING: No process data found. SAP HANA may not be running."
|
||||
send_alert "$SCRIPT_NAME" "HANA Process" "No process data found. SAP HANA may not be running."
|
||||
|
||||
Reference in New Issue
Block a user