Hello guys.
about two weeks ago i had a question about customizing output and thanks to you guys i could solve it.
now i have a similar question but this time its little complex.
this is my output:
-------------------+--------------------+---------+---------
ias-component | process-type | pid | status
-------------------+--------------------+---------+---------
DSA | DSA | N/A | Down
LogLoader | logloaderd | N/A | Down
dcm-daemon | dcm-daemon | N/A | Down
OC4J | home | 28168 | Alive
OC4J | home | 28169 | Alive
OC4J | home | 28167 | Down
OC4J | officeauto | 12476 | Alive
OC4J | gaas | 28170 | Alive
OC4J | report | 28172 | Alive
OC4J | workflow | 1477 | Alive
OC4J | messenger | 28175 | Alive
OC4J | archive | 28177 | Alive
OC4J | GamWS | 28189 | Alive
OC4J | sws | 28108 | Alive
OC4J | menu | 28192 | Alive
WebCache | WebCache | 27675 | Alive
WebCache | WebCacheAdmin | 27671 | Alive
HTTP_Server | HTTP_Server | 16552 | Alive
as you can see i have many OC4Js in here and i want to show them like this:
OK|Home=0 Officeauto=1 . . .
for example if all of the home OC4Js were Alive then HomeValue equals to 1 in other wise Homevalue equals to 0.
i wrote this shell script but it didn't work. i know i should use if but i dont know how!
HomeValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /home/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
OfficeautoValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /officeauto/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
ReportValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /report/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
WorkflowValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /workflow/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
MessengerValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /messenger/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
ArchiveValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /archive/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
GamWSValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /GamWS/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
SwsValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /sws/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
MenuValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /menu/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
WebCacheValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /WebCache/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
HTTP_ServerValue=$("$output" | awk -F\| 'NR>6 && $2 ~ /HTTP_Server/ {gsub (/ /,_); print $2 "=" ($4=="Alive")}')
echo "OK|Home="$HomeValue" Officeauto="$officeautoValue" Report="$reportValue" Workflow="$workflowValue" Messenger="$messengerValue" Archive="$archiveValue" GamWS"$GamWSValue" Sws="$swsValue" WebCache="$WebCacheValue" HTTP_Server="$HTTP_ServerValue""
---------- Post updated at 07:59 AM ---------- Previous update was at 07:47 AM ----------
i forget something:
the OC4Js count is variable. i mean it completely depends to the server configuration.
Thank you.