Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1871928
  • 博文数量: 283
  • 博客积分: 10141
  • 博客等级: 上将
  • 技术积分: 2931
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-21 14:33
文章分类

全部博文(283)

文章存档

2013年(2)

2012年(2)

2011年(17)

2010年(36)

2009年(17)

2008年(18)

2007年(66)

2006年(105)

2005年(20)

分类:

2006-02-21 19:22:16

#!/usr/bin/perl
use strict;
my $begin_node;
my $end_node;
my $node;
my $bash_env=`. /usr/local/lsf/conf/profile.lsf`;
my $USING=`bjobs -u all | grep node | grep -v "^\$"`;
chomp($USING);
my $MAX=384;
sub usage()
{
        print "Usage:   $0 begin_node end_node\n";
        print "Eg.:     $0 192 384 [check free node(s) between node192 and node384]\n";
        exit;
}
sub my_exit($)
{
        print "$_[0]\n";
        exit;
}
sub check_opt($$)
{
        my $begin = shift;
        my $end = shift;
        if(("$begin" > "$end") || ("$begin" <= "0")  || ("$end" <= "0"))
        {
                my_exit("Are you kidding? Please give me a right range of nodes.");
        }
        else
        {
                $begin_node = $begin;
                $end_node = $end;
        }
}
sub free_nodes()
{
        print "Free nodes between node  $begin_node and $end_node:\n";
        for($node = $begin_node; $node < $end_node; $node++)
        {
                if($node < 10)
                {
                        if($USING !~ /node00$node/)
                        {
                                print "node00$node\n";
                        }
                }
                elsif($node < 100)
                {
                        if($USING !~ /node0$node/)
                        {
                                print "node0$node\n";
                        }
                }
                elsif($node < $MAX)
                {
                        if($USING !~ /node$node/)
                        {
                                print "node$node\n";
                        }
                }
                else
                {
                        my_exit("Do you have so many nodes? Please change \$MAX in the beginning of this script.");
                }
        }
}
if( not defined($ARGV[0]) || not defined ($ARGV[1]))
{
        usage();
}
check_opt($ARGV[0],$ARGV[1]);
if("$USING" eq "")
{
        my_exit("I can't find any free node!");
}
else
{
        free_nodes();
}
阅读(1697) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~