diff --git a/alerts.php b/alerts.php index af7c835061..878c23e326 100755 --- a/alerts.php +++ b/alerts.php @@ -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 diff --git a/doc/Alerting.md b/doc/Alerting.md index 0a721db18a..649b1eb6da 100644 --- a/doc/Alerting.md +++ b/doc/Alerting.md @@ -43,7 +43,8 @@ __Conditions__ can be any of: __Values__ can be Entities or any single-quoted data. __Glues__ can be either `&&` for `AND` or `||` for `OR`. -__Note__: The difference between `Equals` and `Matches` (and it's negation) is that `Equals` does a strict comparison and `Matches` allows the usage of the placeholder `*`. The placeholder `*` is comparable with `.*` in RegExp. +__Note__: The difference between `Equals` and `Matches` (and it's negation) is that `Equals` does a strict comparison and `Matches` allows the usage of the placeholder `@`. The placeholder `@` is comparable with `.*` in RegExp. +Arithmetics are allowed as well. ## Examples diff --git a/librenms.cron b/librenms.cron index f2171210ff..49f74898da 100644 --- a/librenms.cron +++ b/librenms.cron @@ -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