diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 4cb84760..e0e60f72 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -865,6 +865,7 @@ func (p *ptpProcess) cmdRun(stdoutToSocket bool) { } else { processStatus(nil, p.name, p.messageTag, PtpProcessDown) } + p.updateGMStatusOnProcessDown(p.name) time.Sleep(connectionRetryInterval) // Delay to prevent flooding restarts if startup fails // Don't restart after termination @@ -1147,3 +1148,14 @@ func (p *ptpProcess) replaceClockID(input string) (output string) { output = clockIDRegEx.ReplaceAllString(input, iface) return output } + +// updateGMStatusOnProcessDown send events when ts2phc process is down by +// send event to EventHandler +func (p *ptpProcess) updateGMStatusOnProcessDown(process string) { + // need to update GM status for following process kill for ts2phc + if process == ts2phcProcessName { + // ts2phc process dead should update GM-STATUS + iface := p.ifaces.GetGMInterface().Name + p.ProcessTs2PhcEvents(faultyOffset, ts2phcProcessName, iface, map[event.ValueType]interface{}{event.PROCESS_STATUS: int64(0)}) + } +} diff --git a/pkg/daemon/metrics.go b/pkg/daemon/metrics.go index a905333c..9703101a 100644 --- a/pkg/daemon/metrics.go +++ b/pkg/daemon/metrics.go @@ -371,7 +371,7 @@ func extractRegularMetrics(configName, processName, output string, ifaces config } output = strings.Replace(output, "path", "", 1) - replacer := strings.NewReplacer("[", " ", "]", " ", ":", " ", " phc ", " ", " sys ", "") + replacer := strings.NewReplacer("[", " ", "]", " ", ":", " ", " phc ", " ", " sys ", " ") output = replacer.Replace(output) index := strings.Index(output, configName) diff --git a/pkg/event/event.go b/pkg/event/event.go index 197b2d6f..a75fcb4e 100644 --- a/pkg/event/event.go +++ b/pkg/event/event.go @@ -32,6 +32,7 @@ const ( PHASE_STATUS ValueType = "phase_status" FREQUENCY_STATUS ValueType = "frequency_status" NMEA_STATUS ValueType = "nmea_status" + PROCESS_STATUS ValueType = "process_status" PPS_STATUS ValueType = "pps_status" GM_INTERFACE_UNKNOWN string = "unknown" )