in lib/ec2macossystemmonitor/relayd.go [80:99]
func PassToRelayd(messageBytes []byte) (n int, err error) {
// The socket file needs to be created to write, the server creates this file.
if !fileExists(SocketPath) {
return 0, fmt.Errorf("ec2macossystemmonitor: %s does not exist, cannot send message: %s", SocketPath, string(messageBytes))
}
// Finally write the serial message to the domain socket
sock, err := net.Dial("unix", SocketPath)
if err != nil {
return 0, fmt.Errorf("cec2macossystemmonitor: could not connect to %s: %s", SocketPath, err)
}
defer sock.Close()
_, err = sock.Write(messageBytes)
if err != nil {
return 0, fmt.Errorf("ec2macossystemmonitor: error while writing to socket: %s", err)
}
// Return the length of the bytes written to the socket
return len(messageBytes), nil
}