Writing Python unit tests for HTTP Clients

I have a nagios / icinga HTTP monitor based on PyCurl: check_pycurl3. Writing tests for this is difficult because: So with a little StackExchange googling, you can start Flask in a thread (remember to set daemon=True) like below: You also need to give it some time to start up before tests commence, I’ve used the …

Continue reading ‘Writing Python unit tests for HTTP Clients’ »

Monitor mail queue with filter

check_mailq_filter – an Icinga / Nagios postfix mail queue monitor with a filter (include or exclude mails matching a pattern). So to exclude facebook mails from your monitor you may run: check_mailq_filter.py -x ‘.*facebookmail.*’ While you’re here, have a look at pfqueue – a console tool for interactively viewing your postfix queue that’s a step …

Continue reading ‘Monitor mail queue with filter’ »

nrpe systemd socket activation

If you’re using nrpe socket activation and don’t have a template file, try this in /etc/systemd/system/nrpe@.service : [Unit] Description=nrpe socket service Requires=nrpe.socket [Service] User=nrpe ExecStart=-/usr/bin/nrpe -c /etc/nrpe/nrpe.cfg –inetd StandardInput=socket StandardOutput=inherit StandardError=journal [Install] WantedBy=multi-user.target You’ll also need /etc/systemd/system/nrpe.socket : [Unit] Description=Nagios Remote Plugin Executor Documentation=http://www.nagios.org/documentation Before=nrpe.service Conflicts=nrpe.service [Socket] ListenStream=5666 Accept=yes [Install] WantedBy=sockets.target Then systemctl start nrpe.socket