From 5faa6b578150539d538768178e6eac99ebf5787b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 9 Jan 2018 23:19:03 +0100 Subject: add a simple counter and systemd unit status notification --- udp514-journal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/udp514-journal.c b/udp514-journal.c index 6116f0c..0ed80d7 100644 --- a/udp514-journal.c +++ b/udp514-journal.c @@ -13,6 +13,7 @@ int main(int argc, char **argv) { struct sockaddr_in cliAddr, servAddr; char buffer[BUFFER_SIZE]; const int y = 1; + unsigned int count = 0; /* open socket */ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { @@ -48,6 +49,9 @@ int main(int argc, char **argv) { sd_journal_send("MESSAGE=%s: %s", inet_ntoa(cliAddr.sin_addr), buffer, "IP_ADDRESS=%s", inet_ntoa(cliAddr.sin_addr), NULL); + + /* count and update status */ + sd_notifyf(0, "READY=1\nSTATUS=Forwarded %d syslog messages.", ++count); } return EXIT_SUCCESS; -- cgit v1.2.3-54-g00ecf