Tuesday, August 02, 2011

PowerShell script to determine if a machine has two or more local interfaces

First, create a txt file (e.g. d:\server.txt) containing a list of servers:

10-2411A0407
10-2411A0408
10-2411A0409

Second, run the following script block:

$Servers = Get-Content D:\Server.txt
foreach ($s in $Servers)
{
  $Interfaces = Invoke-Command -ComputerName $s -Command {Get-WmiObject Win32_NetworkAdapterConfiguration}
  $NumInterfaces = $Interfaces.Length
  $LocalInterfaces = 0
  $LocalIP = ""
  foreach ($If in $Interfaces)
  {
    $IsLocal = $False
    foreach ($ip in $If.IPAddress)
    {     
      if ($ip.StartsWith("10.10."))
      {
        $IsLocal = $True
        break;
      }
    }
    if ($IsLocal)
    {
      $LocalInterfaces++
      $LocalIP += $ip + " "
    }
  }
  if ($LocalInterfaces -ge 2)
  {
    $s
    $LocalIP   
  }
}

Finally, here is what I got out of it:

10-2411A0407
10.10.11.43 10.10.10.87
10-2411A0408
10.10.11.30 10.10.10.83
10-2411A0409
10.10.10.107 10.10.11.28

Wednesday, March 15, 2006

MPI-2 IO 学习笔记

学习内容:MPI2 standart ,
资料来源:http://www.mpi-forum.org/docs/mpi2-report.pdf

要点:MPI2 IO 标准
etype 基本类型
filetype 由一个或多个etype组成,中间允许由空洞

displacement:以字节为单位,从文件第一个字节开始
offset:以etype为单位,从displacement开始
view:文件视图?现在还不是很理解,详见Page 232, Figure9.3

Data access routines:
Data is moved between files and processes by issuing
read and write calls. There are three orthogonal aspects
to data access:
1. positioning (explicit offset vs. implicit file pointer),
2. synchronism (blocking vs. nonblocking and split collective), and
3. coordination (noncollective vs. collective).

重点要掌握P220 的那张data access routines列表,非常详尽。

Monday, March 13, 2006

PVFS2 components

1. pvfs2-server
2. system interface
3. management interface
4. Linux kernel driver
5. pvfs2-client
6. ROMIO PVFS2 device

PVFS2 objects:
1. directory
2. metafile
3. datafile
4. symbolic link

Handles and its range, an example:

Name pvfs2-fs
ID 584761686
RootHandle 1048576

Range cse-wang-server 4-715827885
Range cse-wang05b 715827886-1431655767
Range cse-wang11 1431655768-2147483649


Range cse-wang-server 2147483650-2863311531
Range cse-wang05b 2863311532-3579139413
Range cse-wang11 3579139414-4294967295


TroveSyncMeta yes
TroveSyncData no
AttrCacheKeywords datafile_handles,metafile_dist
AttrCacheKeywords dir_ent, symlink_target
AttrCacheSize 4093
AttrCacheMaxNumElems 32768

Friday, March 10, 2006

cvs for lsfs-pvfs2 project

1. 建立repository
cvs -d D:/server_root/cvs init
cd /home/penggu/DOEproject/lsfs-pvfs2-imp/user-level/pvfs2-1.4.0
cvs -d D:/server_root/cvs import -m "initial import into CVS" pvfs2-1.4.0-dev penggu start

2.check out
cd /home/penggu/DOEproject/lsfs-pvfs2-imp/user-level/dev
cvs -d D:/server_root/cvs co pvfs2-1.4.0-dev

Tuesday, March 07, 2006

pvfs2 cvs check out and update

Dowload module:
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs login
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs co pvfs2
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs logout

Update:
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs login
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs update -P -d
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs logout

如何想要自动化管理,需要三个script文件:
cvs_checkout.sh, cvs_update.sh and cvs_login.exp

------------------------------------
cvs_checkout.sh
------------------------------------
#!/bin/bash
expect cvs_login.exp
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs co pvfs2
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs logout
------------------------------------

cvs_update.sh
------------------------------------
#!/bin/bashexpect
cvs_login.exp
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs update -P -d
cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs logout

cvs_login.exp
----------------------------------
set remote_server cvs.parl.clemson.edu
set my_password fakeone
# Open an cvs session to a remote server, and wait for a password prompt.
spawn cvs -d :pserver:anonymous@cvs.parl.clemson.edu:/anoncvs login
expect "password:"
# Send the password, and then wait for an bash prompt.
send "$my_password\r"
expect eof

Monday, March 06, 2006

SSH Without a Password

The steps assume that a DSA key is being used. To use a RSA key substitute 'rsa' for 'dsa'. The steps assume that you are using a Bourne-like shell (sh, ksh or bash) Some of this information came from: http://www.der-keiler.de/Mailing-Lists/securityfocus/Secure_Shell/2002-12/0083.html

For our testing purpose, we define two servers and one client
SSH client: cse-wang-server
SSH server: cse-wang05b cse-wang11

Steps:1. On the client run the following commands:
mkdir -p $HOME/.ssh
chmod 0700 $HOME/.ssh
ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''
cd $HOME/.ssh/
mv id_dsa.pub id_dsa.pub-`hostname -s`
for server in cse-wang05b.unl.edu cse-wang11.unl.edu ; do
echo "Host ${server}" >> config
echo " IdentityFile ~/.ssh/id_dsa" >> config
scp id_dsa.pub-`hostname -s` ${server}:./.ssh/
done
2.On the server run the following commands:
cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
cd $HOME/.ssh/
for client in cse-wang-server ; do
cat id_dsa.pub-${client} >> authorized_keys2
done
chmod 0600 authorized_keys2
3.On the client, test the ssh connectionssh cse-wang05b.unl.edu

Thursday, May 05, 2005

LFU 的实现思想

LRU容易理解,就是存放在cache中的永远是最后被访问的,那么LFU又是怎么实现呢?

给定cache size, 如果你的item不在cache中,则需要把它加入,同时设置其访问频率为1
如果在cache中,则需要把它的访问频率加一。
如果发生替换,就把当前cache所有的item的访问频率拿来比较,最小的一个被踢掉。

原来就是这么简单啊。呵呵:)

Thursday, April 28, 2005

C++ STL 参考书

今天给很多人发信请教推荐一本STL的教程,结果很快就得到了大家的回应.
这里我觉得有两本书比较不错,一本是1《The C++ Standard Library》, 另一本是
2《Effective STL》,这两本都有中文版。很适合我们阅读。
2的下载链接:http://stl.winterxy.com/download/Eff_STL_CN.pdf
1是我的同学直接用email发送给我的,所以没有下载链接。

真要好好感谢我的这些热心的同学和弟兄们!

在C++中用list容器实现LRU cache

Cache从本质上是个数组,但是LRU cache则似乎不太相同,它有一种内在的顺序,
也就是被淘汰的顺序.

考虑LRU cache的如下操作:

1.添加 Add item
向LRU Cache中添加永远只需要向队列尾部添加

2.删除 Delete item
对应尾部添加,则删除应该发生在队列头部.

3.查找 Search item
查找应该做两件事,一是真正的查找,返回一个True or False.
但是如果命中,则还应该把命中的item移动到尾部,使它不容易被删除.

4.替换-Replace item
Replace可以被看成是两个操作的合并:Replace = Add + Delete,
其中add发生在尾部,delete发生在头部。

5.是否还应该加上有效位,valid bit,以及对应的修改该位的功能?
set_invalid(),set_valid(),is_valid()

可能会需要的参数,
1. Cache size (number of items, Cache 容量)
2. Cache item Data Type (每个item是一个文件,一个block,还是...?)
3. 好像没有了吧?^_^

一下是我的LRU Cache实现的主要代码片断:
class LRU_Cache
{
public:
void _add(int id);
void _del(int id);
bool _find(int id);
bool search(int id);
private:
list lru;
}

void LRU_Cache::_add(int id)
{
lru.push_back(id);
}
void LRU_Cache::_del(int id)
{
lru.remove(id);
}
bool LRU_Cache::_find(int id)
{
list::iterator it;
for (it=lru.begin(); it!=lru.end(); it++)
if ((*it)==id)
return true;
return false;
}

KB MB GB TB PB EB ZB YB

KB Kilobyte 1,024 Bytes
MB Megabyte 1,048,576 Bytes
Gb Gigabit 1 billion bits
GB Gigabyte 1,073,741,824 Bytes | One billion Bytes
TB Terrabyte 1024 GB, 1,048,576 MB, 8,388,608 KB, 1,099,511,627,776 Bytes and 8,796,093,022,208 bits.
PB Pettabyte 1024 TB, 1,048,576 GB, 1,073,741,824 MB, 1,099,511,627,776 KB, 1,125,899,906,842,624 Bytes and 9,007,199,254,740,992 bits.
EB Exabyte 1024 PB, 1,048,576 TB, 1,073,741,824 GB, 1,099,511,627,776 MB, 1,125,899,906,842,624 KB, 1,152,921,504,606,846,976 Bytes and 9,223,372,036,854,775,808 bits.
ZB Zettabyte 1024 EB, 1,048,576 PB, 1,073,741,824 TB, 1,099,511,627,776 GB, 1,125,899,906,842,624 MB, 1,152,921,504,606,846,976 KB, 1,180,591,620,717,411,303,424 Bytes and 9,444,732,965,739,290,427,392 bits
YB Yottabyte 1024 ZB, 1,048,576 EB, 1,073,741,824 PB, 1,099,511,627,776 TB, 1,125,899,906,842,624 GB, 1,152,921,504,606,846,976 MB, 1,180,591,620,717,411,303,424 KB 1,208,925,819,614,629,174,706,176 Bytes and 9,671,406,556,917,033,397,649,408 bits

Wednesday, April 27, 2005

找paper的好地方

看看这个网站,这里有众多的文章库,包括:
google,google scholar,siteceer, sciurs, IEEE Xplore,
ACM Digital Library, SlugLink, O'Reilly Network Safari Bookshelf
Research Resources on the Web and at UCSC

安装Cygwin的步骤

这个站点告诉你如何在你的笔记本windowsXP上一步一步地安装cygwin
我没有试过,但是应该会有帮助Installing Cygwin

Linux支持的最大文件

刚才读了一个帖子,了解了linux下面支持的文件的最大size:http://www.suse.de/~aj/linux_lfs.html

从这里我们看到,在32位的系统上,一般而言,最大文件size是2GB,除非使用了Large File Support (LFS)支持。而64位的系统则自动最大支持2^63 Bytes的大文件。

使用LFS支持需要对内核以及C libary做大量的修改。

64位的系统也可以使用LFS支持,但是并没有任何实际意义,因为在这些系统上,LFS的API仅仅是老的API的一个别名。

下面是一个简单的列表,也是从这个网站上拷贝过来的,该网站上还有更多更详细的说明:http://www.suse.de/~aj/linux_lfs.html

FilesystemFile Size LimitFilesystem Size Limit
ext2/ext3 with 1 KiB blocksize16448 MiB (~ 16 GiB)2048 GiB (= 2 TiB)
ext2/3 with 2 KiB blocksize256 GiB8192 GiB (= 8 TiB)
ext2/3 with 4 KiB blocksize2048 GiB (= 2 TiB)16384 GiB (= 16 TiB)
ext2/3 with 8 KiB blocksize (Systems with 8 KiB pages like Alpha only)65568 GiB (~ 64 TiB)32768 GiB (= 32 TiB)
ReiserFS 3.52 GiB16384 GiB (= 16 TiB)
ReiserFS 3.6 (as in Linux 2.4)1 EiB16384 GiB (= 16 TiB)
XFS8 EiB8 EiB
JFS with 512 Bytes blocksize8 EiB512 TiB
JFS with 4KiB blocksize8 EiB4 PiB
NFSv2 (client side)2 GiB8 EiB
NFSv3 (client side)8 EiB8 EiB