Is Your System Health Status Tested/Checked Today... ????
#!----Here is a script to check the basic health status of a Linux system---#!
[[ Updated on 9th Sep 2024]]
This script has been tested to run successfully on RHEL9/8/7/6, SLES/SLED 15/12/11, Ubuntu24/22/18/16, Alma, Rocky, Boss6(Debian) etc,.x86 and x86_64 bit architectures. It may work on other variants as well, however, not tested. These tests were run on virtual machines.
This script has been tested to run successfully on RHEL9/8/7/6, SLES/SLED 15/12/11, Ubuntu24/22/18/16, Alma, Rocky, Boss6(Debian) etc,.x86 and x86_64 bit architectures. It may work on other variants as well, however, not tested. These tests were run on virtual machines.
This is a small, light-weight script which makes use of native Linux utilities to get the required details and doesn't need much space. This script could be added as a cron job to regularly get system details triggered via an email as desired. The script has been successfully tested to work on most popular Linux distributions. One may alter or change the script to get the desired function or task done.
Details of the script:
Name Of The Script → health-check.sh
Build To Run On → RHEL 9/8/7/6.x /SLES 15/12/11 , CentOS, Roky8/9, Alma89, Ubuntu24/22/18/16 x86/x86_64 architecture
Who Can Run This Script → Root User Or sudo user
Depends On → "sysstat" package & Other Native Commands
Output → This Script would dump the details on the console
Following checks would be performed:
→ Mounted File Systems
→ Read-only File System If Any
→ File Systems Disk Usage
→ I-node Usage
→ Zombie Processes If Found
→ RAM Utilization
→ SWAP Utilization
→ Processor Utilization
→ Current Load Average
→ Most recent reboot and shutdown stamps
→ Top 5 memory & CPU consuming resources
Let’s Download And Execute:
Now, one could download and run the script to get the basic health check of a Linux system. Use the link provided below to download the script.
Change the file permissions to executable if required. You could run the below command to turn on the execute bit for root user:
# chmod u+x health-check.sh
If you are unable to download and move this script file to your Linux system then you may need to copy the complete contents of the file as it is and paste into your file, set execute bit and run it later.
Errors while executing script:
If there are any errors as listed below:
- health-check.sh: line 12: $'\r': command not found
- syntax error near unexpected token `||' or "-bash:
- ./health-check.sh: /bin/bash^M: bad interpreter: No such file or directory
then it could due some character conversion or interpretations when file is copied to Unix/Linux shell, and to resolve this run the command:
# sed -i -e 's/\r$//' health-check.sh
All the best!
More advanced version of this script file which can scan complete Linux system and pull out all hardware details is available as 'hwlist' package. Refer this blog page for more details:
https://www.simplylinuxfaq.com/p/how-to-find-hardware-details-in-linux.html
You may prefer to scan the download and then execute it. One could also perform git clone using the command "git clone https://github.com/SimplyLinuxFAQ/health-check-script.git".
View/read the release file:
View/read the script file here:
View/read a sample output file produced by running 'health-check.sh' script file :
13 comments:
A great help to me, thanks a lot.
Really Good! Thanks.
Thank you. Very useful.
Very good. Thanks : )
Thanks , very good
Keep this going please, great job!
Woah! I'm really enjoying the template/theme of this blog.
It's simple, yet effective. A lot of times it's very difficult to get that "perfect balance" between superb usability and
appearance. I must say you have done a great job with
this. In addition, the blog loads very quick for me on Firefox.
Outstanding Blog!
Nice script, thanks. Usually run a bunch of checks, now they're all nicely together!
healthcheckup.sh: line 140: syntax error near unexpected token `('
healthcheckup.sh: line 140: `paste <(echo "$COL11") <(echo "$COL33") -d' '|column -t'
Naveen, you would need to run the 'sed' command as documented in the blog page to remove extra characters that would have got added when downloaded. I tested the script today again and it is working as expected.
regarding the read-only FS section, i have a read-only FS (/data) but the script doesn't detect it.
Checking For Read-only File System[s]
-------------------------------------
.....No read-only file system[s] found.
Checking For Currently Mounted File System[s]
--------------------------------------------------------------------------
/dev/mapper/vgOS-datavol on /data type xfs (ro,relatime,seclabel,attr2,inode64,noquota)
Yes, there was a small glitch which I've fixed now and it should reflect the read-only file systems without any issue.
Hi, I am not good in bash scripting. However i found this script is easy-to-use.
got below error while executing the same script.
testing.sh: line 93: syntax error near unexpected token `('
testing.sh: line 93: `paste <(echo "$COL1") <(echo "$COL3") -d' '|column -t'
Post a Comment