Sending mails from munin using custom command

We use Sendgrid for email delivery on our cloud. Using custom commands in munin can be tricky. After struggling for some time I wrote a small python script to send emails from munin using sendgrid.

Add this line to munin.conf

contacts mycontact
contact.mycontact.command /usr/bin/sendemail "[Munin] Alert for ${var:host}" "warnings: ${var:wfields} / criticals: ${var:cfields}"
contact.mycontact.text text

Save this file as sendemail in /usr/bin and give it execute permission using chmod +x /usr/bin/sendemail. You should configure the email and sendgrid login details before using this script.

import smtplib, sys
from email.mime.text import MIMEText
from email.Header import Header


if len(sys.argv) < 3:
    print 'Usage: ./sendemail "" "This is the subject" "This is the email text"'

smtp = smtplib.SMTP('', 2525, '')

emailIds = sys.argv[1].split(',')
subject = sys.argv[2]
body = sys.argv[3]

message = MIMEText(body)
message['Subject'] = Header(subject)
message['From']    = DEFAULT_SENDER
message['To']      = ','.join(emailIds)

smtp.sendmail(DEFAULT_SENDER, emailIds, message.as_string())

You should start receiving alerts from munin.

Motorcycle review: Bajaj Avenger 2013

I bought Avenger in July 2013. Specification can be read at I have toured extensively in Karnataka and Leh, so I think this review will definitely help you make up your mind.


  • Engine: The 220 cc engine gets you off from 0-60 pretty quickly. This is a cruiser so couple of seconds does not matter. It will accelerate till 80 fairly. Once you cross 90 there is not much power left in the bike, you will accelerate very slowly. It will get you till 110. You will feel the vibrations on the foot pegs after 90. The sweet spot is between 70-90. You can just relax and cruise on an open road at that speed and you will absolutely love the ride.
  • Maneuverability: Since it is long (longer than RE Bullet also) and quite heavy so it is quite frustrating to ride in traffic. It feels really heavy when riding at speeds below 30. It needs more area to make u-turns. But once you touch 40 it feels lighter, you can even lean at corners.
  • Mileage: In city I get around 28-32 km/l and on highway around 35-38 km/l. I rev the engines hard so I can’t complain on the mileage. People have managed to get 45 on highways.


  • Big seat : This was a big factor while choosing this bike. Since I wanted to ride long distance I wanted comfortable seats. The stock seats were better than other bikes but I added a gel pad and 0.5′ foam on top of the seat for more comfort.
  • Seating position: The low seating position with legs stretched out gives you a chair like seat, which is quite comfortable. The “Feel like god” tagline makes perfect sense when you hop on it. It may take you a while to get used to it though. I am 6 feet tall and weigh 82 kg and I find it extremely comfortable. Be prepared for some splashes in the rainy season though 😉
  • Good Headlights: The default head lights are good. The whole road will be lit perfectly in high beam.
  • Chrome: Bajaj has used sufficient chrome on it to make it shine. I absolutely love it.
  • Electric Ignition: It comes only with an electric ignition. I have not faced any problem with starting even while I was in Leh. Just one push of the button and the engine will come to life.
  • Back Rest: There is a back reset for pillion rider. I use to to strap my luggage :)
  • Types: The MRF Zappier tyres are good. I have done 15,000 km and they still look good. I have had only one puncture.


  • Braking: The front tyre is stretched out, so it can be a nightmare at turns and skids at times. You will learn how to use both the brakes to control it.
  • Odo/Speedometer/Indicator: It comes with analog meters. The speedometer starts swinging once you cross 100 km/hr. I have managed to clock 115 km/hr on it but I am not sure how faulty the meter was. The turn, high beam and neutral indicators are slapped on the tank so you have to look down to see it which is really annoying. There is no RPM indicator.
  • Fuel Gauge: The fuel gauge is faulty. You just can’t depend on it. I have also noticed water droplets inside the fuel gauge. This has been seen on other avenger bikes, wonder why they have not fixed it.
  • Tank Capacity: It can hold 14 litres of petrol. I wish the tank was bigger.
  • Rear View Mirror: The stock mirrors are really bad. I have to change mine.
  • Pillion Seat: The pillion seat is very small, good for only city rides.
  • Rider Foot Pegs: I wish the foot pegs were a little more forward. It would have made the seating position more relaxed.
  • Suspensions: The rear suspensions are hard and you will feel every bump on your butts.
  • Gear: The gear shifting in not smooth. It gets stuck during down shifting.

It is really a good motorcycle for the price you pay. I wish Bajaj did something to improve its design and performance.

Winter Ride

2014 was an incredible year for me. I travelled a lot. I decided to end this year with another ride with some fellow bikers. This was a 4-day ride in which I covered Mudigere, Kudremukh, Sringeri, Agumbe, Chikmanglur and Mullayangiri.

We rode on the first day to Mudigere. A home stay was arranged for stay. It was a very secluded place and it took us a while to locate the place.

Breakfast break

We went to a sun set point to spend the evening.

Next day I left for Sringeri for another solo ride. The roads were not very good. However Kudremukh forests were particularly very scenic to ride on.

Almost dried Bhadra river

Inside Kudremukh saw a sign board for a dam, so decided to check it out :) It looked more like a desert than dam at this point since the river had dried.


A little more chrome?

Kadambi waterfall

Reached Agumbe sunset point around 3:45 pm. It was extremely crowded so I decided to head back to Sringeri and find a stay.

Sun set

Sringeri – Chikmanglur

Condition of road was pretty bad at the start. I had started around 6:30 am. It was extremely foggy. At one point I felt like I should head back to the hotel. Once the sun was out fog went away and the roads improved.

Water droplets on cobwebs.


Headed back to Bangalore next day. Reached 1000 km on odo somewhere on NICE road.


Setting up VPN using OpenVPN on Google Cloud or AWS

VPN is a good way to protect your cloud infrastructure from attacks. In the method below I will list down the step how to log in to your vpn machine and access the cloud LAN from you laptop.

I am using Debian on Google Cloud as an example. The setup process should be similar on other clouds. The cloud lan is in the network and the vpn lan will be in the network

1. Setup firewall rules to allow connection to vpn machine:
Networks > your network (usually named default) > Firewall rules:

Create new:
Name: VPN Traffic
Source IP Ranges:
Allowed Protocols/Ports: tcp:1194
Target Tags: vpn

2. Spawn a new debain machine, go to advanced and tag it vpn. Also enable IP Forwarding.

Log in and run this:
“sudo sysctl -w net.ipv4.ip_forward=1“
Make the same change in “/etc/sysctl.conf“

3. Install openvpn:

sudo apt-get update
sudo apt-get install openvpn

4. Set up openvpn

* Create a new directory with the command sudo mkdir /etc/openvpn/easy-rsa/.
* Copy the necessary files with the command sudo cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/.
* Change the ownership of the newly copied directory with the command sudo chown -R $USER /etc/openvpn/easy-rsa/.
* Edit the file /etc/openvpn/easy-rsa/vars and change the variables listed below.

The variables to edit are:

export KEY_CITY="SanFrancisco"
export KEY_ORG="Uberlabs"
export KEY_EMAIL=""
export KEY_CN="FooBar"

Once the file has been edited and saved, we’ll run several commands must be entered in order to create the certificates:

cd /etc/openvpn/easy-rsa/
source vars
./pkitool --initca
./pkitool --server server
cd keys
sudo openvpn --genkey --secret ta.key
sudo cp server.crt server.key ca.crt dh1024.pem ta.key /etc/openvpn/

Client Certificates

The clients will need to have certificates in order to authenticate to the server. To create these certificates, do the following:

change KEY_CN in vars file everytime you create a new client cert, else you will notice that hostname.crt is of 0 bytes. Or you can use KEY_CN=someuniqueclientcn ./pkitool client1.

cd /etc/openvpn/easy-rsa/
source vars
./pkitool hostname

Files needed to setup client
* /etc/openvpn/ca.crt
* /etc/openvpn/easy-rsa/keys/hostname.crt (Where hostname is the hostname of the client).
* /etc/openvpn/easy-rsa/keys/hostname.key (Where hostname is the hostname of the client).

sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
sudo gzip -d /etc/openvpn/server.conf.gz

Open /etc/openvpn/server.conf and make the below change. SSH does not work properly in udp mode.

proto tcp
push "route" #this is a change

While udp is recommended by openvon but ssh was failing when I tried to ssh on some other hosts on the cloud.

Configure iptables to allow traffic from VPN to LAN
iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

TIP: Restart openvpn every time you make a change in iptables they are not reflected instantly.

sudo service openvpn restart

Client setup:
Install openvpn on your laptop. Copy Sample client.conf to /etc/openvpn. Save the client files in /etc/openvpn/

proto tcp
remote 1194
ca ca.crt
cert roshan-home.crt
key roshan-home.key

sudo service openvpn restart

sudo ifconfig in 30 seconds you will see a new vpn interface tun0. You should be able to ping 10.240.x.x and ssh.

Additional Debugging:
* Use routing table info to see if it is set correctly route -n or netstat -rn
* tcpdump to see if icmp packets are received tcpdump -i any icmp
* netcat or telnet to see if vpn port is open

netcat -z -v 1194
telnet 1194


Tips for planning your motorcyle trip to Leh


  • Read and research. Start here:…-travel-guide/…ate-guide.html See lot of photos, will keep you excited :)
  • You can ride solo, however I would highly recommend against it. Form a group on Bangalore Bikers or BMC Touring. Ride with experienced bikers. Newbies will find it daunting to ride everyday. I had a guy in my group who had slowed down everyone.
  • Consider taking your own bike if it is in good condition. If you own a bike that an engine more than 200cc then you may not have to do any adjustment. Otherwise you need to get air fuel mixture adjusted so that you can get more power out of your bike. This can get this done in Manali. Rental bikes may not be reliable and if they break down it will cost you in money and time. Carry spare keys.
  • AMS may or may not affect you. Diamox is good to use as a precaution against AMS. If you are allegic to Sulphur, you should consult a physician. Start taking one tablet everyday from at least 2 days before you reach Manali. It takes 12-24 hours to show effect.
  • Purchase plastic sheets, rubber/gum boots, petrol cans, bungee cords and rain coats. These things can be bought in Manali. Rubber boots cost only Rs 250, it will save your feet from getting wet. Carrying extra bungee cords and plastic sheets is advisable. You can buy rain coats in Bangalore itself.
  • Try to reach Manali on a Saturday. Market is closed on Sunday. Road to Rohtang Pass is closed on Tuesday morning (you should verify this from a local guy, call up some rental).
  • Buy thermal inners both top and bottoms. Dont carry lots of clothes, you will anyways have to wear thermal inners. But carry enough warm clothes. It becomes too cold after sun set.
  • Buy thick balaclava, thick muffler, 3 pairs of woolen socks.
  • If carrying mesh jacket, carry rain liner and additional jacket to wear inside. I had a DSG Nero, which saved me from cold. It is water proof also (if you close all the zips properly). Wear inner inside gloves. Gloves should not have air vents.
  • Try to find out if you can prevent fogging on the helmet visor. I had keep it open for the most part.
  • Learn how to fix a puncture and clean/change spark plug. That is the least you should know.

During the ride:

  • Always start early. The roads are terrible and it becomes extremely cold once it is dark.
  • Once you cross Keylong, switch off the phone. You won’t get signal in case of prepaid sim. Only postpaid Airtel and BSNL work in after than in some areas. You will get access to network once you are close to Leh. Charge your batteries whenever you get the opportunity. A small spike buster will come handy, we had one.
  • I will advise not listening to songs during ride since most of the roads are on moutains, you should be able to hear any sound of incoming vehicle.
  • Stay alert all the time. You can not make errors there and it can be fatal. There are no hospital facilities.
  • Do not stuff yourself during meals. Take frequent breaks, eat light. This will give you some rest during bad sections of road. You will find tents or eateries every 60-70 kms.
  • NO liqour or smoking!
  • Carry at least 6-8k in cash. Keylong has the last ATM on the route. If you get stuck money will be really handy. If you are carrying multiple luggage, split your money in them.
  • Wave to all the riders. Foreigners may not respond but Indians certainly will :)

Places between Manali to Leh:
1. Koksar – 75 km from Manali – Home stay
2. Tandi – 108 km from Manali – Last petrol pump, bike repair
3. Keylong – 115 km from Manali – Hotels and Home stay, ATM, bike repair
4. Jispa – 140 km from manali – Hotels and tents
5. Zing-Zing Bar – ~180 km from Manali – only tents – don’t halt here for the night
6. Sarchu – ~ 250km from Manali – Only tents
7. Pang – 170 km to Leh, only tents – dont halt here for the night
8. Rumtse – 80 km to Leh – Homestay available
9. In some villages approx, 15 km from Rumtse, I noticed designated camping spots, could not see any home stay though.

You will find eateries in all these places. If you are a hygine-freak prepare to live on chips and water 😛

Road Condition:
1. Manali to Rohtang – Good
2. Rohtang to Koksar – Bad, if it has not rained otherwise pathetic as it will be extremely muddy. Streams of water flowing on road.
3. Koksar to Keylong – Half of the road is good. Then there are potholes and sometimes gravel. Streams of water flowing on road.
4. Keylong – Baralacha – Good. Streams of water flowing on road.
5. Baralacha to Sarchu – Pathetic
6. Sarchu to Pang – Good till you reach the bottom of Gata loops, then pathetic to Pang.
7. Pang to Leh – Bad for a few kilometres then very good. Then a bad stretch of 15 km till you reach Taglang la. After that very good roads till Leh.

Almost 60% of road is bad. This should help in you planning. They are making a tunnel under Rohtang Pass which is scheduled to open in 2017. Go before that happens, Rohtang top is beautiful :)

In my opinion riding to Leh in 3 days makes sense. You can take break at Keylong or Jispa, Sarchu and then Leh. It is not a race, try to enjoy the trip. Also three weeks seems apt for this ride because there is so much to see.

Best Season:
Avoid monsoon season. Ride in May-June or September. It will be less crowded but colder in September. Stays will be cheaper and easier to find. Always negotiate the price. If you are renting bikes also you may be able to get some good deal.

Checklist for motorcyle preparation:…rcycle-ladakh/

This is strictly my opinion:
If you would like to enjoy the view, motorcycles are certainly not the best way to explore this region since roads are not in very good condition. Car will be a good option. There are lot of taxi services to Leh from Manali. You can get taxis from Leh also. There are lot of tour operators also.
But then we all love to ride!

Day 13-14 – Beautiful Jispa – Back to Manali

We decided to take the day off and enjoy this beautiful village. Jispa is a very small village with couple of hotels and tents. Green trees, a river and snow filled mountain tops. We decided to head to the river.


I’ll come back!

The trip is going to be over :(

River Chandra and Bhaga meeting at Tandi to form Chandrabhaga. This river later becomes Chenab.


Sun set at Rohtang. 


Day 12 – Ice bucket challenge! – Pang – Jispa

We woke up next day to freezing cold at Pang. One of the guys went to take a dump. After he was done, he noticed that water in the cans were frozen. Ice bucket challenge accepted :) I leave the rest to your imagination.

I will never ever complain about road conditions!

Vishal Taal

Ice melting and joining Bhaga river.

Tera pyar pyar pyar, zing zing bar. I clicked this photos specially for this pj :)

Sun set. It was more beautiful than it looks.

Deepak Taal. Clicked this photo for my brother, his name is Deepak!

Reached Jispa around 7 pm. We found a really nice hotel. The rooms were good and priced at Rs 800, possibly because the tourist season was almost over. Food was costly, but the chicken curry was out of the world!

Day 11 – Adios Leh! – Leh – Pang

I spent next day walking around in Leh and tried Thukpa(Tibetan cuisine). Food is usually good in Leh but prices are generally high. Meanwhile I managed to find an optician and got new spectacles made.

It was time to head back. We could not go to lot of the places on our itinerary like Nubra Valley, Pangong Tso, Tso Moriri, still this was one trip that I will remember for my entire life. It’s because of the company! The college buddies were back, possibly for our last trip together.

Since we could not visit most of the places we decided to ride slow and enjoy the scenery.

Mesmerizing, isn’t it? Can’t remember where I clicked this. Set this as your wallpaper right now :)


Always far from home! This was a small watch tower on top of Gata Loops. That line had me thinking for a while to quit everything and run away!

During my last long ride, I had seen a river flowing between two mountains (near jog falls) covered with trees. Here the mountains were naked. Stopped here just to compare them.

Enough of the view! I need to go down and feel the cold water now.

A herd of sheep.

Baralacha is near

Reached Pang, around 3 pm. Decided to halt here, got the same tent.

Day 9-10 – Khardung la – Shanti Stupa

There was a marathon from Khardungla to Leh so the the roads were closed for first half. I could barely walk there, wonder how people managed to run. Leh also has less oxygen as per my experience. It is nearly 55 km from Leh. Half of the road is good and rest is gravel.

Next day we went to Shanti Stupa. One has to climb nearly 200 steps to reach the stupa. After climbing only 20 steps I was panting.


I went for shopping in the evening and bought a shawl and a muffler for my parents.