Write a Shell Bash Script for report server related information
#!/bin/bash | |
date | |
echo "uptime:" | |
uptime | |
echo "Currently connected:" | |
w | |
echo "--------------------" | |
echo "Last logins:" | |
last -a | head -3 | |
echo "--------------------" | |
echo "Disk and memory usage:" | |
df -h | xargs | awk '{print "Free/total disk: " $11 " / " $9}' | |
free -m | xargs | awk '{print "Free/total memory: " $17 " / " $8 " MB"}' | |
echo "--------------------" | |
start_log=$(head -1 /var/log/messages | cut -c 1-12) | |
oom=$(grep -ci kill /var/log/messages) | |
echo -n "OOM errors since $start_log :" $oom | |
echo "" | |
echo "--------------------" | |
echo "Utilization and most expensive processes:" | |
top -b | head -3 | |
echo | |
top -b | head -10 | tail -4 | |
echo "--------------------" | |
echo "Open TCP ports:" | |
nmap -p -T4 127.0.0.1 | |
echo "--------------------" | |
echo "Current connections:" | |
ss -s | |
echo "--------------------" | |
echo "processes:" | |
ps auxf --width=200 | |
echo "--------------------" | |
echo "vmstat:" | |
vmstat 1 5 |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND
Sir,
How can we get remote server information, In this programme we can get local server details.
Nice article sir