aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-01-09 23:19:03 +0100
committerGravatar Christian Hesse <mail@eworm.de>2018-01-09 23:19:03 +0100
commit5faa6b578150539d538768178e6eac99ebf5787b (patch)
tree905d487c4f05ed0997973391447e48457506e81a
parentda5f7b86ef18e767108a9a12798013b0e8289b35 (diff)
downloadudp514-journal-5faa6b578150539d538768178e6eac99ebf5787b.tar.gz
udp514-journal-5faa6b578150539d538768178e6eac99ebf5787b.tar.zst
add a simple counter and systemd unit status notification
-rw-r--r--udp514-journal.c4
1 files changed, 4 insertions, 0 deletions
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;