#!/bin/bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Copyright (c) 2010 FSOCA final project | http://joaosantacruz.com # This script is licensed under GNU GPL version 2.0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Create a BASH script (resources.sh) to report how much memory is available on the # system (free, physical) and how much is installed. Extension: If the user has less than 20% # free memory on the system, warn them that they are running out of memory. If the user # has more than 50% free memory (swap + physical) and that the physical amount of memory # is more than 512MB, inform the user that they might be able to run Adobe Flash. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - clear echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo " Resources " echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "" total_physical="$($_CMD free -mto | grep Mem: | awk '{ print $2}')" used_physical="$($_CMD free -mto | grep Mem: | awk '{ print $3}')" free_physical="$($_CMD free -mto | grep Mem: | awk '{ print $4}')" total_swap="$($_CMD free -mto | grep Swap: | awk '{ print $2}')" used_swap="$($_CMD free -mto | grep Swap: | awk '{ print $3}')" free_swap="$($_CMD free -mto | grep Swap: | awk '{ print $4}')" echo "Physical Memory Usage - - - - - " echo "Total: $total_physical MB" echo "Used: $used_physical MB" echo "Free: $free_physical MB" echo -e "\nSwap Memory Usage - - - - - " echo "Total: $total_swap MB" echo "Used: $used_swap MB" echo "Free: $free_swap MB" free_physical_stats=$((($free_physical * 100)/$total_physical)) free_swap_stats=$((($free_swap * 100)/$total_swap)) free_stats=$(((($free_physical+$free_swap) * 100)/($total_physical+$total_swap))) #echo -e "\n Free memory is now: $free_stats%" if [ $free_physical_stats -lt 20 ] then echo -e "\nYou are running out of memory, only $free_physical_stats% of physical memory are free." fi if [[ $free_stats -gt 50 && $total_physical -gt 512 ]] then echo -e "\nYou have $free_stats% free memory (physical[$free_physical MB] + swap[$free_swap MB])" echo "Your total physical memory is more than 512MB, so you might be able to run Adobe Flash" else echo -e "\nYou have $free_stats% free memory (physical[$free_physical MB] + swap[$free_swap MB]) and $total_physical MB \nof total physical memory. You WON'T be able to run Adobe Flash." fi echo "" echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "Press [enter] key to continue. . ."; read pressedKey