Bash: Create Simple Server System Information

Bash: Create Simple Server System Information

A few days ago, at the time when i’m free and i have completed all of my jobs, i was walking around a few of web hosting provider’s websites to get reading. I found that most of them have the uptime statuses of their servers, and it is kind of exclaimed if we have something like that too, we can display our box status and we will always know our box system information without typing command one by one in ssh. So the idea is creating a simple bash script that will show some information like uptime, memory usage, disk usage, port status, etc., and export the statuses to txt or html file so we can we can see our box statuses with browser. It is good when we are not in home so we can check the statuses from phone, laptop, or computer somewhere. Okay, let’s get it on!

First we will check the box uptime status by using uptime command, and you will get the following result:

05:35:16 up 21:40,  1 user,  load average: 0.00, 0.00, 0.00

The informations shown above are server time, uptime, current user, and load average, but we only need uptime to be displayed right? So we’re going cut off another statuses and grab uptime only.

uptime | awk {'print $3'}

and we got:

21:40,

You can use that for displaying uptime status which means 21 hours and 40 minutes, but it’s not so good because there’s a comma character in the end of status right? If you wanna throw that comma character then we should display 5 characters before comma. (more…)

{ 0 comments }