免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1818 | 回复: 0
打印 上一主题 下一主题

请教关于prel脚本抓取hosts主机IP地址不对的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-08-24 14:31 |只看该作者 |倒序浏览

使用NBU备份软件,用NBU命令获得备份策略信息,然后通过脚本来对策略信息进行格式化,但是格式化后,策略信息内容会有不对称的情况。
举个例子,某个备份策略对应的IP是xx.49,但是格式化后,IP变为xx.13。
在hosts文件中,xx.49的主机名为xxx1,而xx.13的主机名为xxx1_new。
请问这种情况应该如何调整脚本?
脚本如下:
#!/usr/bin/perl
        
        
  if ( ! open BPPLLIST, '<', '/usr/openv/script/output/bppllist.out')
  {
        die "Cannot open file: $!";
  }
while ( <BPPLLIST> )
{
        chomp;
        

        if ($includecount==1) {
          if ($_ =~ /Schedule:/) {
                $includecount=0;
          } else {
                push (@backupfile,$_);
          }
        }      
        if ($windowscount==1) {
          if ($_ =~ /Schedule:/ || $_ =~ /------------------/ || $_ =~ /Catalog Disaster Recovery/) {
                $windowscount=0;
          } else {
                push (@windows,$_);
          }
        }      
        if ($_ =~ /Policy Name:\s+(\S+)\s*/) { $plname=$1;}
        if ($_ =~ /Active:\s+(\S+)\s*/) { $active=$1;}
  if ($_ =~ /Schedule:\s+(\S+)\s*/) { $scname=$1;}
  if ($scname ne "Default-Application-Backup"){ $rscname=$scname;}
  if ($_ =~ /Type:\s+(.*Backup)/) {
          $sctype=$1;
      if ($sctype ne "Application Backup"){ push (@rsctype,"$sctype");}
  }
  if ($_ =~ /HW\/OS\/Client:\s+\S+\s+\S+\s+(\S+)/) {
      $clientname=$1;
      if ( ! open HOSTS, '<', '/usr/openv/script/output/hosts.out'){
        die "Cannot open file: $!";
      }
      while (<HOSTS>) {
            chomp;
      if ($_ =~ /([^#]\S+)\s+$clientname/) { $clientip=$1;}
      }
      close HOSTS;
    }
  if ($_ =~ /Include:\s+(\S+)\s*/) { $include=$1;$includecount=1;push (@backupfile,"$include");}
  
  if ($_ =~ /Daily Windows:/) { $windowscount=1;}
  
  if ($_ =~ /\s+([A-Z]\w*),(\s+Week\s+[1-5])/) { $weekday=$1.$2;push (@backupday,"$weekday");}
  if ($_ =~ /(.*of month)$/) { $weekday=$1;push (@backupday,"$weekday");}
  if ($_ =~ /SPECIFIC DATE \d - (.*)$/) { $weekday=$1;push (@backupday,"$weekday");}
  if ($_ =~ /Frequency:\s+(.*)/) { $weekday=$1;push (@backupday,"$weekday");}
  
  if ($_ =~ /Retention Level:.*\((.*)\)/) { $retention=$1;push (@retention,"$retention");}
  
  if ($_ =~ /^---------------------------------------------------------.*/ && $active eq "yes") {
    print "$plname,netbackup2,$clientname,$clientip,@backupfile,@rsctype,@backupday,@retention,@windows\n";
    $active=undef;
    $rscname='Default-Application-Backup';
    @backupday=();
    @backupfile=();
    @windows=();
    @rsctype=();
    @retention=();
    $weekday=undef;
  }

  if ($_ =~ /^---------------------------------------------------------.*/ && $active ne "yes") {
    $active=undef;
    $rscname='Default-Application-Backup';
    @backupday=();
    @backupfile=();
    @windows=();
    @rsctype=();
    @retention=();
    $weekday=undef;
  }
        
}

  close BPPLLIST;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP