Merge pull request #374 from f0o/alerting-dirty

Cronjob adjustment & Lockfile implementation
This commit is contained in:
Neil Lathwood
2014-12-26 23:50:26 +00:00
3 changed files with 21 additions and 2 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

@ -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.
## <a name="rules-examples">Examples</a>

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