Connect. Communicate. Collaborate. Securely.

Home » Kerio User Forums » Kerio Connect » crash server [solution]
  •  
jmripert

Messages: 78
Karma: 0
Send a private message to this user
Hello,

I've resolved this problem with the support :

My service mailserver crash sometimes and none resquest receive a response, but I've the response with a ping request...

I've install 2 script :
- one for monitoring the service (cpu & mem)
- second for restart the service every at 7, 13 and 20 hours.

If this can help anyone.
Bye.



Script&crontab :


kerio_monitor.pl


====== 8< =====
#!/usr/bin/perl

date

my $max_mem = 50; # in percent
my $max_cpu = 50; # in percent



my $platform = `uname`;

my $ps;
foreach (split(/\n/, `ps axu`)) {
if (/mailserver/) {
$ps = $_;
last;
}
}

if ($ps) {
my ($user, $pid, $cpu, $mem, $vsz, $rss, $tt, $stat, $started, $time, $comma
nd) = split(/\s+/, $ps);
if ($mem > $max_mem or $cpu > $max_cpu) {
# restart mailserver
print "MailServer using too high memory or CPU - MEM: $mem, CPU: $cpu\n"
;
print "Restarting!\n";
control("stop");
sleep 10;
control("start");
}
}
else {
# mailserver stopped, restart
print "MailServer stopped\n";
print "Restarting!\n";
control("start");
}


sub control {
#print "control\n";
my $action = shift;
if (grep(/Darwin/, $platform)) {
#print "mac\n";
system("/sbin/SystemStarter", "$action", "KerioMailServer");
}
else {
system("/etc/init.d/keriomailserver", "$action");
}
}
===== 8< =====


kerio_restart.sh


===== 8< =====
#/bin/sh

clear

date
echo ARRET de kerio
/etc/rc5.d/S79keriomailserver stop

sleep 5

date
echo DEMARRAGE de kerio
/etc/rc5.d/S79keriomailserver start
===== 8< ======


in crontab


===== 8< =====
* * * * * /root/kerio_monitor.pl >> /root/kerio_monitor.txt
1 7,13,20 * * * /root/kerio_restart.sh > /root/kerio_restart.txt
===== 8< ======
  •  
jonbrain

Messages: 305
Karma: 0
Send a private message to this user
Does this automatically restart the service if it has crashed?

Could this work on OS X Server?
  •  
jmripert

Messages: 78
Karma: 0
Send a private message to this user
I use this script under linux, under Xserver I don't know.
Have you bash shell and perl langage ... under Xserver ?

My script bash restart the service at 7, 13 and 21 hours.

The script of support restart the service if the cpu or memory exceed 50%. I can't explain the script because I don't understand...
  •  
jonbrain

Messages: 305
Karma: 0
Send a private message to this user
Thanks, I think this should work on OS X as well. Will give it a go.
Previous Topic: watchkms
Next Topic: Offline pst files
Goto Forum:
  


Disclaimer:
Kerio discussion forums are intended for open communication between forum members and may contain information and material posted by members which may be useful in learning about Kerio products. The discussion forums are not intended to provide technical support for any specific product. Any information implied or expressed in the discussion forums is that of the posting member. Kerio is in no way responsible for the information posted in the forums, or its accuracy. Kerio employees may participate in the discussions, but their postings do not represent an offical position of the company on any issues raised or discussed. Kerio reserves the right to monitor and maintain the forums to promote free and accurate exchange of information.

Current Time: Mon Nov 20 05:12:42 CET 2017

Total time taken to generate the page: 0.00425 seconds
.:: Contact :: Home ::.
Powered by: FUDforum 3.0.4.