Hi

i recently wrote a PHP Skript which is running in
an endless-loop and try to connect every 10 seconds
to 127.0.0.1 and receive the service-greeting

if the connection fails or there is no response
"killall dbmail-imapd" or "killall dbmail-pop3d"

on systemd-systems with "Restart=always" the "killall"
triggers the restart by systemd while prevent that
a for whatever reason manually stopped daemon get
fired up by a restart and this should catch the cases
from thursday where the processes refused to respond

another script greps the syslog for "time over, scheduling restart"
twice an hour and triggers cronmails to take notice of this but
that does a lot of other things on the infrastructure and so no
way to publish ist

anybody feel free to reuse these two units and the worker
on systemd-installations (yes, i know PHP is not the first
language for services, but the one i use regulary *gg*)
________________________________________________________

[root@mail:~]$ systemctl status monitor-dbmail-imapd.service
monitor-dbmail-imapd.service - monitor dbmail-imapd
   Loaded: loaded (/etc/systemd/system/monitor-dbmail-imapd.service; enabled)
   Active: active (running) since Mo 2013-08-19 16:07:16 CEST; 5min ago
 Main PID: 5209 (check-dbmail-se)
   CGroup: name=systemd:/system/monitor-dbmail-imapd.service
           └─5209 /usr/bin/php /usr/local/bin/check-dbmail-service.php 143 
dbmail-imapd

[root@mail:~]$ systemctl status monitor-dbmail-pop3d.service
monitor-dbmail-pop3d.service - monitor dbmail-pop3d
   Loaded: loaded (/etc/systemd/system/monitor-dbmail-pop3d.service; enabled)
   Active: active (running) since Mo 2013-08-19 16:07:16 CEST; 5min ago
 Main PID: 5210 (check-dbmail-se)
   CGroup: name=systemd:/system/monitor-dbmail-pop3d.service
           └─5210 /usr/bin/php /usr/local/bin/check-dbmail-service.php 110 
dbmail-pop3d
[Unit]
Description=monitor dbmail-pop3d
After=dbmail-pop3d.service

[Service]
Type=simple
ExecStart=/usr/local/bin/check-dbmail-service.php 110 dbmail-pop3d
Restart=always
RestartSec=1
TimeoutSec=1
Nice=19
IOSchedulingClass=3
User=root
Group=root
PrivateTmp=true
NoNewPrivileges=yes
CapabilityBoundingSet=CAP_KILL
ReadOnlyDirectories=/etc
ReadOnlyDirectories=/usr
ReadOnlyDirectories=/proc
ReadOnlyDirectories=/sys
InaccessibleDirectories=/boot
InaccessibleDirectories=/home                                                   
           
InaccessibleDirectories=/var/lib/rpm
InaccessibleDirectories=/var/lib/yum                                            
                        
InaccessibleDirectories=/var/spool

[Install] 
WantedBy=multi-user.target
[Unit]
Description=monitor dbmail-imapd
After=dbmail-imapd.service

[Service]
Type=simple
ExecStart=/usr/local/bin/check-dbmail-service.php 143 dbmail-imapd
Restart=always
RestartSec=1
TimeoutSec=1
Nice=19
IOSchedulingClass=3
User=root
Group=root
PrivateTmp=true
NoNewPrivileges=yes
CapabilityBoundingSet=CAP_KILL
ReadOnlyDirectories=/etc
ReadOnlyDirectories=/usr
ReadOnlyDirectories=/proc
ReadOnlyDirectories=/sys
InaccessibleDirectories=/boot
InaccessibleDirectories=/home                                                   
           
InaccessibleDirectories=/var/lib/rpm
InaccessibleDirectories=/var/lib/yum                                            
                        
InaccessibleDirectories=/var/spool

[Install] 
WantedBy=multi-user.target

<<attachment: check-dbmail-service.php>>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to