Skip to main content


Showing posts from September, 2016

Nagios Plugin Return Codes

Nagios plugin scripts have to return two things:

1. Exit with a return value
2. A text output to STDOUT

Possible plugin return values are:


Managing Cisco Network Devices using Bash and Expect

Most of the time, managing lots of network devices are troublesome if you do not have a proper management software. In this post i will go through an example. The task that i want to achieve is getting existing tunnel configuration of cisco network devices, then creating a new tunnel configuration using them.

First install expect packages. In my case i use ubuntu:
# sudo apt-get install expect
Make a directory for logs:
# mkdir /tmp/expect_logs
There are some text files and bash, expect scripts: 1. devices_list : IP list of the cisco network devices. 2. : Main Bash script. 3. expect_get.exp : Expect script for getting existing device config. 4. expect_put.exp : Expect script for creating a new device config.
Contents of the scripts accordingly:
Running in a while loop should do the trick. # while read -r line; do ./ $line; done < devices_list

Converting Virtualization Image Formats with qemu-img convert

qemu-img is a practical tool to convert between multiple virtual disk image formats. As of qemu-img- supported formats are in the following list.
raw: Raw disk image format qcow2: QEMU image format (copy-on-write) qcow: Old QEMU image format cow: User Mode Linux copy-on-write image format vdi: VirtualBox 1.1 compatible image format vmdk: VMware 3 and 4 compatible image format vpc: VirtualPC compatible image format (VHD) vhdx: Hyper-V compatible image format (VHDX) cloop: Linux Compressed Loop image
A few examples:
kvm raw image to qcow2 $ qemu-img convert -f raw -O qcow2 raw-image.img qcow2-image.qcow2
kvm raw image to vmdk $ qemu-img convert -f raw -O vmdk raw-image.img vmware-image.vmdk
vmdk to raw image $ qemu-img convert -f vmdk -O raw vmware-image.vmdk raw-image.img
vmdk to qcow2 $ qemu-img convert -f vmdk -O qcow2 vmware-image.vmdk qcow2-image.qcow2
vdi to qcow2 $qemu-img convert -f vdi -O qcow2 vbox-image.vdi qcow2-image.qcow2