diff --git a/scripts/OpenSIPS/quotaCheck.php b/scripts/OpenSIPS/quotaCheck.php index 090001d..e4aac54 100755 --- a/scripts/OpenSIPS/quotaCheck.php +++ b/scripts/OpenSIPS/quotaCheck.php @@ -1,70 +1,72 @@ #!/usr/bin/env php withName('quotaCheck'); + $b = time(); $lockFile = sprintf("/var/lock/CDRTool_QuotaCheck.lock"); $abort_text = "Another check is in progress. Try again later.\n"; $f = fopen($lockFile, "w"); if (flock($f, LOCK_EX + LOCK_NB, $w)) { if ($w) { print $abort_text; - syslog(LOG_NOTICE, $abort_text); + critical($abort_text); exit(2); } } else { print $abort_text; - syslog(LOG_NOTICE, $abort_text); + critical($abort_text); exit(1); } foreach ($DATASOURCES as $k => $v) { if (strlen($v["UserQuotaClass"])) { unset($CDRS); $class_name = $v["class"]; $CDRS = new $class_name($k); $Quota_class = $v["UserQuotaClass"]; $log=sprintf("Checking user quotas for data source %s\n", $v['name']); - syslog(LOG_NOTICE, $log); + logger($log); //print $log; $Quota = new $Quota_class($CDRS); $Quota->checkQuota($v['UserQuotaNotify']); $d = time() - $b; if ($d > 5) { $log = sprintf("Runtime: %d s", $d); - syslog(LOG_NOTICE, $log); + logger($log); } } } function deleteQuotaCheckLockfile($lockFile) { if (!unlink($lockFile)) { - print "Error: cannot delete lock file $lockFile. Aborting.\n"; - syslog(LOG_NOTICE, "Error: cannot delete lock file $lockFile"); + errorAndPrint("Error: cannot delete lock file $lockFile"); } }