1. Query 1 SELECT @@servername as ServerName, command, percent_complete,total_elapsed_time, estimated_completion_time, start_time FROM sys.dm_exec_requests WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')
echo "run custom_service.sh <name_service>" PIDX=${1} # Mendapatkan PID dari proses mariadbd MARIADB_PID=$(pgrep $PIDX)
# Mendapatkan informasi tentang proses mariadbd dari top TOP_INFO=$(top -n 1 -b -p "$MARIADB_PID" | tail -n +8 | head -n 1) Mem_Total_mb=$(free -m | awk 'NR==2{printf "%.f", $2 }') Mem_Total_gb=$(free -m | awk 'NR==2{printf "%.2f", $2/1024 }')
# Mengekstrak nilai CPU dan penggunaan memori dari output top CPU_USAGE=$(echo "$TOP_INFO" | awk '{print $9}') MEMORY_USAGE=$(echo "$TOP_INFO" | awk '{print $10}') MEMORY_B=$(echo "$TOP_INFO" | awk '{print $6 }')
echo "CPU Usage(%) $PIDX : ${CPU_USAGE}%" echo "Memory Usage(%) $PIDX: ${MEMORY_USAGE}%" echo "Memory Usage $PIDX : ${MEMORY_B}" echo "Memory Total Server : $Mem_Total_mb MB or $Mem_Total_gb GB"