Get hostname by socket.gethostname

The script doesn't work properly if you try to get hostname by $HOSTNAME. Changed to get by socket.gethostname() method.