- Admins can now choose to be notified by email about debug, warning or error messages in the server process.
| | |
| | | nameservers=8.8.8.8,8.8.4.4
|
| | | firewall=bastille |
| | | loglevel=2 |
| | | admin_notify_events=1 |
| | | backup_dir=/var/backup |
| | | backup_mode=rootgz |
| | | |
| | |
| | | 'width' => '40', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'admin_notify_events' => array( |
| | | 'datatype' => 'INTEGER', |
| | | 'formtype' => 'SELECT', |
| | | 'default' => '1', |
| | | 'value' => array('3' => 'no_notifications_txt', '0' => 'Debug', '1' => 'Warnings', '2' => 'Errors'), |
| | | 'width' => '40', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'backup_dir' => array( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'TEXT', |
| | |
| | | $wb['overquota_notify_onok_txt'] = 'Meldung an den Kunden senden, wenn Belegung wieder ok'; |
| | | $wb['overquota_notify_freq_txt'] = 'Quota-Warnung alle X Tage versenden'; |
| | | $wb['overquota_notify_freq_note_txt'] = '0 = Meldung nur einmalig versenden, keine Wiederholung'; |
| | | $wb['admin_notify_events_txt'] = 'Sende E-Mail an Administrator ab folgendem Level'; |
| | | $wb['no_notifications_txt'] = 'Keine Benachrichtigungen'; |
| | | ?> |
| | |
| | | $wb["overquota_notify_onok_txt"] = 'Send quota ok message to client'; |
| | | $wb['overquota_notify_freq_txt'] = 'Send quota warning each X days'; |
| | | $wb['overquota_notify_freq_note_txt'] = '0 = send message just once, no repeated messages'; |
| | | $wb['admin_notify_events_txt'] = 'Send email to admin starting with the following level'; |
| | | $wb['no_notifications_txt'] = 'No Notifications'; |
| | | ?>
|
| | |
| | | {tmpl_var name='loglevel'} |
| | | </select> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="admin_notify_events">{tmpl_var name='admin_notify_events_txt'}</label> |
| | | <select name="admin_notify_events" id="admin_notify_events" class="selectInput"> |
| | | {tmpl_var name='admin_notify_events'} |
| | | </select> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="backup_dir">{tmpl_var name='backup_dir_txt'}</label> |
| | | <input name="backup_dir" id="backup_dir" value="{tmpl_var name='backup_dir'}" size="40" maxlength="255" type="text" class="textInput" /> |
| | |
| | | function log($msg, $priority = 0) { |
| | | |
| | | global $conf; |
| | | |
| | | switch ($priority) { |
| | | case 0: |
| | | $priority_txt = 'DEBUG'; |
| | | break; |
| | | case 1: |
| | | $priority_txt = 'WARNING'; |
| | | break; |
| | | case 2: |
| | | $priority_txt = 'ERROR'; |
| | | break; |
| | | } |
| | | $log_msg = @date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg; |
| | | |
| | | if($priority >= $conf['log_priority']) { |
| | | //if (is_writable($conf["log_file"])) { |
| | | if (!$fp = fopen ($conf['log_file'], 'a')) { |
| | | die('Unable to open logfile.'); |
| | | } |
| | | switch ($priority) { |
| | | case 0: |
| | | $priority_txt = 'DEBUG'; |
| | | break; |
| | | case 1: |
| | | $priority_txt = 'WARNING'; |
| | | break; |
| | | case 2: |
| | | $priority_txt = 'ERROR'; |
| | | break; |
| | | } |
| | | |
| | | if (!fwrite($fp, @date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg."\r\n")) { |
| | | if (!fwrite($fp, $log_msg."\r\n")) { |
| | | die('Unable to write to logfile.'); |
| | | } |
| | | echo @date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg."\n"; |
| | | |
| | | echo $log_msg."\n"; |
| | | fclose($fp); |
| | | |
| | | // Log to database |
| | |
| | | //} else { |
| | | // die("Unable to write to logfile."); |
| | | //} |
| | | |
| | | |
| | | } // if |
| | | |
| | | if($priority >= $conf['admin_notify_priority'] && $conf['admin_mail'] != '') { |
| | | // send notification to admin |
| | | $mailBody = $log_msg; |
| | | $mailSubject = substr($log_msg,0,50).'...'; |
| | | $mailHeaders = "MIME-Version: 1.0" . "\n"; |
| | | $mailHeaders .= "Content-type: text/plain; charset=utf-8" . "\n"; |
| | | $mailHeaders .= "Content-Transfer-Encoding: 8bit" . "\n"; |
| | | $mailHeaders .= "From: ". $conf['admin_mail'] . "\n"; |
| | | $mailHeaders .= "Reply-To: ". $conf['admin_mail'] . "\n"; |
| | | |
| | | mail($conf['admin_mail'], $mailSubject, $mailBody, $mailHeaders); |
| | | } |
| | | } // func |
| | | |
| | | |
| | | /* |
| | | 0 = DEBUG |
| | |
| | | } |
| | | } else { |
| | | //* We do not check the nginx config after changes (is faster) |
| | | if($nginx_chrooted) { |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | } else { |
| | | // request a httpd reload when all records have been processed |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | } |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | } |
| | | |
| | | //* The vhost is written and apache has been restarted, so we |
| | |
| | | |
| | | // Set the loglevel |
| | | $conf['log_priority'] = intval($conf['serverconfig']['server']['loglevel']); |
| | | |
| | | // Set level from which admin should be notified by email |
| | | if(!isset($conf['serverconfig']['server']['admin_notify_events']) || $conf['serverconfig']['server']['admin_notify_events'] == '') $conf['serverconfig']['server']['admin_notify_events'] = 3; |
| | | $conf['admin_notify_priority'] = intval($conf['serverconfig']['server']['admin_notify_events']); |
| | | |
| | | // we do not need this variable anymore |
| | | unset($server_db_record); |
| | | |
| | | // retrieve admin email address for notifications |
| | | $sys_ini = $app->dbmaster->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1"); |
| | | $conf['sys_ini'] = $app->ini_parser->parse_ini_string(stripslashes($sys_ini['config'])); |
| | | $conf['admin_mail'] = $conf['sys_ini']['mail']['admin_mail']; |
| | | unset($sys_ini); |
| | | |
| | | /* |
| | | * Save the rescue-config, maybe we need it (because the database is down) |
| | | */ |