Articles with category - Linux

Health checking on your websites

Posted on 1 year ago by Ping Cheng

If you are running one or a few your websites, you definitely would like to avoid any access issue to your site. However, you cannot stop it happens. When your website does have some access issues, you need to know at the first place before any of your visitors, and then you can have some time to fix it.

A straightforward way to monitor your website is writing a small script that can send a request to your site and check if the response is what we are expected. If you cannot hear a response or the response is something you are not acceptable, then an issue can be identified and send a notification to your preferred channel.

This is a very simple python script that we can use


import urllib
import json
import urllib2
import time

def notify_slack(options):
    wekbhook_url = 'my-slack-webhook-url'
    data = json.dumps(options)
    request = urllib2.Request(wekbhook_url, data)
    urllib2.urlopen(request)

def check_url(url, expected_status = 200):
    try:

...

[ Read More ]


Change time zone for CentOS 7

Posted on 2 years ago by Ping Cheng

To have a good log file in your running CentOS server, it is necessary to maintain a good server's time system. Usually you will find the server's time is not quite same as your local time because that the default settings of server would set the timezone to UTC, while your local timezone may be different.

To set the timezone correctly, you can use the following command to change server's timezone:

Firstly, lets backup the current timezone file, in case you do not have a valid time zone configuration

sudo mv /etc/localtime /etc/localtime.bak

Then, let us set the correct time zone

sudo ln -s /usr/share/zoneinfo/Australia/Melbourne /etc/localtime

After above two commands, your server should response the correct date and time now, try use command date to verify if you have a correct configuration.


Extending a Linux File System after Resizing the Volume

Posted on 3 years ago by Ping Cheng

Article source: AWS

This is a log to keep a note to help me on resizing the linux file system in the future. The steps are :

adjust the volume on the AWS, and wait for the complete of volume resizing process

check if the disk was resized

lsblk

extend the disk

sudo growpart /dev/xvdf 1

resize the volume to the new capacity (I am using the xfs file system, other file systems command may be different)

sudo xfs_growfs -d /mnt

check the new volume size

df -h
Search
Hand crafted with by Ping Cheng