Skip to content

Commit

Permalink
fix(dhcpv6): Report config issues are critical
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraichen committed Aug 14, 2023
1 parent 8241d0f commit d168c9c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cmd/check_dhcpv6/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
}

var plugin = nagios.NewPlugin()
plugin.ExitStatusCode = nagios.StateUNKNOWNExitCode
plugin.ExitStatusCode = nagios.StateCRITICALExitCode
defer plugin.ReturnCheckResults()

addr, _ := netip.AddrFromSlice(dhcpv6.AllDHCPRelayAgentsAndServers)
Expand Down Expand Up @@ -147,7 +147,6 @@ func main() {
if err != nil {
if e, ok := err.(net.Error); ok && e.Timeout() {
plugin.ServiceOutput = "No advertise message received"
plugin.ExitStatusCode = nagios.StateCRITICALExitCode
return
}

Expand All @@ -158,11 +157,11 @@ func main() {

adv, err = dhcpv6.FromBytes(buf[:n])
if err != nil {
log.Debugf("Skip invalid or NON-DHCP paket: %s", err)
log.Debugf("Skip invalid or NON-DHCP packet: %s", err)
continue
}

log.Debugf("Received paket: %s", adv.Summary())
log.Debugf("Received packet: %s", adv.Summary())

if recvMsg, ok := adv.(*dhcpv6.Message); ok {
// Check transaction ID if reply to send solicit message
Expand All @@ -179,7 +178,7 @@ func main() {

opt := adv.GetOneOption(dhcpv6.OptionStatusCode)
if opt == nil {
plugin.ServiceOutput = "ERR - No IANA status code in ADVERTISE response"
plugin.ServiceOutput = "ERR - No status code in response"
return
}

Expand Down

0 comments on commit d168c9c

Please sign in to comment.