Thanks both spacebar and agama, you both are saviours, one small update in script.
Am using script suggested by agama:
Script code:
lswpar | awk '
/^Name/ { next; }
/^---/ { next; }
{ state[$2] = state[$2] $1 " "; }
END {
printf( "==== WPAR Status Check =====\n" );
printf( "**** WPAR state Active:\n\t%s\n\n", state["A"] );
printf( "**** WPAR state Defined/Transition/broken:\n\t%s %s %s\n", state["D"], state["T"], state["B"] );
}
' | mail -s "WPAR `hostname` Server monitoring Status of Client WPARs"
unix_support@xyz.com
Current Mail Output from script:
==== WPAR Status Check =====
**** WPAR state A-Active:
usprd02 usprd03 usprd04 usprd05 usprd06
**** WPAR state D-Defined/T-Transition/B-broken:
I need below required output:
If All WPARs are Active, below output:
==== WPAR Status Check =====
**** WPAR state A-Active:
usprd02 usprd03 usprd04 usprd05 usprd06
All WPARs are in Active State
No Defined/Transition/Broken WPARs
If 2 WPARs are Active, and 3 are Defined/Transition/Broken each, below output:
==== WPAR Status Check =====
**** WPAR state A-Active:
usprd02 usprd03
2 WPARs are in Active State
**** WPAR state D-Defined/T-Transition/B-broken:
usprd04 usprd05 usprd06
3 WPARs are in Defined/Transition/Broken State