diff --git a/namaskar.sh b/namaskar.sh index ed44734..f365e83 100644 --- a/namaskar.sh +++ b/namaskar.sh @@ -1,16 +1,40 @@ #!/bin/bash + +# Function to calculate percentage +get_percentage() { + used=$1 + total=$2 + awk -v used="$used" -v total="$total" 'BEGIN { printf("%.2f%%", (used / total) * 100) }' +} + +# Get memory and swap usage details +memory_usage=$(free -h --si | awk '/^Mem/ {print $3 " / " $2}') +swap_usage=$(free -h --si | awk '/^Swap/ {print $3 " / " $2}') + +# Calculate percentage for memory +memory_used=$(free --si | awk '/^Mem/ {print $3}') +memory_total=$(free --si | awk '/^Mem/ {print $2}') +memory_percentage=$(get_percentage "$memory_used" "$memory_total") + +# Calculate percentage for swap +swap_used=$(free --si | awk '/^Swap/ {print $3}') +swap_total=$(free --si | awk '/^Swap/ {print $2}') +swap_percentage=$(get_percentage "$swap_used" "$swap_total") + host=$(uname -n) user=$(whoami) -shell=$(echo $SHELL) -kernel="$(uname -r)" -shell="$(basename "${SHELL}")" -os="$(uname -s)" -uptime="$(uptime -p)" +shell=$(basename "$SHELL") +kernel=$(uname -r) +os=$(uname -s) +uptime=$(uptime -p) + +echo "" c1=$(echo -e "\e[42m \e[0m") c2=$(echo -e "\e[41m \e[0m") c3=$(echo -e "\e[43m \e[0m") c4=$(echo -e "\e[44m \e[0m") c5=$(echo -e "\e[45m \e[0m") +c6=$(echo -e "\e[46m \e[0m") cat <