
# Copyright 05/04/98 Sun Microsystems, Inc. All Rights Reserved.
#pragma ident  "@(#)Config-Reader4u-d.rul	1.1 98/05/04 Sun Microsystems"

# Rule 208
#
# Looks for ECC errors in syslog
#
proc rcr4u208 { action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	set estatus "warning"

	switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u208\n"

			logSubscribe $ruleId /var/adm/messages "(\[Ee\])nabling verbose CE messages(.*)" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug "from open of rcr4u208\n"

			set longmsg [ getRuleMsg ircr4u208longmsg ]
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}



#
# Rule 210.
# error due to Hardware Error
#

proc rcr4u210 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u210 \n"
			
			logSubscribe $ruleId /var/adm/messages "WARNING.*(ss*d\[0-9\]+).*command (\[^ \]+) \[Ee\]r.*\[Hh\]ardware \[Ee\]rror" $rowName $ruleId -m
			return ""
                }
		open {
			ddl print debug " from open of rcr4u210: \n"
			ddl print debug " from open of rcr4u210:list is $matchList\n"
			set diskname [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u210:diskname is $diskname\n"
			set cmdname [ lindex $matchList 1 ]
			ddl print debug " from open of rcr4u210:cmdname is $cmdname\n"
			set ctnode $diskname
			ddl print debug " from open of rcr4u210:ctnode is $ctnode\n"

			set longmsg [ format [ getRuleMsg ircr4u210longmsg ] "$ctnode" ]
			ddl print debug " from open of rcr4u210:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 211.
#  error due to Fatal Error
#

proc rcr4u211 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "error"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u211 \n"
			
			logSubscribe $ruleId /var/adm/messages "WARNING.*(ss*d\[0-9\]+):.*\[Ff\]atal" $rowName $ruleId -m
			return ""
                }
		open {
			ddl print debug " from open of rcr4u211: \n"
			ddl print debug " from open of rcr4u211:list is $matchList\n"
			set diskname [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u211:diskname is $diskname\n"
			set ctnode $diskname
			ddl print debug " from open of rcr4u211:ctnode is $ctnode\n"

			set longmsg [ format [ getRuleMsg ircr4u211longmsg ] "$ctnode" ]
			ddl print debug " from open of rcr4u211:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}





#
# Rule 214.
# power failing
#

proc rcr4u214 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "error"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u214 \n"
			
			logSubscribe $ruleId /var/adm/messages "WARNING: (.*) \[Ff\]ailing" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u214: \n"
			ddl print debug " from open of rcr4u214:list is $matchList\n"
			set what [ lrange $matchList 0 end]
			ddl print debug " from open of rcr4u214:what is $what\n"
			set longmsg [ format [ getRuleMsg ircr4u214longmsg ] "$what" ]
			ddl print debug " from open of rcr4u214:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 216.
# cpu panic
#

proc rcr4u216 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "error"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u216 \n"
			
			logSubscribe $ruleId /var/adm/messages "panic \[\[\]cpu(\[0-9\]+)\[\]\]\[\/\]thread=0x\[0-9a-f\]+: (\[^:\]+)" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u216: \n"
			ddl print debug " from open of rcr4u216:list is $matchList\n"
			set cpuno [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u216:cpuno is $cpuno\n"
			set error [ lrange $matchList  1 end ]
			ddl print debug " from open of rcr4u216:error is $error\n"
			set longmsg [ format [ getRuleMsg ircr4u216longmsg ] "$cpuno" "$error" ]
			ddl print debug " from open of rcr4u216:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 217.
# scsi tape error
#

proc rcr4u217 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "error"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u217 \n"
			
			logSubscribe $ruleId /var/adm/messages "WARNING.*(st\[0-9\]+).*\[\:\].*\[Ee\]rror rate \[\(\](\[0-9\]+)%\[\)\].*too high" $rowName $ruleId -m
			return ""
                }
		open {
			ddl print debug " from open of rcr4u217: \n"
			ddl print debug " from open of rcr4u217:list is $matchList\n"
			set tapeno [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u217:tapeno is $tapeno\n"
			set err_rate [ lindex $matchList 1 ]
			ddl print debug " from open of rcr4u217:err_rate is $err_rate\n"
			set longmsg [ format [ getRuleMsg ircr4u217longmsg ] "$tapeno" "$err_rate" ]
			ddl print debug " from open of rcr4u217:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 219.
# disk removed 
#

proc rcr4u219 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u219 \n"
			
			logSubscribe $ruleId /var/adm/messages "WARNING:.*(ss*d\[0-9\]+).*offline" $rowName $ruleId -m
			return ""
                }
		open {
			ddl print debug " from open of rcr4u219: \n"
			ddl print debug " from open of rcr4u219:list is $matchList\n"
			set diskname [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u219:diskname is $diskname\n"
			set ctnode $diskname
			ddl print debug " from open of rcr4u219:ctnode is $ctnode\n"
			set longmsg [ format [ getRuleMsg ircr4u219longmsg ] "$diskname" ]
			ddl print debug " from open of rcr4u219:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 220.
#  disk insert
#

proc rcr4u220 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u220 \n"
			
			logSubscribe $ruleId /var/adm/messages "(ss*d\[0-9\]+):.*disk okay" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u220: \n"
			ddl print debug " from open of rcr4u220:list is $matchList\n"
			set diskname [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u220:diskname is $diskname\n"
			set ctnode $diskname
			ddl print debug " from open of rcr4u220:ctnode is $ctnode\n"
			set longmsg [ format [ getRuleMsg ircr4u220longmsg ] "$diskname" ]
			ddl print debug " from open of rcr4u220:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 222.
# testing sunvts messages log
#

proc rcr4u222 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "error"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u222 \n"
			
			logSubscribe $ruleId /var/opt/SUNWvts/logs/sunvts.err "FATAL: \[\"\](.*)\[\"\]" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u222: \n"
			ddl print debug " from open of rcr4u222:list is $matchList\n"
			set vtsmsg [ lrange $matchList 0 end ]
			ddl print debug " from open of rcr4u222:vtsmsg is $vtsmsg\n"
			set longmsg [ format [ getRuleMsg ircr4u222longmsg ] "$vtsmsg" ]
			ddl print debug " from open of rcr4u222:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}




#
# Rule 223.
# testing sunvts messages log
#

proc rcr4u223 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u223 \n"
			
			logSubscribe $ruleId /var/opt/SUNWvts/logs/sunvts.err "ERROR: \[\"\](.*)\[\"\]" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u223: \n"
			ddl print debug " from open of rcr4u223:list is $matchList\n"
			set vtsmsg [ lrange $matchList 0 end ]
			ddl print debug " from open of rcr4u223:vtsmsg is $vtsmsg\n"
			set longmsg [ format [ getRuleMsg ircr4u223longmsg ] "$vtsmsg" ]
			ddl print debug " from open of rcr4u223:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

#
# Rule TEMPRATUER-RULE.
#205

proc rcr4u205 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u205: \n"
			set boardtype [ getExternalRowValue $ruleId board.boardTbl.board-entry.type-int $rowName ]
			set nodename [ getExternalRowValue $ruleId board.boardTbl.board-entry.sunSmNodeName $rowName ]
	                set tempdegree  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u205:boardtype is $boardtype\n"
			ddl print debug " from condition of rcr4u205:tempdegree is $tempdegree\n"
			 setRuleParm DYN $ruleId $rowName cur_temp $tempdegree
			 setRuleParm DYN $ruleId $rowName cur_board $boardtype
			 setRuleParm DYN $ruleId $rowName cur_node $nodename
	                expr { (($tempdegree != "--") && (($tempdegree >= 73) && ($boardtype == 2 || $boardtype == 3 || $boardtype == 7 )) || (($tempdegree >= 60) && ($boardtype == 5 || $boardtype == 6 || $boardtype == 8 ))) }
		}
                init {
			ddl print debug " from init of rcr4u205: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u205: \n"
			set tempdegree [ getRuleParm DYN $ruleId $rowName cur_temp ]
			ddl print debug " from open of rcr4u205:tempdegree is $tempdegree\n"
			set boardtype [ getRuleParm DYN $ruleId $rowName cur_board ]
			ddl print debug " from open of rcr4u205:boardtype is $boardtype\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u205:boardname is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u205longmsg ] "$nodename" "$tempdegree" "$boardtype" ]
			ddl print debug " from open of rcr4u205:longmsg is $longmsg\n"
			if { $boardtype == 2 || $boardtype == 3 || $boardtype == 7 } {
	                	if { $tempdegree >= 83 } {
					set estatus error
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				} else {
					set estatus warning
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				}
			} elseif { $boardtype == 4 || $boardtype == 5 || $boardtype == 6 || $boardtype == 8 } {
	                	if { $tempdegree >= 68 } {
					set estatus error
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				} else {
					set estatus warning
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				}
                	} else {
				return ok
			}
		}
		continue {
			ddl print debug " from continue of rcr4u205: \n"
			set tempdegree [ getRuleParm DYN $ruleId $rowName cur_temp ]
			ddl print debug " from continue of rcr4u205:tempdegree is $tempdegree\n"
			set boardtype [ getRuleParm DYN $ruleId $rowName cur_board ]
			ddl print debug " from continue of rcr4u205:boardtype is $boardtype\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u205:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u205longmsg ] "$nodename" "$tempdegree" "$boardtype" ]
			ddl print debug " from continue of rcr4u205:longmsg is $longmsg\n"
			if { $boardtype == 2 || $boardtype == 3 || $boardtype == 7 } {
	                	if { $tempdegree >= 83 } {
					set estatus error
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				} else {
					set estatus warning
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				}
			} elseif { $boardtype == 4 || $boardtype == 5 || $boardtype == 6 || $boardtype == 8 } {
	                	if { $tempdegree >= 68 } {
					set estatus error
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				} else {
					set estatus warning
					setRuleText $ruleId $rowName $estatus $longmsg
					return $estatus
				}
                	} else {
				return ok
			}
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule FAN-STATUS-RULE.
#204

proc rcr4u204 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u204: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u204:value is $value\n"
			 setRuleParm DYN $ruleId $rowName cur_value $value

	                expr { ($value != "OK") }
		}
                init {
			ddl print debug " from init of rcr4u204: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u204: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from open of rcr4u204:value is $value\n"
			set longmsg [ format [ getRuleMsg ircr4u204longmsg ] "$value" ]
			ddl print debug " from open of rcr4u204:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u204: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from continue of rcr4u204:value is $value\n"
			set longmsg [ format [ getRuleMsg ircr4u204longmsg ] "$value" ]
			ddl print debug " from continue of rcr4u204:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

#
# Rule 213.
# Hot plug Removed
#

proc rcr4u213 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u213 \n"
			
			logSubscribe $ruleId /var/adm/messages "NOTICE: (.*) \[Rr\]emoved" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u213: \n"
			ddl print debug " from open of rcr4u213:list is $matchList\n"
			set what [ lrange $matchList 0 end]
			ddl print debug " from open of rcr4u213:what is $what\n"
			set longmsg [ format [ getRuleMsg ircr4u213longmsg ] "$what" ]
			ddl print debug " from open of rcr4u213:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule 215.
# Hot plug Removed
#

proc rcr4u215 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u215 \n"
			
			logSubscribe $ruleId /var/adm/messages "NOTICE: (.*) \[Hh\]otplugged into slot (\[0-9\]+)" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u215: \n"
			ddl print debug " from open of rcr4u215:list is $matchList\n"
			set slotnumber [ lindex $matchList 1 ]
			ddl print debug " from open of rcr4u215:slotnumber is $slotnumber\n"
			set what [ lrange $matchList 0 end]
			ddl print debug " from open of rcr4u215:what is $what\n"
			set longmsg [ format [ getRuleMsg ircr4u215longmsg ] "$what" ]
			ddl print debug " from open of rcr4u215:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule 224.
# Hot plug installed
#

proc rcr4u224 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u224 \n"
			
			logSubscribe $ruleId /var/adm/messages "NOTICE: (.*) \[Ii\]nstalled" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u224: \n"
			ddl print debug " from open of rcr4u224:list is $matchList\n"
			set what [ lrange $matchList 0 end]
			ddl print debug " from open of rcr4u224:what is $what\n"
			set longmsg [ format [ getRuleMsg ircr4u224longmsg ] "$what" ]
			ddl print debug " from open of rcr4u224:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule 221.
# Hot plug installed
#

proc rcr4u221 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
	set estatus "warning"

        switch $action {
		condition {
			return 1
		}
                init {
			ddl print debug " from init of rcr4u221 \n"
			
			logSubscribe $ruleId /var/adm/messages ": \[Rr\]edundant power (.*)" $rowName $ruleId
			return ""
                }
		open {
			ddl print debug " from open of rcr4u221: \n"
			ddl print debug " from open of rcr4u221:list is $matchList\n"
			set status [ lindex $matchList 0 ]
			ddl print debug " from open of rcr4u221:status is $status\n"
			set longmsg [ format [ getRuleMsg ircr4u221longmsg ] "$status" ]
			ddl print debug " from open of rcr4u221:longmsg is $longmsg\n"
			setRuleText $ruleId $rowName $estatus $longmsg
			logEvent $ruleId $rowName $estatus
			return ok
		}
		continue {
			return 
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule ST-STATUS-RULE.
#225

proc rcr4u225 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u225: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u225:value is $value\n"
			set nodename [ getExternalRowValue $ruleId tape.tapeTbl.tapeEntry.sunSmNodeName $rowName ]
			 setRuleParm DYN $ruleId $rowName cur_value $value
			 setRuleParm DYN $ruleId $rowName cur_node $nodename

	                expr { ($value != "OK") && ($value != "ok") &&($value != "drive present, but busy") }
		}
                init {
			ddl print debug " from init of rcr4u225: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u225: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u225:value is $value\n"
			set longmsg [ format [ getRuleMsg ircr4u225longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of 225:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u225: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from continue of rcr4u225:value is $value\n"
			set longmsg [ format [ getRuleMsg ircr4u225longmsg ] "$nodename" "$value" ]
			ddl print debug " from continue of rcr4u225:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule AC-STATUS-RULE.
#218

proc rcr4u218 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u218: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u218:value is $value\n"
			set nodename [ getExternalRowValue $ruleId ac.acTbl.ac-entry.sunSmNodeName $rowName ]
			 setRuleParm DYN $ruleId $rowName cur_value $value
			 setRuleParm DYN $ruleId $rowName cur_node $nodename

	                expr { ($value != "OK") && ($value != "ok") && ($value != "okay") && ($value != "nomem") && ($value != "") && ($value != "--") && ($value != "spare") }
		}
                init {
			ddl print debug " from init of rcr4u218: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u218: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from open of rcr4u218:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u218:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u218longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of rcr4u218:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u218: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from continue of rcr4u218:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from continue of rcr4u218:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u218longmsg ] "$nodename" "$value" ]
			ddl print debug " from continue of rcr4u218:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule power-suuply-STATUS-RULE.
#203
#
# 1.6 logic for this rule
# proc rcr4u203 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
#	switch $action {
#		condition {
#			ddl print debug " from condition of rcr4u203: \n"
#	                set value  [ getMyValue $ruleId $rowName ]
#			ddl print debug " from condition of rcr4u203:value is $value\n"
#			 setRuleParm DYN $ruleId $rowName cur_val $value
#
#	                expr { ($value != "OK") && ($value != "Enabled") }
#		}
#                init {
#			ddl print debug " from init of rcr4u203: \n"
#			return ""
#                }
#		open {
#			ddl print debug " from open of rcr4u203: \n"
#			set value [ getRuleParm DYN $ruleId $rowName cur_val ]
#			ddl print debug " from open of rcr4u203:value is $value\n"
#			if { $value != "unknown" } {
#
#				set longmsg [ format [ getRuleMsg ircr4u203longmsg ] "$value" ]
#				ddl print debug " from open of rcr4u203:longmsg is $longmsg\n"
#			 	setRuleParm DYN $ruleId $rowName cur_val $value
#				set estatus error
#				return $estatus
#			}
#			setRuleParm DYN $ruleId $rowName cur_val $value
#			return ok
#		}
#		continue {
#			ddl print debug " from continue of rcr4u203: \n"
#			set oldvalue [ getRuleParm DYN $ruleId $rowName cur_val ]
#	                set newvalue  [ getMyValue $ruleId $rowName ]
#			if { $newvalue == $oldvalue } {
#				if { $newvalue == "unknown" } {
#					set longmsg [ format [ getRuleMsg ircr4u203longmsg ] "$newvalue" ]
#					ddl print debug " from continue of rcr4u203:longmsg is $longmsg\n"
#					setRuleParm DYN $ruleId $rowName cur_val "ALARMED"
#					set estatus error
#					return $estatus
#				} else { }
#			} else {
#	                        if { ($newvalue == "unknown") && ($oldvalue == "ALARMED") } {
#				} else {
#					if { $newvalue != "unknown" } {
#						closeEvent $ruleId $rowName "ok"
#						set longmsg [ format [ getRuleMsg ircr4u203longmsg ] "$newvalue" ]
#						ddl print debug " from continue of rcr4u203:longmsg is $longmsg\n"
#						set estatus error
#						return $estatus
#					} else { }
#					setRuleParm DYN $ruleId $rowName cur_val $newvalue
#				}
#			}
#		}
#		ack {
#			return
#		}
#		fix {
#			return
#		}
#		close {
#				return ok
#		}
#	}
#}




# Rule power-suuply-STATUS-RULE.
#203
#
# Alram whenever we see status other than OK and enabled.
# If it is unknown then an alarm will be generated abd go away If
# the status changes. If it does not alarm will remain.


 proc rcr4u203 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	switch $action {
		condition {
			ddl print debug " from condition of rcr4u203: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u203:value is $value\n"
			set nodename [ getExternalRowValue $ruleId power_supply.power_supplyTbl.power_supply-entry.sunSmNodeName $rowName ]
			 setRuleParm DYN $ruleId $rowName cur_val $value
			 setRuleParm DYN $ruleId $rowName cur_node $nodename

	                expr { ($value != "OK") && ($value != "Enabled") }
		}
                init {
			ddl print debug " from init of rcr4u203: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u203: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_val ]
			ddl print debug " from open of rcr4u203:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u203:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u203longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of rcr4u203:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u203: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_val ]
			ddl print debug " from open of rcr4u203:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from continue of rcr4u203:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u203longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of rcr4u203:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

## Rule precharge status rule
#201

proc rcr4u201 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u201: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u201:value is $value\n"
			set nodename [ getExternalRowValue $ruleId sunSmNodeName $rowName ]
			 setRuleParm DYN $ruleId $rowName cur_value $value
			 setRuleParm DYN $ruleId $rowName cur_node $nodename

	                expr { ($value != "OK") && ($value != "NA") }
		}
                init {
			ddl print debug " from init of rcr4u201: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u201: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from open of rcr4u201:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u201:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u201longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of rcr4u201:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u201: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_value ]
			ddl print debug " from continue of rcr4u201:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from continue of rcr4u201:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u201longmsg ] "$nodename" "$value" ]
			ddl print debug " from continue of rcr4u201:longmsg is $longmsg\n"
			set estatus error
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

# Rule ST-STATUS-RULE.
#207

proc rcr4u207 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
	
        switch $action {
		condition {
			ddl print debug " from condition of rcr4u207: \n"
	                set value  [ getMyValue $ruleId $rowName ]
			ddl print debug " from condition of rcr4u207:value is $value\n"
			set nodename [ getExternalRowValue $ruleId cpu-unit.cpu-unitTbl.cpu-unit-entry.sunSmNodeName $rowName ]
			 setRuleParm DYN $ruleId $rowName cur_val $value
			 setRuleParm DYN $ruleId $rowName cur_node $nodename

	                expr { ($value != "OK") && ($value != "online") && ($value != "noncritical") }
		}
                init {
			ddl print debug " from init of rcr4u207: \n"
			return ""
                }
		open {
			ddl print debug " from open of rcr4u207: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_val ]
			ddl print debug " from open of rcr4u207:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from open of rcr4u207:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u207longmsg ] "$nodename" "$value" ]
			ddl print debug " from open of 207:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		continue {
			ddl print debug " from continue of rcr4u207: \n"
			set value [ getRuleParm DYN $ruleId $rowName cur_val ]
			ddl print debug " from continue of rcr4u207:value is $value\n"
			set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
			ddl print debug " from continue of rcr4u207:nodename is $nodename\n"
			set longmsg [ format [ getRuleMsg ircr4u207longmsg ] "$nodename" "$value" ]
			ddl print debug " from continue of rcr4u207:longmsg is $longmsg\n"
			set estatus error
			setRuleText $ruleId $rowName $estatus $longmsg
			return $estatus
		}
		ack {
			return
		}
		fix {
			return
		}
		close {
			return ok
		}
	}
}

#
# Rule 300.
# Looks for SIMM memory errors in syslog and makes a PFA
# entry for each.
#

proc rpfa300 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {

        switch $action {
                condition {
                        return 1
                }
                init {
                        ddl print debug " from init of rpfa300 \n"

                        logSubscribe $ruleId /var/adm/messages "ECC \[Mm\]emory \[Ee\]rror.*SIMM Board (\[0-9\]+) (\[^ \]\[0-9\]+)" $rowName $ruleId
                        return ""
                }
                open {
                        ddl print debug " from open of rpfa300: \n"
                        ddl print debug " from open of rpfa300:list is $matchList\n"
                        set boardno [ lindex $matchList 0 ]
                        set boardrefno [ lindex $matchList 1 ]
                        set reflist [ valuesOf  simm.simmTbl.simm-entry.board_reference_number ]
                        set rowid [ lsearch $reflist $boardrefno ]
                        set rowid [ expr $rowid+1 ]
                        set node_logword1 [ getExternalRowValue $ruleId simm.simmTbl.simm-entry.sunSmNodeName $rowid ]
                        set ctnode system.slot($boardno).board($boardno).$node_logword1
                        set size [ getExternalRowValue $ruleId simm.simmTbl.simm-entry.size $rowid ]
                        ddl print debug " from open of rpfa300:ctnode is $ctnode, size is $size\n"
			set dte [ getTime ]
			add_pfa SIMM $dte $ctnode $size
			trim_pfa
			
			set msg [ format [ getRuleMsg irpfa300longmsg ] "$ctnode" ]
			# Check for Test Period 1 errors
			set level [ check_pfa_simm 0 $ctnode ]
	                if { "$level" == "RED" } {
				set estatus error
				setRuleText $ruleId $rowName $estatus $msg ""
                        	logEvent $ruleId $rowName $estatus
			}

			# Check for Test Period 2 errors
			set level [ check_pfa_simm 1 $ctnode ]
	                if { "$level" == "YELLOW" } {
				set estatus error
				setRuleText $ruleId $rowName $estatus $msg ""
                        	logEvent $ruleId $rowName $estatus
			}

			# Check for Test Period 3 errors
			set level [ check_pfa_simm 2 $ctnode ]
	                if { "$level" == "YELLOW" } {
				set estatus error
				setRuleText $ruleId $rowName $estatus $msg ""
                        	logEvent $ruleId $rowName $estatus
			}
                        return ok
                }
                continue {
                        return
                }
                ack {
                        return
                }
                fix {
                        return
                }
                close {
                        return ok
                }
        }
}

#
# Rule 301.
# Looks for disk soft errors in syslog and makes a PFA
# entry for each.
#

proc rpfa301 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {

        switch $action {
                condition {
                        return 1
                }
                init {
                        ddl print debug " from init of rpfa301 \n"

                        logSubscribe $ruleId /var/adm/messages "WARNING.*(ss*d\[0-9\]+).*\[Ee\]r.*\[Rr\]ecovered" $rowName $ruleId
                        return ""
                }
                open {
                        ddl print debug " from open of rpfa301: \n"
                        ddl print debug " from open of rpfa301:list is $matchList\n"
                        set ctnode [ lindex $matchList 0 ]
			# No size for disk
                        set size ""
                        ddl print debug " from open of rpfa301:ctnode is $ctnode, size is $size\n"
                        set dte [ getTime ]
                        add_pfa DISK $dte $ctnode $size
                        trim_pfa

                        set msg [ format [ getRuleMsg irpfa301longmsg ] "$ctnode" ]
                        # Checks for disk PFA
                        set level [ check_pfa_disk 0 $ctnode ]
                        if { "$level" == "RED" } {
                                set estatus error
                                setRuleText $ruleId $rowName $estatus $msg ""
                        	logEvent $ruleId $rowName $estatus
                        }

                        # Checks for disk PFA
                        set level [ check_pfa_disk 1 $ctnode ]
                        if { "$level" == "YELLOW" } {
                                set estatus error
                                setRuleText $ruleId $rowName $estatus $msg ""
                        	logEvent $ruleId $rowName $estatus
                        }

                        return ok
                }
                continue {
                        return
                }
                ack {
                        return
                }
                fix {
                        return
                }
                close {
                        return ok
                }
        }
}

#
# Rule 302.
# Looks for disk soft errors in syslog that is spilled out
# by a SMART drive.
# No analysis is needed on this.  Since the SMART drive
# has already done that.
#

proc rpfa302 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {

	set estatus "error"
        switch $action {
                condition {
                        return 1
                }
                init {
                        ddl print debug " from init of rpfa302 \n"

                        logSubscribe $ruleId /var/adm/messages "(ss*d\[0-9\]+).*drive operation marginal, service immediately" $rowName $ruleId -m
                        return ""
                }
                open {
                        ddl print debug " from open of rpfa302: \n"
                        ddl print debug " from open of rpfa302:list is $matchList\n"
                        set ctnode [ lindex $matchList 0 ]
			# No size for disk
                        set size ""
                        ddl print debug " from open of rpfa302:ctnode is $ctnode, size is $size\n"
                        set dte [ getTime ]
                        set msg [ format [ getRuleMsg irpfa302longmsg ] "$ctnode" ]
                        setRuleText $ruleId $rowName $estatus $msg ""
                        logEvent $ruleId $rowName $estatus
                        return ok
                }
                continue {
                        return
                }
                ack {
                        return
                }
                fix {
                        return
                }
                close {
                        return ok
                }
        }
}
