Skip to content

Commit b79bd44

Browse files
committed
Add more logs
1 parent 12edb6d commit b79bd44

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/smtp_watchdog_daemon1.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
$EMAILTO='supervision@'.$DOMAIN;
185185
}
186186
if (empty($pathtospamdir)) {
187-
$pathtospamdir="/tmp/spam";
187+
$pathtospamdir="/home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/spam";
188188
}
189189

190190
$PID=getmypid();
@@ -197,10 +197,10 @@
197197
file_put_contents($logfile, date('Y-m-d H:i:s') . " Now event captured will be logged into ".$logphpsendmail."\n", FILE_APPEND);
198198

199199
// Load $instanceofuser
200-
$instanceofuser = getInstancesOfUser($pathtospamdir);
200+
$instanceofuser = getInstancesOfUser($pathtospamdir, $logfile);
201201

202202
// Load $blacklistips
203-
$blacklistips = getBlackListIps($pathtospamdir);
203+
$blacklistips = getBlackListIps($pathtospamdir, $logfile);
204204

205205
$datelastload = dol_now();
206206

@@ -249,7 +249,7 @@
249249

250250

251251
if ($datelastload < (dol_now() - 3600)) {
252-
file_put_contents($logfile, date('Y-m-d H:i:s') . " reload cached files\n", FILE_APPEND);
252+
file_put_contents($logfile, date('Y-m-d H:i:s') . " reload cached files (at least once per hour)\n", FILE_APPEND);
253253

254254
// Call this sometimes to refresh list of paid instances
255255
$instanceofuser = getInstancesOfUser($pathtospamdir);
@@ -475,7 +475,7 @@
475475
}
476476
}
477477

478-
file_put_contents($logphpsendmail, date('Y-m-d H:i:s') . " Nb of processes found with ".$commandresexec." = ".$resexec." (we accept ".$MAXALLOWED.")\n", FILE_APPEND);
478+
file_put_contents($logphpsendmail, date('Y-m-d H:i:s') . " Nb of processes found with ".$commandresexec." = ".$resexec." (we accept mailquota ".$MAXALLOWED.")\n", FILE_APPEND);
479479

480480
if ($resexec > $MAXALLOWED) {
481481
file_put_contents($logphpsendmail, date('Y-m-d H:i:s') . " $remoteip sellyoursaas rules ko quota reached. User has reached its quota of ".$MAXALLOWED."\n", FILE_APPEND);
@@ -541,10 +541,13 @@
541541
* getInstancesOfUser()
542542
*
543543
* @param string $pathtospamdir Spam directory
544+
* @param string $logfile File name for log
544545
* @return array Array of instances in mailquota (so paid instances). Key is osu... user. Value is an array.
545546
*/
546-
function getInstancesOfUser($pathtospamdir)
547+
function getInstancesOfUser($pathtospamdir, $logfile)
547548
{
549+
file_put_contents($logfile, date('Y-m-d H:i:s') . " Load file with mail quota ".$pathtospamdir."/mailquota\n", FILE_APPEND);
550+
548551
$instanceofuser = array();
549552
// Loop on each line of $pathtospamdir/mailquota
550553
$fp = @fopen($pathtospamdir."/mailquota", "r");
@@ -567,10 +570,13 @@ function getInstancesOfUser($pathtospamdir)
567570
* getBlackListIps()
568571
*
569572
* @param string $pathtospamdir Spam directory
573+
* @param string $logfile File name for log
570574
* @return array Array of blacklisted IPs. Key and value are the IP.
571575
*/
572-
function getBlackListIps($pathtospamdir)
576+
function getBlackListIps($pathtospamdir, $logfile)
573577
{
578+
file_put_contents($logfile, date('Y-m-d H:i:s') . " Load file with list of IP ".$pathtospamdir."/blaklistip\n", FILE_APPEND);
579+
574580
$blacklistips = array();
575581
// Loop on each line of $pathtospamdir/mailquota
576582
$fp = @fopen($pathtospamdir."/blacklistip", "r");

0 commit comments

Comments
 (0)