Package: rabbitmq-alert
About RabbitMQ AlertSend notifications when predefined conditions are met.Which conditions?Ready messagesUnacknowledged messagesTotal queued messagesNumber of connected consumersNumber of open connectionsNumber of nodes runningMemory used by each node in MBsMy inspiration to create this notification sender is to monitor a set
of Celery workers. Sometimes they stop working and monitoringthe queue size seems to be an easy way to know when these situations
happen. Additionally, automatically monitoring the queue sizesis a great way to scale up/down the number of workers.What type of notifications?Currently the following are supported:E-mailsSlack messagesTelegram messagesInstallationUse thePIPcommand, which should already exist in your Linux installation:sudo pip install rabbitmq-alertUsageExecute with the global configuration fileCopy the example configuration file to the default path of the global configuration file:sudo cp /etc/rabbitmq-alert/config.ini.example /etc/rabbitmq-alert/config.iniEdit it with you preferred settings. Then you are ready to executerabbitmq-alertusing the global configuration file. Just execute:sudo rabbitmq-alertExecute with optionsYou can executerabbitmq-alertalong using the provided options,
but first take a look at--helpto see whats availableand the purpose of each option.Example:sudo rabbitmq-alert \
    --host=my-server --port=55672 --username=guest --password=guest \
    --vhost=%2F --queue=my_queue1,my_queue2 --ready-queue-size=3 --check-rate=300 \
    --email-to=admin@example.com --email-from=admin@example.com \
    --email-subject="RabbitMQ alert at %s - %s" --email-server=localhostExecute with a custom configuration fileAlternatively, you can use a custom configuration file.
For the required format, take a lookat the/etc/rabbitmq-alert/config.ini.examplefile.Then executerabbitmq-alertwith the configuration file option:sudo rabbitmq-alert -c my_config.iniExecute as a daemonAsystemdscript is created upon installation withPIP.Use the following commands to reload thesystemdconfigurationand startrabbitmq-alertas a daemon.sudo systemctl daemon-reload
sudo systemctl start rabbitmq-alertTo haverabbitmq-alertalways started on boot:sudo systemctl enable rabbitmq-alertIn case your system still usesinit.d, aninit.dscript has been created
in/etc/init.duponPIPinstallation. To startrabbitmq-alertas a daemon:sudo /etc/init.d/rabbitmq-alert startTo haverabbitmq-alertalways started on boot:sudo update-rc.d rabbitmq-alert defaultsDifferent options per queueExcept conditions for all queues, you can also define queue specific conditionsin the configuration file, in case you want to have fine-tuned options for each queue.Just create a[Conditions]section for each queue. Example:[Conditions:my-queue]
...

[Conditions:my-other-queue]
...Note that queue names also have to be defined in the[Server]section of the configuration file:[Server]
...
queues=my-queue,my-other-queue
...LoggingYou can find the logs ofrabbitmq-alertto/var/log/rabbitmq-alert/.Log files are rotated in a daily basis.Execute in a containerThere is a docker image for the project. First, you have to create a configuration fileforrabbitmq-alert, which will then be copied into the container. Then you can runrabbitmq-alertinside a container.docker run -d --name rabbitmq-alert -v config.ini:/etc/rabbitmq-alert/config.ini \
mylkoh/rabbitmq-alert:latestFor the configuration file, advise theconfig.ini.examplethat exists in the project’s repository.ContributeThe projectrabbitmq-alertis written inpython2.Of course, you can contribute to the project. Take a look at the
GitHub “Issues” page and pick an issue to implement / fix.Fork the project, develop and then create a pull request, in order for
your code to be added to the project.Prepare your environmentTo start, you have to install the dev dependencies which are some
required python packages:make deps-devRun the tests!After writing your awesomeness, run the test suites to ensure that
everything is still fine:make testFirstly, ensure that you have removed the rabbitmqalert package from your system.
Otherwise you may find yourself running the tests on the installed package
instead of the source code.Do add tests yourself for the code you contribute to ensure the quality
of the project.Happy coding :-)Build and publish a new container versionTo build a new image version of the project:docker build --no-cache -t mylkoh/rabbitmq-alert:1.2.2 -t mylkoh/rabbitmq-alert:latest .Publish the image:docker push mylkoh/rabbitmq-alertTesting the containerCreate a network that all containers will belong to:docker network create rabbitmq-alertRunrabbitmqinto a container:docker run -d --name some-rabbit --net rabbitmq-alert -p 8080:15672 rabbitmq:3-managementYou can then go tohttp://localhost:8080in a browser to use the management plugin.The username and password are bothguest. Create a fake SMTP server:docker run -d --name fake-smtp --net rabbitmq-alert -p 25:25 munkyboy/fakesmtpNow, runrabbitmq-alertusing the same network:docker run -d --name rabbitmq-alert --net rabbitmq-alert \
-v config.ini:/etc/rabbitmq-alert/config.ini mylkoh/rabbitmq-alert:latest