Initialize
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
commit
72ca285f02
23
Makefile
Normal file
23
Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
# Makefile for rootail
|
||||
#
|
||||
# Copyright 2024, Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
|
||||
#
|
||||
# Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
||||
# You may not use this work except in compliance with the Licence.
|
||||
# An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
||||
# You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
||||
|
||||
PREFIX=/usr/local
|
||||
BINDIR=$(PREFIX)/bin
|
||||
MANDIR=$(PREFIX)/man
|
||||
SYSCONFDIR=$(PREFIX)/etc
|
||||
|
||||
usage:
|
||||
@echo 'Available targets: "install", "uninstall"'
|
||||
|
||||
install:
|
||||
install -d '$(DESTDIR)$(BINDIR)'
|
||||
install rootail.pl '$(DESTDIR)$(BINDIR)/rootail'
|
||||
|
||||
uninstall:
|
||||
rm '$(BINDIR)/rootail'
|
1
README.txt
Normal file
1
README.txt
Normal file
@ -0,0 +1 @@
|
||||
Simple tool which listens to rabbit.opensuse.org (aka "roo") and prints all messages in a human friendly format.
|
51
rootail.pl
Executable file
51
rootail.pl
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/perl -W
|
||||
# Simple tool which listens to rabbit.opensuse.org and prints all messages in a human friendly format.
|
||||
# Copyright 2024, Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
|
||||
#
|
||||
# Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
||||
# You may not use this work except in compliance with the Licence.
|
||||
# An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
||||
# You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
||||
|
||||
use 5.26.0; # Leap 15.6
|
||||
|
||||
use Net::AMQP::RabbitMQ;
|
||||
use JSON::PP;
|
||||
use Try::Tiny;
|
||||
|
||||
my $mq = Net::AMQP::RabbitMQ->new();
|
||||
|
||||
$mq->connect(
|
||||
'rabbit.opensuse.org', {
|
||||
user => 'opensuse',
|
||||
password => 'opensuse',
|
||||
ssl => 1,
|
||||
ssl_cacert => '/etc/ssl/ca-bundle.pem',
|
||||
}
|
||||
);
|
||||
|
||||
$mq->channel_open(1);
|
||||
my $exchange = $mq->exchange_declare(1, 'pubsub', {
|
||||
durable => 1,
|
||||
exclusive => 1,
|
||||
passive => 1,
|
||||
}
|
||||
);
|
||||
|
||||
my $queue = $mq->queue_declare(1, '');
|
||||
$mq->queue_bind(1, $queue, 'pubsub', '#');
|
||||
$mq->consume(1, $queue);
|
||||
|
||||
|
||||
while ( my $message = $mq->recv() )
|
||||
{
|
||||
print "\n=== MESSAGE ===\n";
|
||||
try {
|
||||
my $json = 'JSON::PP'->new->pretty;
|
||||
print($json->encode($json->decode($message->{'body'})));
|
||||
} catch {
|
||||
print "$message->{'body'}\n";
|
||||
};
|
||||
}
|
||||
|
||||
$mq->disconnect();
|
Loading…
Reference in New Issue
Block a user