test_probes_process.xml.sh | test_probes_process.xml.sh | |||
---|---|---|---|---|
#!/usr/bin/env bash | #!/usr/bin/env bash | |||
TMP_P=(`ps -A -o pid -o ppid -o comm | awk '$1 != 2 && $2 != 2 {print $3}' | \ | TMP_P=(`LD_PRELOAD= ps -A -o pid -o ppid -o comm | awk '$1 != 2 && $2 != 2 {print $3}' | \ | |||
sed -n '2,30p'`) | sed -n '2,30p'`) | |||
COUNTER=1 | COUNTER=1 | |||
for I in "${TMP_P[@]}"; do | for I in "${TMP_P[@]}"; do | |||
if [ `ps -A | grep $I | wc -l` -eq 1 ]; then | J="`echo $I | sed 's/^-/\\\\-/'`" | |||
if [ `LD_PRELOAD= ps -A -o comm| grep $J | wc -l` -eq 1 ]; then | ||||
PROCS[$COUNTER]="$I" | PROCS[$COUNTER]="$I" | |||
COUNTER=$[$COUNTER+1]; | COUNTER=$[$COUNTER+1]; | |||
fi | fi | |||
done | done | |||
function getField { | function getField { | |||
echo `ps -A -o comm -o ${1} | grep ${2} | awk '{ print $2 }'` | COMM="`echo ${2} | sed 's/^-/\\\\-/'`" | |||
echo `LD_PRELOAD= ps -A -o comm -o ${1} | grep ${COMM} | awk '{ print $ | ||||
2 }'` | ||||
} | } | |||
cat <<EOF | cat <<EOF | |||
<?xml version="1.0"?> | <?xml version="1.0"?> | |||
<oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-defi nitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns :xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval .mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:unix-def="http:/ /oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://ov al.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.o rg/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/ XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.m itre.org/XMLSchema/oval-definitions-5#independent independent-definitions-s chema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-de finitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 ova l-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval -common-schema.xsd"> | <oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-defi nitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns :xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval .mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:unix-def="http:/ /oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://ov al.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.o rg/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/ XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.m itre.org/XMLSchema/oval-definitions-5#independent independent-definitions-s chema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-de finitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 ova l-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval -common-schema.xsd"> | |||
<generator> | <generator> | |||
<oval:product_name>process</oval:product_name> | <oval:product_name>process</oval:product_name> | |||
<oval:product_version>1.0</oval:product_version> | <oval:product_version>1.0</oval:product_version> | |||
<oval:schema_version>5.4</oval:schema_version> | <oval:schema_version>5.4</oval:schema_version> | |||
skipping to change at line 95 | skipping to change at line 97 | |||
<states> | <states> | |||
EOF | EOF | |||
I=1 | I=1 | |||
while [ $I -le "${#PROCS[@]}" ]; do | while [ $I -le "${#PROCS[@]}" ]; do | |||
cat <<EOF | cat <<EOF | |||
<process_state version="1" id="oval:1:ste:${I}" xmlns="http://oval.mitr e.org/XMLSchema/oval-definitions-5#unix"> | <process_state version="1" id="oval:1:ste:${I}" xmlns="http://oval.mitr e.org/XMLSchema/oval-definitions-5#unix"> | |||
<command>`getField 'comm' ${PROCS[$I]}`</command> | <command>`getField 'comm' ${PROCS[$I]}`</command> | |||
<pid datatype="int">`getField 'pid' ${PROCS[$I]}`</pid> | <pid datatype="int">`getField 'pid' ${PROCS[$I]}`</pid> | |||
<ppid datatype="int">`getField 'ppid' ${PROCS[$I]}`</ppid> | <ppid datatype="int">`getField 'ppid' ${PROCS[$I]}`</ppid> | |||
<scheduling_class>`getField 'cls' ${PROCS[$I]}`</scheduling_class> | <scheduling_class>`getField 'class' ${PROCS[$I]}`</scheduling_class> | |||
<start_time>`getField 'start_time' ${PROCS[$I]}`</start_time> | <start_time>`getField 'stime' ${PROCS[$I]} | sed 's/\([A-Z][a-z]\{2\} | |||
\)\([0-9]\{1,2\}\)/\1_\2/'`</start_time> | ||||
<user_id datatype="int">`getField 'uid' ${PROCS[$I]}`</user_id> | <user_id datatype="int">`getField 'uid' ${PROCS[$I]}`</user_id> | |||
</process_state> | </process_state> | |||
EOF | EOF | |||
I=$[$I+1] | I=$[$I+1] | |||
done | done | |||
cat <<EOF | cat <<EOF | |||
</states> | </states> | |||
</oval_definitions> | </oval_definitions> | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 9 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |