【问题标题】:Autosys - Get Jobs list on a specific computerAutosys - 在特定计算机上获取作业列表
【发布时间】:2017-09-08 09:51:12
【问题描述】:

我尝试获取在特定客户端上运行的所有作业的列表。

运行autorep -J ALL -q 时,我得到以下输出:

 /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ###


  /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE Y
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ### 

  ...

如您所见,此处显示所有客户所有工作列表

我期望得到如下输出:

 /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ###


  /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ### 

  ...

不幸的是,autorep -J ALL -q -m MACHINE X 命令不起作用,但给我以下输出:

/* ----------------- MACHINE X ----------------- */

insert_machine: MACHINE X
type: a
factor: 1.00
port: 7520
node_name: MACHINE X
agent_name: WA_AGENT
encryption_type: DEFAULT
opsys: windows
character_code: ASCII

我猜这是添加机器的JIL格式,所以我期望得到什么。

你知道我尝试做的事情是否仅使用 autosys 命令是可能的,或者我是否必须通过一些正则表达式解析第一个输出才能最终获得我想要的?

【问题讨论】:

    标签: autosys jil


    【解决方案1】:

    我创建了一个 Autosys Jill 解析器,使用它您可以在 csv 文件中获得所需的信息。之后您可以过滤所需的信息

    首先,您必须有一个文件,其中包含要从 jill 中提取的所需列

    $]cat Jill_Columns
    insert_job
    job_type
    box_name
    watch_file
    watch_interval
    command
    date_conditions
    machine
    owner
    permission
    condition
    days_of_week
    exclude_calendar
    start_times
    description
    std_out_file
    std_err_file
    alarm_if_fail
    profile
    application
    

    还有需要解析成csv的Jill文件

    这是脚本

    在 unix box 中运行的命令

    sh JillToCsv.sh Your_Jill_Columns Yours_Jill_file

    #!/bin/bash
    
    
    
    Usage()
    {
    echo "----------------------------------------------------------------------------"
    echo " "
    echo " "
    echo " "
    echo "This script takes two parameter "
    echo "First is the file which conatins column names like below for Jill information "
    echo "cat Jill_ColumnOrder.txt"
    echo "insert_job
    job_type
    box_name
    command
    date_conditions
    machine
    owner
    permission
    condition
    days_of_week
    exclude_calendar
    start_times
    description
    std_out_file
    std_err_file
    alarm_if_fail
    profile
    application"
    
    echo " "
    echo " "
    echo " "
    echo "Second is the Jill File which needs to be parsed as csv "
    echo " "
    echo " "
    echo " "
    echo "----------------------------------------------------------------------------"
    }
    
    if [ $# -eq 2 ]
    then
    echo "File which contains column names  : $1"
    echo "Input Jill File                   : $2"
    else
    echo "Please pass manadatory parameters"
    Usage
    exit 1
    fi
    
    
    Jill_ColumnOrder=$1
    
    
    tfile=$2
    
    dos2unix $tfile
    
    final=${tfile}_Parse.csv
    rm -f $final
    
    
    heading=`cat $Jill_ColumnOrder|sed 's/$/@Akhilesh@/g'|sed '$ s/@Akhilesh@$//g'|tr -d '\n'`
    
    line=
    filler=1
    
    
    no_columns=`cat $Jill_ColumnOrder|wc -l`
    
    
    while [ $filler -lt $no_columns ]
    do
            filler=`expr $filler + 1`
            line=$line`echo -n "@Akhilesh@"`
            #echo $line
    done
    
    #echo "$heading"
    #echo "   "
    #echo "$line"
    
    
    
    echo "$heading">$final
    
    
    
    count=1
    cat $tfile|sed -r 's/job_type/\njob_type/g'|sed '/^$/d'|sed -r 's/\s+/ /g'|while read kk
    do
            echo "$kk"|sed -r 's/^[ ]+//g'|grep '\/\* -----------------' # >/dev/null
            if [ $? -eq 0 ]
            then
                    count=`expr $count + 1`
                    echo "$line">>$final
            else
            PP=`echo $kk|cut -d ':' -f1|tr -d ' '`
            #echo "PP    : $PP"
            val=`echo $kk|cut -d ':' -f2-|sed -r 's/^[ ]+//g'|tr -d '"'|tr -d '\n'`
            #echo $val
            val=\"$val\"
            field=`grep -nw $PP $Jill_ColumnOrder|cut -d':' -f1|tr -d '\n'`
    
            #echo "field   :  $field"
    
            if [ -z $field ]
            then
            echo "$PP not there in column list"
            else
    
            awk -F'@Akhilesh@' -v OFS=@Akhilesh@ -v var="$val" -v var1=$count '{if(NR== var1) $'$field' = var;print}' $final > tmp.parse && mv tmp.parse $final
            fi
    
    
    
            fi
    done
    
    
    
    
    cat $final|sed 's/@Akhilesh@/,/g' > tmp.parse && mv tmp.parse $final
    

    【讨论】:

      【解决方案2】:

      autorep 目前还不支持这种排序。您将需要解析输出。

      戴夫

      【讨论】:

      • 不是我正在寻找的答案,但很可能是真的,很遗憾 - 无论如何谢谢
      【解决方案3】:

      我终于为我创建了一个脚本:

      #!/bin/ksh
      autorep -j ALL -q > alljobs.jil
      mkdir /tmp/autosystemp
      i=0
      while IFS=\| read -r "line"; do
              if [ `echo $line | grep '/* ------' | wc -l` -eq 1 ]; then
                      i=$((i+1))
              fi
              echo "$line" >> "/tmp/autosystemp/f$i"
      done < alljobs.jil
      rm tempo/f0
      for file in /tmp/autosystemp/*; do
              while read line; do
                      if [ `echo $line | grep "machine: $1" | wc -l` -eq 1 ]; then
                              cat $file >> "jobs-on-$1.jil"
                      fi
              done < $file
      done
      rm -rf /tmp/autosystemp
      

      要使用它,只需将机器名称作为参数传递给脚本

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多