This commit is contained in:
James 2024-04-27 11:32:58 +01:00
parent 268afe9fbd
commit b65606c455

View File

@ -21,6 +21,7 @@ def send_to_graphite(data, host='10.6.0.1', port=2003):
with socket.create_connection((host, port), timeout=1) as sock:
while data:
message = data.popleft()
print(f"Sending data to Graphite: {message}") # Debug message for sending data
sock.sendall(message.encode('utf-8'))
except (socket.error, socket.timeout) as e:
print(f"Failed to send data, will drop if buffer is full. Error: {e}", file=sys.stderr)
@ -45,9 +46,11 @@ def main():
for data in graphite_data:
if len(data_buffer) < data_buffer.maxlen:
data_buffer.append(data + '\n')
print(f"Data queued for Graphite: {data}") # Debug message for queuing data
# Try to send data if the buffer is not empty
if data_buffer:
print("Attempting to send data...") # Debug message before sending data
send_to_graphite(data_buffer)
except KeyboardInterrupt: