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

2.Linux/Unix/MacOSX

/etc/hosts

 

Format:

127.0.0.1    example.domain.com

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”;
        sleep(30);
}

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

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 (http://www.gnu.org/).

http://linux.about.com/library/cmd/blcmdl1_readelf.htm

ldd

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

http://linux.about.com/library/cmd/blcmdl1_ldd.htm

http://linux.byexamples.com/archives/409/how-to-list-shared-library-dependencies-used-by-an-application/

od

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.

http://linux.die.net/man/1/od

Others:

nm, objdump, objcopy,size, strings

reference:

http://www.tenouk.com/Module111linuxutility1.html

http://www.tenouk.com/Module000linuxnm3.html

http://www.tenouk.com/Module111.html

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: , , , , , |

C

POSIX Threads Tutorial

http://math.arizona.edu/~swig/documentation/pthreads/

POSIX thread (pthread) libraries

http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

C++

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

http://www.paulbridger.com/multithreading_tutorial/

Multithreading Tutorial (mainly on Win32)

http://www.codeproject.com/KB/threads/MultithreadingTutorial.aspx

C++/CLI Threading

Part I:

http://www.drdobbs.com/windows/184402018

Part II:

http://www.drdobbs.com/windows/184402029

Threads in C++

http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-18.html

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

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