Here's how to do it in general:
$ cat test.awk
BEGIN { FS=OFS="," }
{n=0; for (i=1;i<=NF;i++) {($i ~ /(*)/) && n++}}
{ print "Fields: " NF, " Matches: " n}
n == 0 {$NF="OFFLINE"}
n < NF-3 {$NF="PARTIAL"}
n == NF-3 {$NF="CONNECTED"}
n > NF-3 {$NF="ERROR"}
{print}
I've included a diagnostic line { print "Fields: " NF, "Matches: " n}
to help point out what I think is a problem with the specification, see below. You can comment out the diagnostic line with # comment character.
I also included an ERROR line n > NF-3 {$NF="ERROR"}
just in case that condition ever occurs. You could also have it print an error message there and exit. If the error condition is impossible, you can delete that line.
Anyway, back to the problem with the specification, assume the input file is the following, as you just posted:
$ cat input
N_DC_Fabric_A,AU_SAP01,c050760169900000(*),50060169472007fc(*),50060160472007fc(*),
N_DC_Fabric_A,AU_SAP02,c050760169900004,50060169472007fc(*),50060160472007fc(*),
N_DC_Fabric_A,AU_SAP03,c050760169900004,50060169472007fc,50060160472007fc,
N_DC_Fabric_A,AU_SAP011,c050760169900000(*),50060169472007fc(*),
When we run the awk script, here is what it produces, along with the diagnostic messages:
$ awk -f test.awk input
Fields: 6, Matches: 3
N_DC_Fabric_A,AU_SAP01,c050760169900000(*),50060169472007fc(*),50060160472007fc(*),CONNECTED
Fields: 6, Matches: 2
N_DC_Fabric_A,AU_SAP02,c050760169900004,50060169472007fc(*),50060160472007fc(*),PARTIAL
Fields: 6, Matches: 0
N_DC_Fabric_A,AU_SAP03,c050760169900004,50060169472007fc,50060160472007fc,PARTIAL
Fields: 5, Matches: 2
N_DC_Fabric_A,AU_SAP011,c050760169900000(*),50060169472007fc(*),CONNECTED
The last record is CONNECTED. It has 5 fields (2 matches). awk counts the end of the line after the last comma as a field. I think maybe you were counting that last record as having 4 fields. So I would suggest the condition for CONNECTED is NF-3 instead of NF-2. I hope that makes sense.
The first record is also CONNECTED, I think, NOT PARTIAL as you had in the last post. The line has 6 fields (3 matches).
In any case, the first and last record should be both be the same (either CONNECTED or PARTIAL) I think, because the last record has one more field, and has one more match, so both sides of the matches == NF - N
equation increase.
One more thing. If some of the lines do not end with a comma, the awk script will not work correctly. If there is any question, to be safe, you could always run sed -e "s/ *$//" -e "s/[^,]$/&,/"
on the file first.