Autosys - 获取特定计算机上的作业列表

Autosys - Get Jobs list on a specific computer

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

当 运行 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 命令是可能的,或者我是否必须通过一些正则表达式解析第一个输出以最终获得我想要的东西?

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

戴夫

我创建了一个 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 框中

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  : "
echo "Input Jill File                   : "
else
echo "Please pass manadatory parameters"
Usage
exit 1
fi


Jill_ColumnOrder=


tfile=

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

我终于创建了一个脚本来帮我完成它:

#!/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: " | wc -l` -eq 1 ]; then
                        cat $file >> "jobs-on-.jil"
                fi
        done < $file
done
rm -rf /tmp/autosystemp

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