Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6259](https://github.com/apache/trafficcontrol/issues/6259) - Traffic Portal No Longer Allows Spaces in Server Object "Router Port Name"
- [#6175](https://github.com/apache/trafficcontrol/issues/6175) - POST request to /api/4.0/phys_locations accepts mismatch values for regionName.
- [#6283](https://github.com/apache/trafficcontrol/issues/6283) - The Traffic Ops Postinstall script will work in CentOS 7, even if Python 3 is installed
- [#5373](https://github.com/apache/trafficcontrol/issues/5373) - Traffic Monitor logs not consistent

### Changed
- Updated `t3c` to request less unnecessary deliveryservice-server assignment and invalidation jobs data via new query params supported by Traffic Ops
Expand Down
36 changes: 8 additions & 28 deletions traffic_monitor/ds/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,6 @@ func addAvailableData(dsStats *dsdata.Stats, crStates tc.CRStates, serverCachegr
}
}

for dsName, stat := range dsStats.DeliveryService {
lastStat, lastStatExists := lastStats.DeliveryServices[dsName]
if !lastStatExists {
continue
}

getEvent := func(desc string) health.Event {
// TODO sync.Pool?
return health.Event{
Time: health.Time(time.Now()),
Description: desc,
Name: dsName.String(),
Hostname: dsName.String(),
Type: "Delivery Service",
Available: stat.CommonStats.IsAvailable.Value,
}
}
if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true {
events.Add(getEvent("no available caches"))
} else if stat.CommonStats.IsAvailable.Value == true && lastStat.Available == false {
events.Add(getEvent("available caches"))
}
}

// TODO move to its own func?
for dsName := range crStates.DeliveryService {
stat, ok := dsStats.DeliveryService[dsName]
Expand Down Expand Up @@ -325,14 +301,18 @@ func addDSPerSecStats(lastStats *dsdata.LastStats, dsStats *dsdata.Stats, dsName
Description: desc,
Name: dsName.String(),
Hostname: dsName.String(),
Type: "DELIVERYSERVICE",
Type: health.DeliveryServiceEventType,
Available: stat.CommonStats.IsAvailable.Value,
}
}
if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true && dsErr != nil {
events.Add(getEvent(dsErr.Error())) // TODO change events.Add to not allocate new memory, after the limit is reached.
if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true {
eventDesc := "Unavailable"
if dsErr != nil {
eventDesc = eventDesc + " err: " + dsErr.Error()
}
events.Add(getEvent(eventDesc)) // TODO change events.Add to not allocate new memory, after the limit is reached.
} else if stat.CommonStats.IsAvailable.Value == true && lastStat.Available == false {
events.Add(getEvent("REPORTED - available"))
events.Add(getEvent("Available caches"))
}

lastStat.Available = stat.CommonStats.IsAvailable.Value
Expand Down
4 changes: 4 additions & 0 deletions traffic_monitor/health/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
"github.com/apache/trafficcontrol/lib/go-log"
)

const (
DeliveryServiceEventType = "DELIVERYSERVICE"
)

type Time time.Time

func (t Time) MarshalJSON() ([]byte, error) {
Expand Down
9 changes: 8 additions & 1 deletion traffic_monitor/manager/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func comparePeerState(events health.ThreadsafeEvents, result peer.Result, peerSt
description = "Peer is unreachable"
}

events.Add(health.Event{Time: health.Time(result.Time), Description: description, Name: result.ID.String(), Hostname: result.ID.String(), Type: "PEER", Available: result.Available})
events.Add(
health.Event{
Time: health.Time(result.Time),
Description: description,
Name: result.ID.String(),
Hostname: result.ID.String(),
Type: "PEER",
Available: result.Available})
}
}
11 changes: 10 additions & 1 deletion traffic_monitor/manager/statecombiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@ func combineCacheState(
}

if overrideCondition != "" {
events.Add(health.Event{Time: health.Time(time.Now()), Description: fmt.Sprintf("Health protocol override condition %s", overrideCondition), Name: cacheName.String(), Hostname: cacheName.String(), Type: toData.ServerTypes[cacheName].String(), Available: available, IPv4Available: ipv4Available, IPv6Available: ipv6Available})
events.Add(
health.Event{
Time: health.Time(time.Now()),
Description: fmt.Sprintf("Health protocol override condition %s", overrideCondition),
Name: cacheName.String(),
Hostname: cacheName.String(),
Type: toData.ServerTypes[cacheName].String(),
Available: available,
IPv4Available: ipv4Available,
IPv6Available: ipv6Available})
}

combinedStates.AddCache(cacheName, tc.IsAvailable{IsAvailable: available, Ipv4Available: ipv4Available, Ipv6Available: ipv6Available})
Expand Down