#!/bin/bash
echo -e Resource\\tNode\\tScore\\t[target_role]
2>&1 ptest -LVVVVVVV|grep -E "assign_node|rsc_location"|grep -w -E "\ [-]{0,1}[0-9]*$"|while read line
do
        node=`echo $line|cut -d ' ' -f 8|cut -d ':' -f 1`
        res=`echo $line|cut -d ' ' -f 6|tr -d ","`
        score=`echo $line|cut -d ' ' -f 9`
        targetrole=`cibadmin -Q|grep $res|grep target_role|grep -o -E 'value=".*"'|cut -d '"' -f 2|grep -i stopped`
        if [ "$targetrole" = "stopped" ]
        then
                echo zScore of -1000000 is intentional when target_role=\"stopped\"
        fi
        echo -e a$res\\t$node\\t$score\\t$targetrole
done|sort -k 1|uniq|cut -b 2-
