Sunday, July 2, 2017

I/O error, dev fd0, sector 0

This happens in my Ubuntu VM and the log usually have these 2 messages

[  148.462686] blk_update_request: I/O error, dev fd0, sector 0
[  148.462735] floppy: error -5 while reading block 0

To get rid of those messages:

echo "blacklist floppy" | sudo tee /etc/modprobe.d/blacklist-floppy.conf

sudo rmmod floppy

sudo update-initramfs -u

After reboot, you can verify that floppy module (lsmod | grep floppy) no longer get loaded automatically and there is no such messages in the log anymore.

Monday, June 12, 2017

Ubuntu download deb packages without installing

To download without installaing, just use the following command

apt-get -d install package

Once done, you can go /var/cache/apt/archives to retrieve the packages you had downloaded.

Wednesday, May 24, 2017

How to print Gmail email without header information

First click on the printer button


Click cancel when prompted

Go to Developer Tools


Once you in Deveoper tools mode, you will notice there is a new pane below that show all the HTML code. Expand bodycontainer div class, when you mouse over the first table element, you will notice the section on top will be highlighted as well. This means that particular HTML code is the one that generated the highlighted section. Delete this table element.


And you will notice that Gmail header is no longer there.


Repeat these steps with other element such as

hr - to remove the seperator
first table element under maincontent div class - to remove message header
first and second tr element under message table - to remove sender and receipeint email.

After deleting the unwanted header information, you will get a clean message content. And you can proceed to print it.




Monday, August 31, 2015

How to test UDP port is responding

Using the following command will do the trick.

# nc -zuv 3 192.168.123.123 5140
Connection to 192.168.123.123 5140 port [udp/*] succeeded!

Tuesday, August 25, 2015

Linux Biscuit!


Docker 1.8 with td-agent 2.2.1 container

This is a quick guide on setting up td-agent container with Docker 1.8

  1. Create a directory to store your dockerfile and td-agent config file. 
  2. mkdir ~/td-agent-es && cd ~/td-agent-es
    
  3. Create a dockerfile as shown below
  4. Create td-agent.conf file as shown below
  5. Build the docker image
  6. docker build -t td-agent-es .
    
  7. Start elasticsearch container. As you can see from the td-agent.conf, the td-agent container will link to this elasticsearch container. Please note that this setup is not using any persistent storage mapping. You can refer to this link for more information on how to setup that mapping.
  8. docker run -d -p 9200:9200 -p 9300:9300 --name es elasticsearch
    
  9. Start your td-agent container 
  10. docker run -d -p 24224:24224 --link es:es --name td-agent td-agent-es
    
  11. Launch a hello-world to see if td-agent is forwarding log to elasticsearch container. Please note that Docker 1.8 add fluentd as one of the logging-driver. So this command will not work if you are using Docker with older version
  12. docker run --log-driver=fluentd --log-opt fluentd-address=[your-host-IP-address]:24224 hello-world
  13. Use the following command to check if elasticsearch container is receiving log. You can check container ID or container name using docker ps -a
  14. curl -XGET 'http://[your-host-IP-address]:9200/_all/_search?q=*'
    

Tuesday, August 18, 2015

Install jobber on CentOS 6.*


All the commands below are executed using root user
  1. Install go and git if you not already do so
  2. yum install go
    yum install git
  3. You need to specify workspace directory, this can be any path in your system. For this example, i use the following directory as the workspace - /home/amd/go
  4. Set the $GOPATH to this workspace directory
  5. export GOPATH=/home/amd/go
    
  6. Change directory to your workspace directory and run the following command to get the jobber files.
  7. go get github.com/dshearer/jobber
    
  8. As git supplied by CentOS 6 is version 1.7.1 and it cannot handle gopkg.in in package properly. If this is not down, you will encounter hang problem during compilation process. So you need to manually get the yaml.v2 package.
  9. git clone --branch v2 https://github.com/go-yaml/yaml $GOPATH/src/gopkg.in/yaml.v2
    
  10. Compile jobber package
  11. make -C src/github.com/dshearer/jobber
    
  12. Before proceed to next step, install daemonized if not already do so.
  13. yum install daemonize
    
  14. Install jobber
  15. make install -C src/github.com/dshearer/jobber
    
  16. Running the following command and you can see jobber service is running.
  17. service jobber status
    
  18. To create a scheduled job, you need to create .jobber file under user home directory. jobber file are written in YAML format.
  19.  ---
    - name: DailyBackup
      cmd: backup daily
      time: 0 0 13
      onError: Stop
      notifyOnError: false
      notifyOnFailure: true
    
  20. Once it is created, you need to load the job
  21.  /usr/local/bin/jobber reload
    
  22. You can check the log of the job using this command.
  23.  /usr/local/bin/jobber log