Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created August 2, 2017 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishu3101/57bca4c81229db42ab8b699531229478 to your computer and use it in GitHub Desktop.
Save ishu3101/57bca4c81229db42ab8b699531229478 to your computer and use it in GitHub Desktop.
Run code using Python, Javascript, Ruby, PowerShell & more online
  • https://tio.run - Try It Online (TIO) is a family of online interpreters for an evergrowing list of practical and recreational programming languages.
  • https://repl.it - repl.it is a cloud coding environment for Python, Ruby, Javascript, Node, React Native & more
@himakiran19
Copy link

#!/bin/bash

Get hostname

hostname=$(hostname)

Get memory usage

memory_usage=$(free | awk '/Mem/{printf("%.2f%", $3/$2*100)}')

Get disk space usage

disk_usage=$(df -h | awk '//$/{printf("Free Space: %s (%s free)", $4, $5)}')

Get CPU usage

cpu_usage=$(top -bn1 | grep "Cpu(s)" | awk '{printf("%s%", $2)}')

Print the report

echo "Health Check Report on $hostname"
echo "Memory Usage: $memory_usage"
echo "Disk Space:"
echo "Drive /: $disk_usage"
echo "CPU Usage: $cpu_usage"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment