mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #374 from f0o/alerting-dirty
Cronjob adjustment & Lockfile implementation
This commit is contained in:
18
alerts.php
18
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
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user