Last active
September 3, 2022 03:04
-
-
Save 0xjairo/fb5e749ced15dd5d3d986194eca398e2 to your computer and use it in GitHub Desktop.
GeekTool System Monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Modified from: | |
# http://www.macosxtips.co.uk/geeklets/system/comprehensive-system-monitor-yosemite/ | |
# Make sure you change the following variable | |
# to match the network interface you would like to monitor | |
nic=en3 | |
echo ------- System Information ------ | |
# Find current bandwith in each pipe | |
myvar1=`netstat -bI ${nic} | awk "/${nic}/"'{print $7;exit}'` | |
myvar3=`netstat -bI ${nic} | awk "/${nic}/"'{print $10;exit}'` | |
sleep 1 | |
# Find current bandwith in each pipe after a second. | |
myvar2=`netstat -bI ${nic} | awk "/${nic}/"'{print $7;exit}'` | |
myvar4=`netstat -bI ${nic} | awk "/${nic}/"'{print $10;exit}'` | |
# Find the difference between each pipe after 1 second. | |
subin=$(($myvar2 - $myvar1)) | |
subout=$(($myvar4 - $myvar3)) | |
# Convert the bytes to kilobytes | |
kbin=`echo "scale=2; $subin/1024;" | bc` | |
kbout=`echo "scale=2; $subout/1024;" | bc` | |
# Current CPU usage | |
cpu="`ps -A -o %cpu | awk '{s+=$1} END {print s "%"}'`" | |
# Current Memory Usage | |
mem="`ps -A -o %mem | awk '{s+=$1} END {print s "%"}'`" | |
# Current Disk Usage | |
hdd="`df -h | grep -E "disk1\s+" | awk '{print $3}' | sed 's/Gi$//'` GB" | |
echo "CPU:$cpu Mem:$mem Disk:$hdd" | |
echo | |
# Current IP Address | |
# Current Network Traffic | |
echo "IP address: `ipconfig getifaddr ${nic}`" | |
echo "Up:$kbout KB/s Down:$kbin KB/s" | |
# Current uptime | |
echo Uptime: `uptime | sed -E "s/^[0-9]+:[0-9]+[[:space:]]+up //" | sed -E "s/, [0-9] users.*//"` | |
echo | |
# Install iStats for the following to work: | |
# gem install iStats | |
# Current CPU Temp | |
istats cpu | |
# Current Fan speed | |
istats fan speed | |
echo | |
# Battery | |
istats battery time | |
istats battery temp | |
istats battery charge | |
# Top 10 processes | |
echo | |
echo --------- Top Processes --------- | |
ps -ecrwwo "command pid %cpu %mem" | head -n 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script intended to be called from GeekTool and originally modified from
http://www.macosxtips.co.uk/geeklets/system/comprehensive-system-monitor-yosemite/