#
#pragma ident "@(#)Config-Reader4uwg-d.rul	1.10 01/02/13 Sun Microsystems"
#


#
# Rule 209.
# UltraSparc I/II SIMM correctable error rule --
# open an alarm which is closed immediately, based on
# Solaris Error Recovery project messages
#
# Expected messages are e.g:
#
# Feb  2 10:01:43 wgs99-92 SUNW,UltraSPARC-II: [ID 212736 kern.notice]
# [AFT0] Corrected Memory Error on CPU3, errID 0x0000002b.b705ab19
#
#

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

    switch $action {
	condition {
	    return 1
	}
	init {
	    ddl print debug " from init of rcr4u209\n"
	    
	    logSubscribe $ruleId /var/adm/messages "\[\[\]AFT0\[\]\] (.*) on (CPU\[0-9\]+)" $rowName $ruleId
	    return ""
	}
	open {
	    ddl print debug "from open of rcr4u209\n"
	    ddl print debug "from open of rcr4u209: list is $matchList\n"
	    set errdesc [ lindex $matchList 0 ]
	    ddl print debug "from open of rcr4u209: errdesc is $errdesc from open\n"
	    set cpuname [ lindex $matchList 1 ]
	    ddl print debug "from open of rcr4u209: cpuname is $cpuname from open\n"
	    set longmsg [ format [ getRuleMsg ircr4u209longmsg ] "$errdesc" "$cpuname" ]
	    ddl print debug "from open of rcr4u209: longmsg is  $longmsg from open\n"
	    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
			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
			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 212.
# Ultra Sparc III Correctable error
#
# Message is e.g:
#
# Feb 12 14:06:37 wgs97-57 SUNW,UltraSPARC-III: [ID 557032 kern.notice]
# CPU2 System bus data hardware corrected error:
# AFSR 0x00000002.00000037 AFAR 0x00000020.2795abc0
#
#

proc rcr4u212 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
    
    set estatus "warning"
    
    switch $action {
	condition {
	    return 1
	}
	init {
	    ddl print debug " from init of rcr4u212 \n"
	    logSubscribe $ruleId /var/adm/messages "(CPU\[0-9\]+) (.*) hardware corrected error" $rowName $ruleId
	    return ""
	}
	open { 
            ddl print debug "from open of rcr4u212\n" 
            ddl print debug "from open of rcr4u212: list is $matchList\n" 
            set cpuname [ lindex $matchList 0 ] 
            ddl print debug "from open of rcr4u212: cpuname is $cpuname from open\n" 
            set errdesc [ lindex $matchList 1 ] 
            ddl print debug "from open of rcr4u212: errdesc is $errdesc from open\n" 
            set longmsg [ format [ getRuleMsg ircr4u212longmsg ] "$errdesc" "$cpuname" ] 
            ddl print debug "from open of rcr4u212: longmsg is  $longmsg from open\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
			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
			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 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.board-entry.type-int $rowName ]
			set nodename [ getExternalRowValue $ruleId board.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") && ($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 != "--") }
		}
                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
		}
	}
}

# 200
# DIMM Status

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

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

# Rule power-supply-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 != "OK") && ($value != "Removed") }
		}
                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
		}
	}
}

# CPU Status

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 TEMPERATURE-RULE.
# 230

proc rcr4u230 {action ruleId {rowName ""} {rowIndex 0} {matchList ""} } {
    switch $action {
	condition {
	    ddl print debug " from condition of rcr4u205: \n"
	    set nodename [ getExternalRowValue $ruleId temperature-sensor.temperature-sensorTbl.temperature-sensor-entry.sunSmNodeName $rowName ]
	    set tempdegree  [ getMyValue $ruleId $rowName ]
	    set highwarn    [ getExternalRowValue $ruleId temperature-sensor.temperature-sensorTbl.temperature-sensor-entry.highwarn $rowName  ]
	    set lowwarn    [ getExternalRowValue $ruleId temperature-sensor.temperature-sensorTbl.temperature-sensor-entry.lowwarn $rowName ]
	    set highfail    [ getExternalRowValue $ruleId temperature-sensor.temperature-sensorTbl.temperature-sensor-entry.highfail $rowName ]
	    set lowfail    [ getExternalRowValue $ruleId temperature-sensor.temperature-sensorTbl.temperature-sensor-entry.lowfail $rowName ]
	    ddl print debug " from condition of rcr4u230:boardname is $nodename\n"
	    ddl print debug " from condition of rcr4u230:tempdegree is $tempdegree\n"
	    setRuleParm DYN $ruleId $rowName cur_temp $tempdegree
	    setRuleParm DYN $ruleId $rowName cur_node $nodename
	    setRuleParm DYN $ruleId $rowName cur_highf $highfail
	    setRuleParm DYN $ruleId $rowName cur_lowf $lowfail
	    setRuleParm DYN $ruleId $rowName cur_highw $highwarn
	    setRuleParm DYN $ruleId $rowName cur_loww $lowwarn
	    
	    expr { (($tempdegree != "--") && (($tempdegree >= $highwarn) || ($tempdegree <= $lowwarn))) }
	}
	init {
	    ddl print debug " from init of rcr4u230: \n"
	    return ""
	}
	open {
	    ddl print debug " from open of rcr4u230: \n"
	    set tempdegree [ getRuleParm DYN $ruleId $rowName cur_temp ]
	    ddl print debug " from open of rcr4u230:tempdegree is $tempdegree\n"
	    set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
	    ddl print debug " from open of rcr4u205:boardname is $nodename\n"
	    set highfail [ getRuleParm DYN $ruleId $rowName cur_highf ]
	    ddl print debug " from open of rcr4u230:highfail is $highfail\n"
	    set lowfail [ getRuleParm DYN $ruleId $rowName cur_lowf ]
	    ddl print debug " from open of rcr4u230:lowfail is $lowfail\n"
	    set highwarn [ getRuleParm DYN $ruleId $rowName cur_highw ]
	    ddl print debug " from open of rcr4u230:highwarn is $highwarn\n"
	    set lowwarn [ getRuleParm DYN $ruleId $rowName cur_loww ]
	    ddl print debug " from open of rcr4u230:lowwarn is $lowwarn\n"
	    
	    if { $tempdegree >= $highfail } {
		set estatus error
		
		set errmsg [ getRuleMsg icr4u230highfmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename" "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    } 
	    if { $tempdegree >= $highwarn } {
		set estatus warning
				
		set errmsg [ getRuleMsg icr4u230highwmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename"  "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    }
	    if { $tempdegree <= $lowfail } {
		set estatus error
				
		set errmsg [ getRuleMsg icr4u230lowfmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename"  "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    } 
	    if { $tempdegree <= $lowwarn } {
		set estatus warning
		
		set errmsg [ getRuleMsg icr4u230lowwmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename"  "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    }			    
	}
	continue {
	    ddl print debug " from continue of rcr4u230: \n"
	    set tempdegree [ getRuleParm DYN $ruleId $rowName cur_temp ]
	    ddl print debug " from continue of rcr4u230:tempdegree is $tempdegree\n"
	    set nodename [ getRuleParm DYN $ruleId $rowName cur_node ]
	    ddl print debug " from open of rcr4u205:boardname is $nodename\n"
	    set highfail [ getRuleParm DYN $ruleId $rowName cur_highf ]
	    ddl print debug " from open of rcr4u230:highfail is $highfail\n"
	    set lowfail [ getRuleParm DYN $ruleId $rowName cur_lowf ]
	    ddl print debug " from open of rcr4u230:lowfail is $lowfail\n"
	    set highwarn [ getRuleParm DYN $ruleId $rowName cur_highw ]
	    ddl print debug " from open of rcr4u230:highwarn is $highwarn\n"
	    set lowwarn [ getRuleParm DYN $ruleId $rowName cur_loww ]
	    ddl print debug " from open of rcr4u230:lowwarn is $lowwarn\n"
	    
	    if { $tempdegree >= $highfail } {
		set estatus error
		
		set errmsg [ getRuleMsg icr4u230highfmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename" "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    } 
	    if { $tempdegree >= $highwarn } {
		set estatus warning
		
		set errmsg [ getRuleMsg icr4u230highwmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename" "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    }
	    if { $tempdegree <= $lowfail } {
		set estatus error
		
		set errmsg [ getRuleMsg icr4u230lowfmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename" "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		setRuleText $ruleId $rowName $estatus $longmsg
		return $estatus
	    } 
	    if { $tempdegree <= $lowwarn } {
		set estatus warning
		
		set errmsg [ getRuleMsg icr4u230lowwmsg ]
		set longmsg [ format [ getRuleMsg ircr4u230longmsg ] "$nodename" "$errmsg" "$tempdegree" ]
		ddl print debug " from open of rcr4u230:longmsg is $longmsg\n"
		
		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
                        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
                }
        }
}
