- View the hostname of the system
- View system date and time
- Check the free memory
- Check Hard disk free space
- Check status of some regular services (you may need to edit the script to add your own services and daemons)
- View system ip address information
- Check internet connection by pinging to the domain "google.com"
- Check the system uptime
- List all the currently logged in users (including remote SSH logins)
- Review system processes and CPU load
- Schedule a shutdown
[root@server ~] vi basic_info
#Now add all the below text(green in colour) to the file
#!/bin/bash
clear
menu=
time=
echo "=========== =========== ========="
echo "WELCOME TO MACHINE INFO SCRIPT"
echo "=========== =========== ========="
echo "WELCOME TO MACHINE INFO SCRIPT"
echo "=========== =========== ========="
echo "1: View the hostname of this machine"
echo "2: View system date and time"
echo "3: Check free RAM space"
echo "4: Check Hard disk free space"
echo "5: Check status of regular services"
echo "6: View system ipaddress information"
echo "7: Check internet connection (ping to Google)"
echo "8: Check how long system is running"
echo "9: List the current logged in users information"
echo "10: Review system process and cpu"
echo "11: Schedule a shutdown"
echo "0: Exit from Script"
until [ "$menu" = "0" ]; do
echo -n "enter menu selection>"
read menu
if [ "$menu" = "0" ]; then
echo "Bye, Exiting Script...." $exit
fi
case $menu in
1 ) hostname ;;
2 ) date ;;
3 ) free -m ;;
4 ) df -h ;;
5 ) service postfix status
service dovecot status
service squid status
service smb status
service openvpn status
service vsftpd status
service httpd status
service dhcpd status
service named status ;;
6 ) ifconfig ;;
7 ) ping google.com ;;
8 ) uptime ;;
9 ) w ;;
10 ) top ;;
11 ) echo -n "enter the shutdown time in 24hr format(eg: 14:45)>"
read time
echo " Your linux machine will shutdown at $time"
shutdown -h $time ;;
esac
0 comments:
Post a Comment