Archive for June, 2007

DNS host setting

Posted on June 22, 2007. Filed under: Linux, Mac, Services, Windows |

File locations:

1. Windows

Windows 95/98/Me c:\windows\hosts

Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts

Windows XP Home c:\windows\system32\drivers\etc\hosts





Read Full Post | Make a Comment ( None so far )

A perl script that can monitor windows

Posted on June 18, 2007. Filed under: Computer Science, Programming |

A perl script that can monitor windows

#!/usr/bin/perl -w
use Win32::OLE qw[in];

my $host = $ARGV[0] || ‘.’;
my $wmi = Win32::OLE->GetObject( “winmgmts://$host/root/cimv2” )
        or die Win32::FormatMessage( Win32::OLE::LastError() );

my %instances = (
        Win32_PhysicalMemory => &get_pmem,
        Win32_PerfRawData_PerfOS_Memory => &get_amem,
        Win32_Processor => &get_load,
        Win32_LogicalDisk => &get_disk,

while(1) {
        my $out = get_perf_data();
        print $out;
        print “n”;

sub get_perf_data {
        my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
        $year = $year + 1900;
        $mon  = $mon + 1;
        my $str = sprintf “%4.4d-%2.2d-%2.2d”,$year,$mon,$mday;
        my $timestr = sprintf “%2.2d:%2.2d:%2.2d”,$hour,$min,$sec;
        my $mem;
        foreach ( keys %instances ) {
                my $class = $wmi->InstancesOf( $_ );
                $mem .= $instances{ $_ }->( $class );
        my $out = “##nCollect Time: “.$str.” “.$timestr.”n”.$mem.”%%rn”;
        return $out;

# get cpu loadavg
sub get_load {
        my $class = shift;
        my $total=””;
        my $i = 0;
        $i++,$total = $total.”CPU No. $i: “.$_->{LoadPercentage}.”%n” foreach in($class);
        return $total;

# get total memory size
sub get_pmem {
        my $class = shift;
        my $total;
        $total += $_->{Capacity} foreach in($class);
        return “Physical Memory: $total Bytesn”;

# get available memory size
sub get_amem {
        my $class = shift;
        my $amem;
        $amem .= join ‘ ‘, $_->{AvailableBytes} foreach in($class);
        return “Available Memory: $amem Bytesn”;

# get free disk sizes
sub get_disk {
        my $class = shift;
        my $total = “”;
        $total .= “DISK “.$_->{DeviceID}.” Free: “.$_->{FreeSpace}.” Bytesn” foreach in($class);
        return $total

Read Full Post | Make a Comment ( None so far )

Useful linux commands: readelf, ldd, od

Posted on June 8, 2007. Filed under: Uncategorized | Tags: , , , , , |


readelf displays information about the contents of one or more ELF format object files.   The options control what particular information to display.  elf files are the object files to be examined.  32-bit and 64-bit ELF files are supported, also archives containing ELF files.  This program performs a similar function to objdump but it goes into more detail and it exists independently of the BFD library, so if there is a bug in BFD then readelf will not be affected.

BFD – Binary File Descriptor.  Is a package which allows applications to use the same routines to operate on object files whatever the object file format (


ldd prints the shared libraries required by each program or shared library specified on the command line


od will dump files in octal and other formats.  Write an unambiguous representation, octal bytes by default, of a FILE to standard output.  With more than one FILE argument, concatenate them in the listed order to form the input.  With no FILE, or when FILE is -, read standard input.


nm, objdump, objcopy,size, strings


Read Full Post | Make a Comment ( None so far )

Some multithreading tutorial URLs

Posted on June 6, 2007. Filed under: C/C++, Linux, Programming, Windows | Tags: , , , , , |


POSIX Threads Tutorial

POSIX thread (pthread) libraries


Multithreading Tutorial(Mutex, deadlock, livelock, scoped lock, Read/Write lock, Monitor Object, Active Object, boost) — Good!

Multithreading Tutorial (mainly on Win32)

C++/CLI Threading

Part I:

Part II:

Threads in C++

Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...