Alerts cronjob to be every minute.

Added:
	Lockfile to Alerts cronjob
This commit is contained in:
f0o
2014-12-22 18:17:43 +00:00
parent 6ac4776623
commit d6d5282e84
2 changed files with 19 additions and 1 deletions

View File

@ -25,11 +25,29 @@
include("includes/defaults.inc.php");
include("config.php");
$lock = false;
if( file_exists($config['install_dir']."/.alerts.lock") ) {
$pids = explode("\n", trim(`ps -e | grep php | awk '{print $1}'`));
$lpid = trim(file_get_contents($config['install_dir']."/.alerts.lock"));
if( in_array($lpid,$pids) ) {
$lock = true;
}
}
if( $lock === true ) {
exit('Alreading running with PID '.$lpid."\r\n");
} else {
file_put_contents($config['install_dir']."/.alerts.lock", getmypid());
}
include("includes/definitions.inc.php");
include("includes/functions.php");
RunAlerts();
unlink($config['install_dir']."/.alerts.lock");
/**
* Run all alerts
* @return void

View File

@ -2,4 +2,4 @@
*/5 * * * * root /opt/librenms/discovery.php -h new >> /dev/null 2>&1
*/5 * * * * root /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1
15 0 * * * root sh /opt/librenms/daily.sh >> /dev/null 2>&1
*/2 * * * * root /opt/librenms/alerts.php >> /dev/null 2>&1
* * * * * root /opt/librenms/alerts.php >> /dev/null 2>&1