We’ll I know it’s been a while since I posted something here, but the mood wasn’t really there…
You might have been in the situation where you went on Dell’s support website to download some drivers or utilities for your notebook and you were asked for the Service Tag. The first thing that you might have thought about at this time is to topple your notebook to look for the Service Tag underneath. we’ll no need for that, you can obtain it from the command line:

On Linux —
dmidecode -s system-serial-number

On Windows —
wmic bios get serialnumber

It’s always handy to have a script to create the reverse lookup records from a forward lookup zone file. So here its goes…

#!/bin/sh
#@Author Daysen — daysenv@gmail.com

#———–
>rev

cp /var/lib/named/master/de.daysen.com.hosts fwd
sed -e ‘/^;/d’ fwd | sed -e ‘/^$/d’ > f1

while read line
do
RD_=`echo $line | awk ‘{print $3}’`
IN_=`echo $line | awk ‘{print $2}’`

if [ “$IN_” = “IN” ] && [ “$RD_” != “SOA” ]
then

if [ “$RD_” != “SRV” ]
then
if [ “$RD_” = “CNAME” ] || [ “$RD_” = “NS” ]
then
CN_=`echo $line | awk ‘{print $4}’`
if [ “$RD_” = “NS” ]
then
c=`nslookup $CN_ | grep -v “127.0.0.1” | grep “Address” | awk ‘{print $2}’ | awk -F . ‘{print $2″.”$1}’`
a=”$c.in-addr.arpa. IN NS     “
b=`echo $line | awk ‘{print $4}’`
else

c=`nslookup $CN_ | grep -v “127.0.0.1” | grep “Address” | awk ‘{print $2}’`
a=`echo $c | awk -F . ‘{print $4″.”$3″.”$2″.”$1″.in-addr.arpa.        IN        PTR     “}’`
b=`echo $line | awk ‘{print $1}’`
fi
else

c=`echo $line | awk ‘{print $4}’`
a=`echo $c | awk -F . ‘{print $4″.”$3″.”$2″.”$1″.in-addr.arpa.        IN        PTR     “}’`
b=`echo $line | awk ‘{print $1}’`
fi

echo $a”        “$b >> rev
sort -k3,4 rev > f2
mv f2 rev
fi
fi

done < f1

rm -f f1

Virtualbox uses a NAT network connection by default. So initiating an SSH connection to the guest machine from either the host machine or any other box is impossible. A work around for this is to forward all packets coming to a port on the host machine to the port on which the ssh server listens on the guest machine. This can be done using the “VBoxManage” Virtualbox command. Assuming the host port is 2022, ssh server listens on the default port 22 and the network adapter is a PCnet. The guest machine runs Mepis Linux and is named mepis01.

Type the following commands on the host machine’s console

>> VBoxManage setextradata mepis01 “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort” 2022

>> VBoxManage setextradata mepis01 “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort” 22

>> VBoxManage setextradata mepis01 “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol” TCP

You need to close and restart the host machine before the changes take effect.

You can now connect through ssh from the host machine as:
>> ssh -l daysen -p 2022 localhost

Replace localhost with the IP address or hostname of the host machine if you are connecting from another box

Compression utility…

Posted: August 19, 2010 in Utilities
Tags: , ,

I came into a problem where I needed to compress each and every file in a directory. The top directory contained several sub-directories, each containing several sub-directories…Compressing each and every of the few hundred files by hand is obviously tedious. So I wrote a small vbs utility to do the job.

‘Daysen Veerasamy
’12 May 2009
‘Archives all files in top-dir(incl sub-dirs) to dest-dir
Dim objFSO
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
LogFile = “c:\users\daysenv\desktop\files.log”
Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(LogFile, 2, True)
objStartFolder = Wscript.Arguments.Item(0)
arcDest = Wscript.Arguments.Item(1)
pass = Wscript.Arguments.Item(2)
Set objFolder = objFSO.GetFolder(objStartFolder)
‘objLogFile.Write objFolder.Path
‘objLogFile.Writeline
Set colFiles = objFolder.Files
For Each objFile in colFiles
‘objLogFile.Write objFile.Name
‘objLogFile.Writeline
archive objFile.Name, arcDest, objFolder.Path, pass
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
‘objLogFile.Write Subfolder.Path
‘objLogFile.Writeline
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
‘objLogFile.Write (objFolder.Path & “\” & objFile.Name)
‘objLogFile.Writeline
archive objFile.Name,  arcDest, objFolder.Path, pass
Next
ShowSubFolders Subfolder
Next
End Sub
Sub archive(fname, fdest, odest, passwd)
Dim wshShell
Set wshShell  = Wscript.CreateObject(“WScript.shell”)
‘wscript.echo “rar ” & “a” & ” ” & “-df” & ” ” & “-p” & passwd & ” ” & “-hp” & passwd & ” ” & “-ep” & ” ” & “-ep1″ & ” ” & ” ” & “-v700000″ & ” ” & ” ” & fdest & “\” & fname & “.rar” & ” ” & odest & “\” & fname
wshShell.run “rar ” & “a” & ” ” & “-df” & ” ” & “-p” & passwd & ” ” & “-hp” & passwd & ” ” & “-ep” & ” ” & “-ep1″ & ” ” & ” ” & “-v700000″ & ” ” & ” ” & fdest & “\” & fname & “.rar” & ” ” & odest & “\” & fname
Set wshShell = nothing
End Sub
objLogFile.Close

The Hobbit

Posted: August 18, 2010 in Linux
Tags: , ,

Let’s talk a bit about Hobbit. Well, am not talking about the famous novel of J.R.R Tolkien, but about the Hobbit Monitoring Tool. Hobbit can monitor servers, networks, applications etc…;Just to name a few. More about Hobbit can be found at the Hobbit project page  at http://xymon.sourceforge.net/docs/about.html. I’ve been using Hobbit for quite a few years now to monitors most of equipment in the Company data centers. Some of my Hobbit extensions are on Launchpad at https://code.launchpad.net/hobbit-mon. I will gradually post more extensions when time permits.