function MailGraphStatus() { $tpl = new templates(); $ini = new Bs_IniHandler(); $sock = new sockets(); $ini->loadFile("ressources/logs/global.status.ini"); $status = DAEMON_STATUS_ROUND("MAILGRAPH", $ini, null); return $tpl->_ENGINE_parse_body($status); }
function update(){ $page=CurrentPageName(); $tpl=new templates(); $t=time(); $sock=new sockets(); $zpush_version=base64_decode($sock->getFrameWork("zarafa.php?zpush-version=yes")); $ini=new Bs_IniHandler(); $ini->loadFile("ressources/index.ini"); $couldversion=$ini->_params["NEXT"]["z-push"]; $html=" <div style='font-size:22px;text-align:center;margin:10px' id='title$t'></div> <div style='margin:10px;min-height:75px' id='Status$t'></div> <div id='start-$t'></div> <center style='margin:50px'> <hr>". button("{update} v.$couldversion","Restore$t()",32)."</center> <script> var x_Restore$t= function (obj) { var tempvalue=obj.responseText; if(tempvalue.length>3){alert(tempvalue);} document.getElementById('start-$t').innerHTML=''; LoadAjax('start-$t','$page?logs-starter=yes&t=$t'); } function Restore$t(){ var XHR = new XHRConnection(); XHR.appendData('install-zpush','yes'); XHR.sendAndLoad('$page', 'POST',x_Restore$t); } var x_GetLogs$t= function (obj) { var tempvalue=obj.responseText; if(tempvalue.length>3){ document.getElementById('textToParseCats-$t').innerHTML=tempvalue; } } function GetLogs$t(){ var XHR = new XHRConnection(); XHR.appendData('restore-logs','yes'); XHR.appendData('t','$t'); XHR.setLockOff(); XHR.sendAndLoad('$page', 'POST',x_GetLogs$t); } $('#Status$t').progressbar({ value: 1 }); </script> "; echo $tpl->_ENGINE_parse_body($html); }
function start() { $sock = new sockets(); $page = CurrentPageName(); $tpl = new templates(); $ini = new Bs_IniHandler(); $t = time(); if (!isset($_GET["t"])) { $_GET["t"] = $t; } if (!is_file("/usr/share/artica-postfix/ressources/logs/global.status.ini")) { if (!isset($_GET["wait"])) { $sock->getFrameWork("cmd.php?Global-Applications-Status=yes"); } echo $tpl->_ENGINE_parse_body("<center style='margin-20px;font-size:20px'>{please_wait_waiting_services_status}</center>\n\t\t\t\t<script>\n\t\t\t\t\tfunction Wait{$t}(){\n\t\t\t\t\t\tif(!document.getElementById('{$t}')){return;}\n\t\t\t\t\t\tLoadAjaxRound('{$_GET["t"]}','{$page}?start=yes&={$t}&wait=yes');\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\tsetTimeout('Wait{$t}()',1200);\n\t\t\t\t</script>"); die; } $ini->loadFile("/usr/share/artica-postfix/ressources/logs/global.status.ini"); $tr[] = "<div style='margin-top:20px'>"; $tr[] = "<table style='width:100%'>"; $tr[] = "<tr style='height:70px'>\n\t<th style='font-size:22px;' colspan=4>{services}</th>\n\t<th style='font-size:22px;' colspan=2>{processes}/{memory}</th>\n\t<th style='font-size:22px;'>{uptime}</th>\n\t<th style='font-size:22px;' colspan=2>{action}</th>\n\t</tr>"; while (list($key, $array) = each($ini->_params)) { $icon = "ok48.png"; $color = "black"; $text = "{running}"; $service_name = $array["service_name"]; $service_disabled = intval($array["service_disabled"]); if ($service_disabled == 0) { continue; } $running = intval($array["running"]); $master_version = $array["master_version"]; $processes_number = $array["processes_number"]; $uptime = "{since}: {$array["uptime"]}"; $master_memory = FormatBytes($array["master_memory"]); $service_cmd = urlencode($array["service_cmd"]); $start = imgtootltip("48-run.png", "{start}", "Loadjs('system.services.cmd.php?APPNAME={$service_name}&action=start&cmd={$service_cmd}&appcode={$key}')"); $action = imgtootltip("stop-48.png", "{stop}", "Loadjs('system.services.cmd.php?APPNAME={$service_name}&action=stop&cmd={$service_cmd}&appcode={$key}')"); $restart = imgtootltip("restart-48.png", "{restart}", "Loadjs('system.services.cmd.php?APPNAME={$service_name}&action=restart&cmd={$service_cmd}&appcode={$key}')"); if ($running == 0) { $icon = "danger48.png"; $color = "#d32d2d"; $text = "{stopped}"; $processes_number = 0; $action = $start; $uptime = "-"; } $tr[] = "<tr style='height:70px'>\n\t\t\t\t<td style='font-size:22px;color:{$color}'><img src='img/{$icon}'></td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{{$service_name}}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$master_version}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$text}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$processes_number} {processes}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color};'>{$master_memory}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$uptime}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$action}</td>\n\t\t\t\t<td style='font-size:22px;color:{$color}'>{$restart}</td>\n\t\t\t</tr>"; } $tr[] = "</table>"; $tr[] = "</div>"; echo $tpl->_ENGINE_parse_body(@implode("\n", $tr)); }
function service_status() { $page = CurrentPageName(); $sock = new sockets(); $tpl = new templates(); $sock->getFrameWork("sealion.php?service-status=yes"); $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/APP_SEALION_AGENT.status"); $status = DAEMON_STATUS_ROUND("APP_SEALION_AGENT", $ini); $html = "{$status}<div style='text-align:right;height:40px;'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('sealion-agent-status','{$page}?sealion-agent-status=yes');", "right") . "</div>"; echo $tpl->_ENGINE_parse_body($html); }
function STATUSOF() { $key = $_POST["STATUSOF"]; $sock = new sockets(); $datas = base64_decode($sock->getFrameWork("system.php?all-services=yes")); $bsini = new Bs_IniHandler(); $bsini->loadFile("/usr/share/artica-postfix/ressources/logs/global.status.ini"); $img = "42-red.png"; if ($bsini->_params[$key]["running"] == 1) { $img = "42-green.png"; } echo $img; }
function status() { $page = CurrentPageName(); $sock = new sockets(); $tpl = new templates(); $sock->getFrameWork("ss5.php?service-status=yes"); $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/APP_SS5.status"); $status = DAEMON_STATUS_ROUND("APP_SS5", $ini); $redsocks = DAEMON_STATUS_ROUND("APP_REDSOCKS", $ini); $html = "{$status}{$redsocks}<div style='text-align:right;height:40px;'>" . imgtootltip("refresh-32.png", "{refresh}", "RefreshTab('influxdb_main_table');", "right") . "</div>"; echo $tpl->_ENGINE_parse_body($html); }
function build() { $users = new usersMenus(); $sock = new sockets(); $unix = new unix(); $SystemLoadNotif = $sock->GET_INFO("SystemLoadNotif"); if (!is_numeric($SystemLoadNotif)) { $SystemLoadNotif = 0; } $EnableSyslogDB = $sock->GET_INFO("EnableSyslogDB"); if (!is_numeric($EnableSyslogDB)) { $EnableSyslogDB = 0; } $MySQLSyslogType = $sock->GET_INFO("MySQLSyslogType"); if (!is_numeric($MySQLSyslogType)) { $MySQLSyslogType = 1; } $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); $EnableIntelCeleron = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableIntelCeleron")); $python = $unix->find_program("python"); $nice = $unix->EXEC_NICE(); $ps = $unix->find_program("ps"); $sort = $unix->find_program("sort"); $head = $unix->find_program("head"); $echo = $unix->find_program("echo"); $date = $unix->find_program("date"); $mkdir = $unix->find_program("mkdir"); $php5 = $unix->LOCATE_PHP5_BIN(); $ZarafaDedicateMySQLServer = $sock->GET_INFO("ZarafaDedicateMySQLServer"); if (!is_numeric($ZarafaDedicateMySQLServer)) { $ZarafaDedicateMySQLServer = 0; } build_progress_restart("{reconfiguring}", 22); $ini = new Bs_IniHandler(); $ini->loadFile('/etc/artica-postfix/smtpnotif.conf'); if (!is_numeric($ini->_params["SMTP"]["EnableNotifs"])) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } if (!is_numeric($ini->_params["SMTP"]["tls_enabled"])) { $ini->_params["SMTP"]["tls_enabled"] = 0; } $smtp_server = trim($ini->_params["SMTP"]['smtp_server_name']); $smtp_server_port = $ini->_params["SMTP"]['smtp_server_port']; $smtp_dest = $ini->_params["SMTP"]['smtp_dest']; $smtp_sender = $ini->_params["SMTP"]['smtp_sender']; $smtp_auth_user = $ini->_params["SMTP"]['smtp_auth_user']; $smtp_auth_passwd = $ini->_params["SMTP"]['smtp_auth_passwd']; $tls_enabled = $ini->_params["SMTP"]["tls_enabled"]; $recipientsZ = explode("\n", "/etc/artica-postfix/settings/Daemons/SmtpNotificationConfigCC"); $recipients = array(); while (list($index, $to) = each($recipientsZ)) { if (trim($to) == null) { continue; } $recipients[] = $to; } if ($smtp_server == null) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } if ($smtp_dest == null) { if (count($recipients) == 0) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } } if (!is_numeric($smtp_server_port)) { $smtp_server_port = 25; } $EnableNotifs = $ini->_params["SMTP"]["EnableNotifs"]; $monit_not_on = 'instance,action'; $f[] = 'set daemon 60 with start delay 5'; $f[] = 'set idfile /var/run/monit/monit.id'; $cpunum = $unix->CPU_NUMBER(); $normal = $cpunum * 2 + 1; $normal2 = $cpunum * 2; $busy = $cpunum * 4; build_progress_restart("{reconfiguring}", 23); $EnableMONITSmtpNotif = $sock->GET_INFO("EnableMONITSmtpNotif"); if (!is_numeric($EnableMONITSmtpNotif)) { $EnableMONITSmtpNotif = 1; } $MonitCPUUsage = intval($sock->GET_INFO("MonitCPUUsage")); $MonitCPUUsageCycles = intval($sock->GET_INFO("MonitCPUUsageCycles")); $MonitMemUsage = intval($sock->GET_INFO("MonitMemUsage")); $MonitMemUsageCycles = intval($sock->GET_INFO("MonitMemUsageCycles")); $MonitReportLoadVG1mn = intval($sock->GET_INFO("MonitReportLoadVG1mn")); $MonitReportLoadVG1mnCycles = intval($sock->GET_INFO("MonitReportLoadVG1mnCycles")); if ($MonitReportLoadVG1mnCycles == 0) { $MonitReportLoadVG1mnCycles = 5; } $MonitReportLoadVG5mn = intval($sock->GET_INFO("MonitReportLoadVG5mn")); $MonitReportLoadVG5mnCycles = intval($sock->GET_INFO("MonitReportLoadVG5mnCycles")); if ($MonitReportLoadVG5mnCycles == 0) { $MonitReportLoadVG5mnCycles = 15; } $MonitReportLoadVG15mn = intval($sock->GET_INFO("MonitReportLoadVG15mn")); $MonitReportLoadVG15mnCycles = intval($sock->GET_INFO("MonitReportLoadVG15mnCycles")); if ($MonitReportLoadVG15mnCycles == 0) { $MonitReportLoadVG15mnCycles = 60; } $MonitMemPurgeCache = intval($sock->GET_INFO("MonitMemPurgeCache")); $MonitMemPurgeCacheCycles = intval($sock->GET_INFO("MonitMemPurgeCacheCycles")); if ($MonitMemPurgeCache == 0) { $MonitMemPurgeCache = 70; } if ($MonitMemPurgeCacheCycles == 0) { $MonitMemPurgeCacheCycles = 5; } if ($MonitMemUsageCycles == 0) { $MonitMemUsageCycles = 5; } if ($MonitCPUUsageCycles == 0) { $MonitCPUUsageCycles = 15; } if ($MonitCPUUsage > 0) { if ($MonitCPUUsage < 50) { $MonitCPUUsage = 90; } } if ($MonitMemUsage > 0) { if ($MonitMemUsage < 50) { $MonitMemUsage = 90; } } build_progress_restart("{reconfiguring}", 24); $rmbin = $unix->find_program("rm"); $echo = $unix->find_program("echo"); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } $f[] = 'set logfile syslog facility log_daemon'; $f[] = 'set statefile /var/run/monit/monit.state'; $f[] = ''; if ($EnableNotifs == 1) { if ($EnableMONITSmtpNotif == 1) { $f[] = "set mailserver {$smtp_server} PORT {$smtp_server_port}"; if (strlen($smtp_auth_user) > 0) { $f[] = "\tUSERNAME \"{$smtp_auth_user}\" PASSWORD \"{$smtp_auth_passwd}\""; } if ($tls_enabled == 1) { $f[] = "\tusing TLSV1"; } $f[] = "\tset eventqueue"; $f[] = "\tbasedir /var/monit"; $f[] = "\tslots 100"; $f[] = "\tset mail-format {"; $f[] = "\t\tfrom: {$smtp_sender}"; $f[] = "\t\tsubject: Artica service monitor: \$SERVICE \$EVENT"; $f[] = "\t\tmessage: Artica service monitor \$ACTION \$SERVICE at \$DATE on \$HOST: \$DESCRIPTION"; $f[] = "\t}"; $f[] = "set alert {$smtp_dest} but not on {{$monit_not_on}}"; if ($recipients > 0) { while (list($index, $to) = each($recipientsZ)) { $f[] = "set alert {$to} but not on {{$monit_not_on}}"; } } } } build_progress_restart("{reconfiguring}", 25); $allips = $unix->NETWORK_ALL_INTERFACES(true); $f[] = "set httpd port 2874 and use address 127.0.0.1"; $f[] = "\tallow 127.0.0.1"; while (list($tcpi, $to) = each($allips)) { $f[] = "\tallow {$tcpi}"; } $top = $unix->find_program("top"); $hostname = $unix->hostname_g(); $TSCR = array(); if ($MonitReportLoadVG1mn > 0) { $TSCR[] = "\tif loadavg (1min) > {$MonitReportLoadVG1mn} for {$MonitReportLoadVG1mnCycles} cycles then exec \"/bin/artica-system-alert.sh LOAD_1 {$MonitReportLoadVG1mn}\""; } if ($MonitReportLoadVG5mn > 0) { $TSCR[] = "\tif loadavg (5min) > {$MonitReportLoadVG5mn} for {$MonitReportLoadVG5mnCycles} cycles then exec \"/bin/artica-system-alert.sh LOAD_5 {$MonitReportLoadVG5mn}\""; } if ($MonitReportLoadVG15mn > 0) { $TSCR[] = "\tif loadavg (15min) > {$MonitReportLoadVG15mn} for {$MonitReportLoadVG15mnCycles} cycles then exec \"/bin/artica-system-alert.sh LOAD_15 {$MonitReportLoadVG15mn}\""; } if ($MonitCPUUsage > 0) { if ($MonitCPUUsage < 75) { $MonitCPUUsage = 75; } $TSCR[] = "\tif cpu usage(system) > {$MonitCPUUsage}% for {$MonitCPUUsageCycles} cycles then exec \"/bin/artica-system-alert.sh CPU_SYSTEM {$MonitCPUUsage}\""; $TSCR[] = "\tif cpu usage(user) > {$MonitCPUUsage}% for {$MonitCPUUsageCycles} cycles then exec \"/bin/artica-system-alert.sh CPU_USER {$MonitCPUUsage}\""; $TSCR[] = "\tif cpu usage(wait) > {$MonitCPUUsage}% for {$MonitCPUUsageCycles} cycles then exec \"/bin/artica-system-alert.sh CPU_WAIT {$MonitCPUUsage}\""; } if ($MonitMemUsage > 0) { if ($MonitMemUsage < 75) { $MonitMemUsage = 75; } $TSCR[] = "\tif memory > {$MonitMemUsage}% for {$MonitMemUsageCycles} cycles then exec \"/bin/artica-system-alert.sh MEM {$MonitMemUsage}\""; } if ($MonitMemPurgeCache > 5) { @chmod("/usr/share/artica-postfix/exec.kernel.purge.cache.php", 0755); $TSCR[] = "\tif memory > {$MonitMemPurgeCache}% for {$MonitMemPurgeCacheCycles} cycles then exec \"/usr/share/artica-postfix/exec.kernel.purge.cache.php\""; } if (count($TSCR) > 1) { $f[] = "check system " . $unix->hostname_g(); $f[] = @implode("\n", $TSCR); } $TSCR = array(); $SCRIPT = array(); $SCRIPT[] = "#!/bin/sh"; $SCRIPT[] = "CURRENT=`{$date} +%s`"; $SCRIPT[] = "DIR=\"/home/artica/system/perf-queue/\$CURRENT\""; $SCRIPT[] = "{$mkdir} -p \"\$DIR\""; $SCRIPT[] = "{$echo} \$CURRENT >\$DIR/time.txt"; $SCRIPT[] = "{$echo} \$1 >\$DIR/why.txt"; $SCRIPT[] = "{$echo} \$2 >\$DIR/why2.txt"; $iotop = $unix->find_program("iotop"); if (is_file($iotop)) { $SCRIPT[] = "{$iotop} -o -a -b -q -t -n 20 >\$DIR/iotop.txt || true"; } $SCRIPT[] = "{$nice} {$python} /usr/share/artica-postfix/bin/ps_mem.py >\$DIR/psmem.txt 2>&1"; $SCRIPT[] = "{$ps} --no-heading -eo user,pid,pcpu,args|{$sort} -grbk 3|{$head} -50 >\$DIR/TOP50-CPU.txt 2>&1"; $SCRIPT[] = "{$ps} --no-heading -eo user,pid,pmem,args|{$sort} -grbk 3|{$head} -50 >\$DIR/TOP50-MEM.txt 2>&1"; $SCRIPT[] = "{$ps} auxww >\$DIR/ALLPS.txt 2>&1"; $SCRIPT[] = ""; @file_put_contents("/bin/artica-system-alert.sh", @implode("\n", $SCRIPT)); @chmod("/bin/artica-system-alert.sh", 0755); $SCRIPT = array(); $f[] = ""; $f[] = "check host loopback with address 127.0.0.1"; $f[] = "\tif failed icmp type echo with timeout 1 seconds then exec \"/bin/loopbackfailed.sh\""; $f[] = ""; $loopbackfailed[] = "#!/bin/sh"; $loopbackfailed[] = "{$php5} /usr/share/artica-postfix/exec.virtuals-ip.php --loopback"; $loopbackfailed[] = ""; @file_put_contents("/bin/loopbackfailed.sh", @implode("\n", $loopbackfailed)); @chmod("/bin/loopbackfailed.sh", 0755); $loopbackfailed = array(); build_progress_restart("{reconfiguring}", 25); //******************************************************************************************************************** $f[] = "check file php.log with path /var/log/php.log"; $f[] = "\tif size > 100 MB then"; $f[] = "\t\texec \"/bin/clean-phplog.sh\""; $f[] = ""; $f[] = "check file usrphp.log with path /usr/share/artica-postfix/ressources/logs/php.log"; $f[] = " if size > 100 MB then"; $f[] = "\t\texec \"/bin/clean-phplog.sh\""; $f[] = ""; $f[] = "check file squid-logger-start.log with path /var/log/artica-postfix/squid-logger-start.log"; $f[] = "\tif size > 100 MB then"; $f[] = "\t\texec \"/bin/squid-logger-start.sh\""; $f[] = ""; build_progress_restart("{reconfiguring}", 26); $f[] = "include /etc/monit/conf.d/*"; @file_put_contents("/etc/monit/monitrc", @implode("\n", $f)); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/monit/monitrc done...\n"; } $AA[] = "#!/bin/sh"; $AA[] = "{$echo} \"#\" >/var/log/artica-postfix/squid-logger-start.log"; $AA[] = ""; @file_put_contents("/bin/squid-logger-start.sh", @implode("\n", $AA)); @chmod("/bin/squid-logger-start.sh", 0755); $AA = array(); $AA[] = "#!/bin/sh"; $AA[] = "{$echo} \"#\" >/var/log/php.log"; $AA[] = ""; @file_put_contents("/bin/clean-phplog.sh", @implode("\n", $AA)); @chmod("/bin/clean-phplog.sh", 0755); $AA = array(); $monit = new monit(); $monit->save(); $INITD_PATH = $unix->SLAPD_INITD_PATH(); $SLAPD_PID_FILE = $unix->SLAPD_PID_PATH(); $squidbin = $unix->LOCATE_SQUID_BIN(); @unlink("/etc/monit/conf.d/APP_OPENLDAP.monitrc"); //******************************************************************************************************************** $f = array(); //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 27); $f = array(); $f[] = "check process APP_FRAMEWORK"; $f[] = "with pidfile /var/run/lighttpd/framework.pid"; $f[] = "start program = \"/etc/init.d/artica-framework start --monit\""; $f[] = "stop program = \"/etc/init.d/artica-framework stop --monit\""; $f[] = "if 5 restarts within 5 cycles then timeout"; @file_put_contents("/etc/monit/conf.d/articaframework.monitrc", @implode("\n", $f)); $f = array(); //******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_OPENSSH.monitrc"); @unlink("/etc/monit/conf.d/APP_MYSQLD.monitrc"); //******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring}", 28); $f[] = "check process APP_ARTICA_STATUS with pidfile /etc/artica-postfix/exec.status.php.pid"; $f[] = "\tstart program = \"/etc/init.d/artica-status start --monit\""; $f[] = "\tstop program = \"/etc/init.d/artica-status stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Status...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ARTICASTATUS.monitrc", @implode("\n", $f)); //******************************************************************************************************************** $f = array(); $EnableInflux = 1; if ($SquidPerformance > 2) { $EnableInflux = 0; } $InfluxUseRemote = intval($sock->GET_INFO("InfluxUseRemote")); $EnableInfluxDB = intval($sock->GET_INFO("EnableInfluxDB")); if ($InfluxUseRemote == 1) { $EnableInfluxDB = 0; } if ($EnableIntelCeleron == 1) { $EnableInflux = 0; } if ($EnableInfluxDB == 0) { $EnableInflux = 0; } if (is_file("/etc/artica-postfix/STATS_APPLIANCE")) { $EnableInflux = 1; } build_progress_restart("{reconfiguring}", 29); @unlink("/etc/monit/conf.d/APP_INFLUXDB.monitrc"); @unlink("/etc/monit/conf.d/APP_POSTGRES.monitrc"); if (is_file("/usr/local/ArticaStats/bin/postgres")) { if ($EnableInflux == 1) { $InfluxRestartMem = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/InfluxRestartMem")); $f[] = "check process APP_POSTGRES with pidfile /home/ArticaStatsDB/postmaster.pid"; $f[] = "\tstart program = \"/etc/init.d/artica-postgres start --monit\""; $f[] = "\tstop program = \"/etc/init.d/artica-postgres --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; if ($InfluxRestartMem > 50) { $f[] = "\tif totalmem > {$InfluxRestartMem} MB for 5 cycles then restart"; } $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Status...\n"; } @file_put_contents("/etc/monit/conf.d/APP_POSTGRES.monitrc", @implode("\n", $f)); //******************************************************************************************************************** } } $f = array(); @unlink("/etc/monit/conf.d/squid.monitrc"); @unlink("/etc/monit/conf.d/APP_SQUIDMAIN.monitrc"); // ******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_SQUIDDB.monitrc"); build_progress_restart("{reconfiguring} Proxy service", 30); if (is_dir("/opt/squidsql/data")) { if ($SQUIDEnable == 1) { $f = array(); $f[] = "check process APP_SQUID_DB with pidfile /var/run/squid-db.pid"; $f[] = "\tstart program = \"/etc/init.d/squid-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/squid-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/mysqld/squid-db.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Squid MySQL DB...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SQUIDDB.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring} Dnsmasq", 31); @unlink("/etc/monit/conf.d/APP_DNSMASQ.monitrc"); if ($users->dnsmasq_installed) { $enabled = $sock->dnsmasq_enabled(); if ($enabled == 1) { $f[] = "check process APP_DNSMASQ with pidfile /var/run/dnsmasq.pid"; $f[] = "\tstart program = \"/etc/init.d/dnsmasq start --monit\""; $f[] = "\tstop program = \"/etc/init.d/dnsmasq stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DnsMASQ...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DNSMASQ.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring} Proftpd", 31); @unlink("/etc/monit/conf.d/APP_PROFTPD.monitrc"); $proftpd = $unix->find_program("proftpd"); if (is_file($proftpd)) { $enabled = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableProFTPD")); if ($enabled == 1) { $f[] = "check process APP_PROFTPD with pidfile /var/run/proftpd.pid"; $f[] = "\tstart program = \"/etc/init.d/proftpd start --monit\""; $f[] = "\tstop program = \"/etc/init.d/proftpd stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DnsMASQ...\n"; } @file_put_contents("/etc/monit/conf.d/APP_PROFTPD.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring} Bandwidthd", 31); @unlink("/etc/monit/conf.d/APP_BANDWIDTHD.monitrc"); if (is_file("/usr/bandwidthd/bandwidthd")) { $enabled = $sock->Bandwidthd_enabled(); if ($enabled == 1) { $f[] = "check process APP_BANDWIDTHD with pidfile /var/run/bandwidthd.pid"; $f[] = "\tstart program = \"/etc/init.d/bandwidthd start --monit\""; $f[] = "\tstop program = \"/etc/init.d/bandwidthd stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DnsMASQ...\n"; } @file_put_contents("/etc/monit/conf.d/APP_BANDWIDTHD.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring} rsyslog", 32); $rsyslogd = $unix->find_program("rsyslogd"); @unlink("/etc/monit/conf.d/APP_RSYSLOG.monitrc"); if (is_file($rsyslogd)) { $SCRIPT = array(); $SCRIPT[] = "#!/bin/sh"; $SCRIPT[] = "{$php5} /usr/share/artica-postfix/exec.watchdog.rsyslogd.php --start"; $SCRIPT[] = ""; @file_put_contents("/bin/artica-rsyslog-start.sh", @implode("\n", $SCRIPT)); @chmod("/bin/artica-rsyslog-start.sh", 0755); $SCRIPT = array(); $SCRIPT[] = "#!/bin/sh"; $SCRIPT[] = "{$php5} /usr/share/artica-postfix/exec.watchdog.rsyslogd.php --stop"; $SCRIPT[] = ""; @file_put_contents("/bin/artica-rsyslog-stop.sh", @implode("\n", $SCRIPT)); @chmod("/bin/artica-rsyslog-stop.sh", 0755); $SCRIPT = array(); $f[] = "check process APP_RSYSLOG with pidfile /var/run/rsyslogd.pid"; $f[] = "\tstart program = \"/bin/artica-rsyslog-start.sh\""; $f[] = "\tstop program = \"/bin/artica-rsyslog-stop.sh\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring rsyslogd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_RSYSLOG.monitrc", @implode("\n", $f)); } // ******************************************************************************************************************** build_progress_restart("{reconfiguring} Squid-tail", 32); $APP_ARTICA_SQUID_TAIL = $unix->SQUID_TAIL_ENABLED(); @unlink("/etc/monit/conf.d/APP_ARTICA_SQUID_TAIL.monitrc"); if ($APP_ARTICA_SQUID_TAIL == 1) { $f = array(); $f[] = "check process APP_ARTICA_SQUID_TAIL with pidfile /etc/artica-postfix/pids/exec.logfile_daemon.php.pid"; $f[] = "\tstart program = \"/etc/init.d/squid-tail start\""; $f[] = "\tstop program = \"/etc/init.d/squid-tail stop\""; $f[] = "\tif cpu usage > 95% for 5 cycles then restart"; $f[] = "\tif totalmem > 550.0 MB for 5 cycles then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring squid-tail...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ARTICA_SQUID_TAIL.monitrc", @implode("\n", $f)); } // ******************************************************************************************************************** build_progress_restart("{reconfiguring} Squid-Proxy", 32); $APP_SQUID = $unix->SQUID_ENABLED(); @unlink("/etc/monit/conf.d/APP_SQUID.monitrc"); if ($APP_SQUID == 1) { $MonitConfig = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/SquidWatchdogMonitConfig"))); if (!isset($MonitConfig["watchdog"])) { $MonitConfig["watchdog"] = 1; } if (!is_numeric($MonitConfig["watchdog"])) { $MonitConfig["watchdog"] = 1; } $f = array(); if ($MonitConfig["watchdog"] == 1) { $MonitSquidMaxRestartMem = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/MonitSquidMaxRestartMem")); $MonitSquidMaxCPU = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/MonitSquidMaxCPU")); $f[] = "check process APP_SQUID with pidfile /var/run/squid/squid.pid"; $f[] = "\tstart program = \"/etc/init.d/squid start --monit\""; $f[] = "\tstop program = \"/etc/init.d/squid stop --monit\""; if ($MonitSquidMaxCPU > 0) { $f[] = "\tif cpu usage > {$MonitSquidMaxCPU}% for 5 cycles then restart"; } if ($MonitSquidMaxRestartMem > 0) { $f[] = "\tif totalmem > {$MonitSquidMaxRestartMem}.0 MB for 5 cycles then restart"; } $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring squid...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SQUID.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** build_progress_restart("{reconfiguring} OpenLDAP", 32); $EnableOpenLDAP = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP")); $SLAPD_PID_FILE = $unix->SLAPD_PID_PATH(); @unlink("/etc/monit/conf.d/APP_SLAPD.monitrc"); if ($EnableOpenLDAP == 1) { if ($EnableIntelCeleron == 0) { $f = array(); $f[] = "check process APP_SLAPD with pidfile {$SLAPD_PID_FILE}"; $f[] = "\tstart program = \"/etc/init.d/slapd start --force --monit\""; $f[] = "\tstop program = \"/etc/init.d/slapd stop --force\""; $f[] = "\tif cpu usage > 95% for 5 cycles then restart"; $f[] = "\tif totalmem > 550.0 MB for 5 cycles then restart"; $f[] = "\tif failed unixsocket /var/run/slapd/slapd.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring slapd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SLAPD.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring} Suricata", 32); $EnableSuricata = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSuricata")); @unlink("/etc/monit/conf.d/APP_SURICATA.monitrc"); @unlink("/etc/monit/conf.d/APP_SURICATA_TAIL.monitrc"); $suricata = $unix->find_program("suricata"); if (is_file($suricata)) { if ($EnableSuricata == 1) { $f[] = "check process APP_SURICATA with pidfile /var/run/suricata/suricata.pid"; $f[] = "\tstart program = \"/etc/init.d/suricata start --monit\""; $f[] = "\tstop program = \"/etc/init.d/suricata stop --monit\""; $f[] = "\tif cpu usage > 95% for 5 cycles then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Suricata...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SURICATA.monitrc", @implode("\n", $f)); $f = array(); $f[] = "check process APP_SURICATA_TAIL with pidfile /etc/artica-postfix/exec.suricata-tail.php.pid"; $f[] = "\tstart program = \"/etc/init.d/suricata-tail start --monit\""; $f[] = "\tstop program = \"/etc/init.d/suricata-tail stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Suricata tail...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SURICATA_TAIL.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring}", 32); $winbind = $unix->find_program("winbindd"); if (is_file("/etc/monit/conf.d/winbindd.monitrc")) { @unlink("/etc/monit/conf.d/winbindd.monitrc"); } @unlink("/etc/monit/conf.d/winbind.monitrc"); $EnableKerbAuth = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableKerbAuth")); if (is_file($winbind)) { if ($EnableKerbAuth == 1) { $f[] = "check process winbindd with pidfile /var/run/samba/winbindd.pid"; $f[] = "\tstart program = \"/etc/init.d/winbind start\""; $f[] = "\tstop program = \"/etc/init.d/winbind stop\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring winbindd...\n"; } @file_put_contents("/etc/monit/conf.d/winbind.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); build_progress_restart("{reconfiguring}", 33); @unlink("/etc/monit/conf.d/APP_CICAP.monitrc"); if ($users->C_ICAP_INSTALLED) { if ($SQUIDEnable == 1) { $CicapEnabled = $sock->GET_INFO("CicapEnabled"); if (!is_numeric($CicapEnabled)) { $CicapEnabled = 0; } if ($CicapEnabled == 1) { $f[] = "check process APP_C_ICAP with pidfile /var/run/c-icap/c-icap.pid"; $f[] = "\tstart program = \"/etc/init.d/artica-postfix start cicap\""; $f[] = "\tstop program = \"/etc/init.d/artica-postfix stop cicap\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring C-ICAP...\n"; } @file_put_contents("/etc/monit/conf.d/APP_CICAP.monitrc", @implode("\n", $f)); } } } // ******************************************************************************************************************** build_progress_restart("{reconfiguring}", 34); @unlink("/etc/monit/conf.d/APP_SYSLOGDB.monitrc"); if ($EnableSyslogDB == 1) { if ($MySQLSyslogType == 1) { $f = array(); $f[] = "check process APP_SYSLOG_DB with pidfile /var/run/syslogdb.pid"; $f[] = "\tstart program = \"/etc/init.d/syslog-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/syslog-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/syslogdb.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring syslogd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SYSLOGDB.monitrc", @implode("\n", $f)); $f = array(); } } //******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/cron.monitrc"); if (is_file("/etc/monit/templates/rootbin")) { $f[] = "check process crond with pidfile /var/run/crond.pid"; $f[] = " group system"; $f[] = " group crond"; $f[] = " start program = \"/etc/init.d/cron start\""; $f[] = " stop program = \"/etc/init.d/cron stop\""; $f[] = " if 5 restarts with 5 cycles then timeout"; $f[] = " depend cron_bin"; $f[] = " depend cron_rc"; $f[] = " depend cron_spool"; $f[] = ""; $f[] = " check file cron_bin with path /usr/sbin/cron"; $f[] = " group crond"; $f[] = " include /etc/monit/templates/rootbin"; $f[] = ""; $f[] = " check file cron_rc with path \"/etc/init.d/cron\""; $f[] = " group crond"; $f[] = " include /etc/monit/templates/rootbin"; $f[] = ""; $f[] = " check directory cron_spool with path /var/spool/cron/crontabs"; $f[] = " group crond"; $f[] = " if failed permission 1730 then unmonitor"; $f[] = " if failed uid root then unmonitor"; $f[] = " if failed gid crontab then unmonitor"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring cron...\n"; } @file_put_contents("/etc/monit/conf.d/cron.monitrc", @implode("\n", $f)); $f = array(); } @unlink("/etc/monit/conf.d/APP_ZARAFASERVER.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAGATEWAY.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAAPACHE.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAWEB.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFASPOOLER.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFADB.monitrc"); build_progress_restart("{reconfiguring}", 35); if (is_file($unix->find_program("zarafa-server"))) { $ZarafaApacheEnable = $sock->GET_INFO("ZarafaApacheEnable"); if (!is_numeric($ZarafaApacheEnable)) { $ZarafaApacheEnable = 1; } $ZarafaApachePort = $sock->GET_INFO("ZarafaApachePort"); if (!is_numeric($ZarafaApachePort)) { $ZarafaApachePort = 9010; } if ($ZarafaDedicateMySQLServer == 1) { $f = array(); $f[] = "check process APP_ZARAFA_DB with pidfile /var/run/zarafa-db.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/mysqld/zarafa-db.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Database...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFADB.monitrc", @implode("\n", $f)); } $f = array(); $f[] = "check process APP_ZARAFA_SERVER with pidfile /var/run/zarafa-server.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-server start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-server stop --monit\""; $f[] = "\tif failed unixsocket /var/run/zarafa then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Server...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFASERVER.monitrc", @implode("\n", $f)); $f = array(); $f[] = "check process APP_ZARAFA_SPOOLER with pidfile /var/run/zarafa-spooler.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-spooler start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-spooler stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Spooler...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFASPOOLER.monitrc", @implode("\n", $f)); $f = array(); $f[] = "check process APP_ZARAFA_GATEWAY with pidfile /var/run/zarafa-gateway.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-gateway start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-gateway stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Gateway...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFAGATEWAY.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 36); $EnableClamavDaemon = $sock->GET_INFO("EnableClamavDaemon"); $EnableClamavDaemonForced = $sock->GET_INFO("EnableClamavDaemonForced"); $CicapEnabled = $sock->GET_INFO("CicapEnabled"); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($EnableClamavDaemon)) { $EnableClamavDaemon = 0; } if (!is_numeric($EnableClamavDaemonForced)) { $EnableClamavDaemonForced = 0; } if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if (!is_numeric($CicapEnabled)) { $CicapEnabled = 0; } if ($SQUIDEnable == 1) { if ($CicapEnabled == 1) { $EnableClamavDaemon = 1; } } if ($EnableClamavDaemonForced == 1) { $EnableClamavDaemon = 1; } //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 37); @unlink("/etc/monit/conf.d/APP_CLAMAV.monitrc"); $MasterBin = $unix->find_program("clamd"); if (is_file($MasterBin)) { if ($EnableClamavDaemon == 1) { $f = array(); $f[] = "check process APP_CLAMAV"; $f[] = "with pidfile /var/run/clamav/clamd.pid"; $f[] = "start program = \"/etc/init.d/clamav-daemon start --monit\""; $f[] = "stop program = \"/etc/init.d/clamav-daemon stop --monit\""; $f[] = "if 5 restarts within 5 cycles then timeout"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Clamd service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_CLAMAV.monitrc", @implode("\n", $f)); $f = array(); } } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/ufdb.monitrc"); @unlink("/etc/monit/conf.d/ufdbweb.monitrc"); $ufdbbin = $unix->find_program("ufdbguardd"); build_progress_restart("{reconfiguring}", 38); if (is_file($ufdbbin)) { $EnableUfdbGuard = intval($sock->EnableUfdbGuard()); $UseRemoteUfdbguardService = $sock->GET_INFO('UseRemoteUfdbguardService'); $EnableSquidGuardHTTPService = $sock->GET_INFO("EnableSquidGuardHTTPService"); $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); $SquidGuardApachePort = $sock->GET_INFO("SquidGuardApachePort"); $SquidGuardApacheSSLPort = $sock->GET_INFO("SquidGuardApacheSSLPort"); if (!is_numeric($UseRemoteUfdbguardService)) { $UseRemoteUfdbguardService = 0; } if (!is_numeric($EnableUfdbGuard)) { $EnableUfdbGuard = 0; } if (!is_numeric($EnableSquidGuardHTTPService)) { $EnableSquidGuardHTTPService = 1; } if (!is_numeric($EnableWebProxyStatsAppliance)) { $EnableWebProxyStatsAppliance = 0; } if ($EnableUfdbGuard == 0) { $EnableSquidGuardHTTPService = 0; } if ($EnableWebProxyStatsAppliance == 1) { $EnableSquidGuardHTTPService = 1; } if (!is_numeric($SquidGuardApachePort)) { $SquidGuardApachePort = "9020"; } if (!is_numeric($SquidGuardApacheSSLPort)) { $SquidGuardApacheSSLPort = 9025; } if ($SquidPerformance > 2) { $EnableSquidGuardHTTPService = 0; } if ($SQUIDEnable == 1) { if ($EnableSquidGuardHTTPService == 1) { $f = array(); $f[] = "check process APP_SQUIDGUARD_HTTP"; $f[] = "with pidfile /var/run/lighttpd/squidguard-lighttpd.pid"; $f[] = "start program = \"/etc/init.d/squidguard-http start --monit\""; $f[] = "stop program = \"/etc/init.d/squidguard-http stop --monit\""; $f[] = "if failed host 127.0.0.1 port {$SquidGuardApachePort} then restart"; $f[] = "if 5 restarts within 5 cycles then timeout"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Web filtering HTTP service...\n"; } @file_put_contents("/etc/monit/conf.d/ufdbweb.monitrc", @implode("\n", $f)); } } } //******************************************************************************************************************** $EnableArticaFrontEndToNGninx = $sock->GET_INFO("EnableArticaFrontEndToNGninx"); $EnableArticaFrontEndToApache = $sock->GET_INFO("EnableArticaFrontEndToApache"); if (!is_numeric($EnableArticaFrontEndToNGninx)) { $EnableArticaFrontEndToNGninx = 0; } if (!is_numeric($EnableArticaFrontEndToApache)) { $EnableArticaFrontEndToApache = 0; } $EnableNginx = $sock->GET_INFO("EnableNginx"); $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb"); if (!is_numeric($EnableFreeWeb)) { $EnableFreeWeb = 0; } if (!is_numeric($EnableNginx)) { $EnableNginx = 1; } if ($EnableNginx == 0) { $EnableArticaFrontEndToNGninx = 0; } $pid = null; build_progress_restart("{reconfiguring}", 39); @unlink("/etc/monit/conf.d/APP_LIGHTTPD.monitrc"); if ($EnableArticaFrontEndToNGninx == 0) { $pid = "/var/run/lighttpd/lighttpd.pid"; if ($EnableArticaFrontEndToApache == 1) { $pid = "/var/run/artica-apache/apache.pid"; } $f = array(); $f[] = "check process APP_ARTICAWEBCONSOLE with pidfile {$pid}"; $f[] = "\tstart program = \"/etc/init.d/artica-webconsole start --monit\""; $f[] = "\tstop program = \"/etc/init.d/artica-webconsole stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Web Console...\n"; } @file_put_contents("/etc/monit/conf.d/APP_LIGHTTPD.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_NGINX.monitrc"); $nginx = $unix->find_program("nginx"); if (is_file($nginx)) { if ($EnableNginx == 1) { $f = array(); $f[] = "check process APP_NGINX with pidfile /var/run/nginx.pid"; $f[] = "\tstart program = \"/etc/init.d/nginx start --monit\""; $f[] = "\tstop program = \"/etc/init.d/nginx stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring NgINX...\n"; } @file_put_contents("/etc/monit/conf.d/APP_NGINX.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 40); $f = array(); if (is_file("/etc/init.d/sysklogd")) { $f[] = "check process APP_SYSLOGD with pidfile /var/run/syslogd.pid"; $f[] = "\tstart program = \"/etc/init.d/sysklogd start --monit\""; $f[] = "\tstop program = \"/etc/init.d/sysklogd stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = "\tcheck file syslogd_file with path /var/log/syslog"; $f[] = "\tif timestamp > 10 minutes then restart"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring sysklogd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SYSKLOGD.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 41); $binpath = $unix->DHCPD_BIN_PATH(); @unlink("/etc/monit/conf.d/APP_DHCPD.monitrc"); $f = array(); if (is_file($binpath)) { $EnableDHCPServer = $sock->GET_INFO("EnableDHCPServer"); if (!is_numeric($EnableDHCPServer)) { $EnableDHCPServer = 0; } if ($EnableDHCPServer == 1) { $f[] = "check process APP_DHCP with pidfile /var/run/dhcpd.pid"; $f[] = "\tstart program = \"/etc/init.d/isc-dhcp-server start --monit\""; $f[] = "\tstop program = \"/etc/init.d/isc-dhcp-server stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DHCP Service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DHCPD.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** $binpath = $unix->find_program("rdpproxy"); build_progress_restart("{reconfiguring}", 42); @unlink("/etc/monit/conf.d/APP_RDPPROXY.monitrc"); $f = array(); if (is_file($binpath)) { $EnableRDPProxy = $sock->GET_INFO("EnableRDPProxy"); if (!is_numeric($EnableRDPProxy)) { $EnableRDPProxy = 0; } if ($EnableRDPProxy == 1) { $f[] = "check process APP_RDPPROXY with pidfile /var/run/redemption/rdpproxy.pid"; $f[] = "\tstart program = \"/etc/init.d/rdpproxy start --monit\""; $f[] = "\tstop program = \"/etc/init.d/rdpproxy stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring RDP Proxy...\n"; } @file_put_contents("/etc/monit/conf.d/APP_RDPPROXY.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** build_progress_restart("{reconfiguring}", 43); @unlink("/etc/monit/conf.d/APP_DNSMASQ.monitrc"); $f = array(); $binpath = $unix->find_program("dnsmasq"); if (is_file($binpath)) { $EnableDNSMASQ = $users->EnableDNSMASQ(); if ($EnableDNSMASQ == 1) { $f[] = "check process APP_DNSMASQ with pidfile /var/run/dnsmasq.pid"; $f[] = "\tstart program = \"/etc/init.d/dnsmasq start --monit\""; $f[] = "\tstop program = \"/etc/init.d/dnsmasq stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DNSMasq Service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DNSMASQ.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} checking syslog\n"; } if (is_file("/etc/init.d/syslog")) { checkDebSyslog(); } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} configuration done\n"; } shell_exec($GLOBALS["MONIT_CLASS"]->monitor_all_cmdline . " 2>&1"); build_progress_restart("{reconfiguring}", 45); }
function status() { $sock = new sockets(); $sock->getFrameWork("unifi.php?status=yes"); $tpl = new templates(); $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/unifi.status"); $UNIFI_MONGODB = DAEMON_STATUS_ROUND("UNIFI_MONGODB", $ini, null); $UNIFI_CONTROLLER = DAEMON_STATUS_ROUND("UNIFI_CONTROLLER", $ini, null); echo $tpl->_ENGINE_parse_body("\n\t\t\t{$UNIFI_CONTROLLER}\n\t\t\t<p> </p>\n\t\t\t{$UNIFI_MONGODB}\n\t\t\t\n\t\t\t"); }
if (!is_file("/etc/artica-postfix/settings/Daemons/CyrusAVConfig")) { echo "/etc/artica-postfix/settings/Daemons/CyrusAVConfig no such file...\n"; die; } @mkdir("/etc/artica-postfix/pids"); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $unix = new unix(); if ($unix->process_exists(@file_get_contents($pidfile))) { echo "Process already exists...\n"; die; } @file_put_contents($pidfile, getmypid()); $t1 = time(); $time = date('Y-m-d') . "_" . date('h:i'); $ini = new Bs_IniHandler(); $ini->loadFile("/etc/artica-postfix/settings/Daemons/CyrusAVConfig"); $nice = EXEC_NICE(); $clamscan = $unix->find_program("clamscan"); if (!is_file($clamscan)) { die; } $partition_default = $unix->IMAPD_GET("partition-default"); if (!is_dir($partition_default)) { send_email_events("Mailboxes antivirus scanning failed", "partition-default: \"{$partition_default}\"\nno such directory", "mailbox"); echo "partition-default: no such directory\n"; die; } @mkdir("/var/log/artica-postfix/antivirus/cyrus-imap", 0755, true); $time = date('Y-m-d') . "_" . date('h:I'); $cmd = "{$nice} /usr/bin/clamscan --recursive=yes --infected "; $cmd = $cmd . "--max-filesize=10M --max-scansize=10M --max-recursion=5 --max-dir-recursion=10 ";
function NotifyStatus() { $users = new usersMenus(); $master = @file_get_contents("/etc/artica-cluster/master"); $server = $master; $sock = new sockets(); if (trim($master) == null) { writelogs("Unable to get the master ", __FUNCTION__, __FILE__, __LINE__); return null; } if ($GLOBALS["VERBOSE"]) { echo "NotifyStatus() start...\n"; } if (!$users->GLUSTER_INSTALLED) { if ($GLOBALS["VERBOSE"]) { echo "GLUSTER_INSTALLED=false\n"; } die; } $gluster = new GlusterClient(); $unix = new unix(); $filetemp = $unix->FILE_TEMP(); if ($GLOBALS["VERBOSE"]) { echo "/usr/share/artica-postfix/bin/artica-install --gluster-status >{$filetemp} 2>&1\n"; } shell_exec("/usr/share/artica-postfix/bin/artica-install --gluster-status >{$filetemp} 2>&1"); $ini = new Bs_IniHandler(); $ini->loadFile($filetemp); while (list($num, $ligne) = each($ini->_params["GLUSTER"])) { $orders[$num] = $ligne; writelogs("order {$num}={$ligne}", __FUNCTION__, __FILE__, __LINE__); if ($GLOBALS["VERBOSE"]) { echo "order {$num}={$ligne}\n"; } } @unlink($filetemp); if ($GLOBALS["VERBOSE"]) { echo "my name is {$gluster->PARAMS["name"]}\n"; } $orders["NTFY_STATUS"] = $gluster->PARAMS["name"]; $orders["bricks"] = implode(",", $gluster->CLUSTERED_BRIKS); $folders = $gluster->CLUSTERED_FOLDERS; while (list($num, $ligne) = each($folders)) { $orders[$num] = $ligne; } $curl = new glusterCurl("https://{$server}:9000/exec.gluster.php"); $curl->parms = $orders; if ($GLOBALS["VERBOSE"]) { echo "sending infos to {$server}\n"; } if (!$curl->get()) { writelogs("curl error !"); return null; } if (preg_match("#DELETE_YOU#is", $curl->data)) { shell_exec("/etc/init.d/artica-postfix stop gluster"); shell_exec("/bin/rm -f /etc/artica-cluster/*"); $sock->getFrameWork("cmd.php?reconfigure-cyrus=yes"); return null; } if (preg_match("#CYRUS-ID=(.*?);#is", $curl->data, $re)) { writelogs("Master cyrus id =\"{$re[1]}\"", __FUNCTION__, __FILE__, __LINE__); $sock->SET_CLUSTER('cyrus_id', $re[1]); $cyrus_id = $sock->getFrameWork("cmd.php?idofUser=cyrus"); if ($cyrus_id != $re[1]) { writelogs("cyrus id \"{$re[1]}\" is different of my cyrus id {$cyrus_id} (restart cyrus)", __FUNCTION__, __FILE__, __LINE__); $sock->getFrameWork("cmd.php?reconfigure-cyrus=yes"); } str_replace("CYRUS-ID={$re[1]};", "", $curl->data); } $data = explode(";", $curl->data); if (is_array($data)) { while (list($index, $computer) = each($data)) { if ($computer == null) { continue; } if (!is_file("/etc/artica-cluster/clusters-{$computer}")) { $mustRestart = true; GetCLusterCLientInfos($computer); } } } if ($mustRestart) { shell_exec("/etc/init.d/artica-postfix restart gluster"); } }
function rules_toolbox_left() { if (!isset($_GET["t"])) { $_GET["t"] = time(); } $updateutility = null; $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $users = new usersMenus(); $mouse = "OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\""; $t = $_GET["t"]; if (!is_numeric($t)) { $t = time(); } $Computers = $q->COUNT_ROWS("webfilters_nodes"); if (!$q->TABLE_EXISTS("webfilter_certs")) { $q->CheckTables(); } if ($q->COUNT_ROWS("webfilter_certs") == 0) { $q->fill_webfilter_certs(); } $Computers = numberFormat($Computers, 0, "", " "); $sock = new sockets(); $EnableUfdbGuard = intval($sock->EnableUfdbGuard()); $tablescat = $q->LIST_TABLES_CATEGORIES(); $CountDeCategories = numberFormat(count($tablescat), 0, "", " "); $categoryuris_malware = numberFormat($q->COUNT_ROWS("categoryuris_malware"), 0, "", " "); $disable_service = $tpl->_ENGINE_parse_body("{disable_service}"); $datasUFDB = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig"))); if (!is_numeric($datasUFDB["DebugAll"])) { $datasUFDB["DebugAll"] = 0; } $update_parameters = $tpl->_ENGINE_parse_body("{update_parameters}"); $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); $SquidDatabasesUtlseEnable = $sock->GET_INFO("SquidDatabasesUtlseEnable"); $UseRemoteUfdbguardService = $sock->GET_INFO("UseRemoteUfdbguardService"); $UFDB = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig"))); $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth"); $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); if (!is_numeric($UseRemoteUfdbguardService)) { $UseRemoteUfdbguardService = 0; } if (!is_numeric($EnableWebProxyStatsAppliance)) { $EnableWebProxyStatsAppliance = 0; } if (!is_numeric($UseRemoteUfdbguardService)) { $UseRemoteUfdbguardService = 0; } if (!is_numeric($EnableKerbAuth)) { $EnableKerbAuth = 0; } if (!is_numeric($SquidDatabasesUtlseEnable)) { $SquidDatabasesUtlseEnable = 1; } $SquidDatabasesArticaEnable = $sock->GET_INFO("SquidDatabasesArticaEnable"); if (!is_numeric($SquidDatabasesArticaEnable)) { $SquidDatabasesArticaEnable = 1; } if ($EnableWebProxyStatsAppliance == 1) { $EnableUfdbGuard = 1; } if ($UseRemoteUfdbguardService == 0) { if ($UFDB["UseRemoteUfdbguardService"] == 1) { $sock->SET_INFO("UseRemoteUfdbguardService", 1); $UseRemoteUfdbguardService = 1; } } if ($users->WEBSTATS_APPLIANCE) { $EnableWebProxyStatsAppliance = 1; } if (!$users->APP_UFDBGUARD_INSTALLED) { $EnableUfdbGuard = 0; } if ($users->UPDATE_UTILITYV2_INSTALLED) { $updateutility = "\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/kaspersky-update-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.UpdateUtility.php')\" nowrap>UpdateUtility</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>"; } $ufdbgverb_icon = "ok24-grey.png"; $ufdbgverb_txt = "OFF"; if ($datasUFDB["DebugAll"] == 1) { $ufdbgverb_icon = "ok32.png"; $ufdbgverb_txt = "ON"; } if ($SquidDatabasesUtlseEnable == 1) { $SquidDatabasesUtlseEnable_P = "<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.toulouse-university.disable.php')\" nowrap>\n\t\t\t\t<b><span style='font-size:13px;text-decoration:underline'>{toulouse_university} {enabled}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t\t</tr>\t\t\n\t\t"; } else { $SquidDatabasesUtlseEnable_P = "<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32-grey.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline'\n\t\tOnClick=\"javascript:Loadjs('squid.toulouse-university.disable.php')\" nowrap>\n\t\t<b><span style='font-size:13px;text-decoration:underline'>{toulouse_university} {disabled}</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t"; } if ($SquidDatabasesArticaEnable == 1) { $SquidDatabasesArticaEnable_P = "<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline'\n\t\tOnClick=\"javascript:Loadjs('squid.artica-databases.disable.php')\" nowrap>\n\t\t<b><span style='font-size:13px;text-decoration:underline'>{artica_databases} {enabled}</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t"; } else { $SquidDatabasesArticaEnable_P = "<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32-grey.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline'\n\t\tOnClick=\"javascript:Loadjs('squid.artica-databases.disable.php')\" nowrap>\n\t\t<b><span style='font-size:13px;text-decoration:underline'>{artica_databases} {disabled}</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t"; } if (!$users->CORP_LICENSE) { $SquidDatabasesArticaEnable_P = "<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32-grey.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline'\n\t\tOnClick=\"javascript:blur()\" nowrap>\n\t\t<b><span style='font-size:13px;text-decoration:underline'>{artica_databases} {no_license}</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t"; } if ($EnableUfdbGuard == 1) { $DisableUfdbGuard = "\n\t\t\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/ok32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.disableUfdb.php')\" nowrap><b><span style='font-size:13px;text-decoration:underline'>{$disable_service}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t{$SquidDatabasesArticaEnable_P}\n\t\t{$SquidDatabasesUtlseEnable_P}\t\n\t\t"; } if ($UseRemoteUfdbguardService == 1) { $DisableUfdbGuard = null; } $html = "\n\t<table style='width:98%' class=form>\n\t{$DisableUfdbGuard}\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/computer-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php',true)\" nowrap><b><span style='font-size:13px;text-decoration:underline'>{$Computers}</span></b><span style='font-size:13px'> {computers}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/check-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='middle' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.categories.urls.php?popup-js=yes&category=malware&tablesize=695');\" nowrap><b><span style='font-size:13px;text-decoration:underline'>{$categoryuris_malware} Malware Uris</span></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\t\n\t\n\t\n\t\n\t\n\t"; $html = $html . "\n\t\t\t\n\t\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/check-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.tests.php')\" nowrap>\n\t\t\t\t<span style='font-size:13px;text-decoration:underline'>{verify_rules}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\t\t\n\t\n\t\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/loupe-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.category.tests.php')\" nowrap><span style='font-size:13px;text-decoration:underline'>{test_categories}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\t\t\t\n\t\n\t\n\t\n"; if ($UseRemoteUfdbguardService == 0) { $html = $html . "<tr>\n\t\t<td valign='middle' width=1%><img src='img/service-restart-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.php?force-reload-js=yes')\" nowrap><span style='font-size:13px;text-decoration:underline'>{reload_service}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/events-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.sevents.php?js=yes')\" nowrap><span style='font-size:13px;text-decoration:underline'>{service_events}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/{$ufdbgverb_icon}'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline;text-transform:capitalize' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.debug.php')\" nowrap><span style='font-size:13px;text-decoration:underline'>{debug} [{$ufdbgverb_txt}]</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/32-stop.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('squidguardweb.php')\" nowrap><span style='font-size:13px;text-decoration:underline'>{banned_page_webservice}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t"; } $html = $html . ""; if ($UseRemoteUfdbguardService == 0) { $html = $html . "\n\t<tr>\n\t\t<td valign='middle' width=1%><img src='img/script-32.png'></td>\n\t\t<td valign='middle' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='middle' width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:13px;text-decoration:underline' \n\t\t\t\tOnClick=\"javascript:Loadjs('ufdbguard.conf.php');\" nowrap>\n\t\t\t\t\t<span style='font-size:13px;text-decoration:underline'>{config_status}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\t\n\t{$updateutility}\t\n"; } $html = $html . "\n\n\t</table> \n\t\n\t\n\t"; $shield = null; if ($EnableUfdbGuard == 1) { if ($UseRemoteUfdbguardService == 0) { if (!$users->CORP_LICENSE) { $shield = "shield-warn-64.png"; $warn["{warn_ufdbguard_no_license}"] = null; } $ini = new Bs_IniHandler(); $sock = new sockets(); $sock->getFrameWork('squid2.php?ufdb-ini-status-write=yes'); $ini->loadFile("/usr/share/artica-postfix/ressources/interface-cache/UFDB_STATUS"); $restartlocalservice = "Loadjs('system.services.cmd.php?APPNAME=APP_UFDBGUARD&action=restart&cmd=%2Fetc%2Finit.d%2Fufdb&id=ed8cebc50034e96ed26a4d3cb953403f&appcode=APP_UFDBGUARD');"; $redirector_file = "/usr/share/artica-postfix/ressources/logs/web/squid_redirectors_status.db"; $redirectors_array = unserialize(@file_get_contents($redirector_file)); if (count($redirectors_array) > 1) { $redirectors_count = count($redirectors_array); if (strlen($redirectors_count) == 1) { $redirectors_count = "0{$redirectors_count}"; } $OBS["{redirectors}:{$redirectors_count}"] = "Loadjs('squid.redirectors.php');"; } if ($ini->_params["APP_UFDBGUARD"]["running"] == 0) { $shield = "shield-red-64.png"; $err["{warn_ufdbguard_stopped}"] = $restartlocalservice; } else { if ($shield == null) { $shield = "shield-ok-64.png"; } $OBS["{running_since}: {$ini->_params["APP_UFDBGUARD"]["uptime"]}"] = null; $OBS["{memory}: " . FormatBytes($ini->_params["APP_UFDBGUARD"]["master_memory"])] = null; } } if ($UseRemoteUfdbguardService == 1) { $server = $UFDB["remote_server"]; $port = $UFDB["remote_port"] = 3977; if (!@fsockopen($server, $port, $errno, $errstr, 1)) { $shield = "shield-red-64.png"; $err["{server}:«{$server}»:{$port}<br>{error} {$errno} {$errstr}"] = "Loadjs('ufdbguard.php?client-js=yes');"; } else { $OBS["{warn_ufdbguard_remote_use}"] = "Loadjs('ufdbguard.php?client-js=yes')"; } } if ($EnableWebProxyStatsAppliance == 0) { if (trim($sock->getFrameWork("squid.php?isufdbguard-squidconf=yes")) != "OK") { $shield = "shield-warn-64.png"; $warn["{warn_ufdbguard_not_squidconf}"] = "Loadjs('squid.compile.progress.php')"; } } $OBS["{refresh}"] = "LoadAjaxTiny('rules-toolbox-left','{$page}?rules-toolbox-left=yes&RemoveCache=yes');"; $html2[] = "\n\t <table style='width:100%'>\n\t <tr>\n\t \t<td valign='top' style='width:64px'><img src='img/{$shield}'></td>\n\t \t<td>\t\t\n\t \t\t<table style='width:100%'>\n\t "; while (list($num, $js) = each($warn)) { if ($js == null) { $js = "blur();"; } $html2[] = "\n\t \t\t<tr>\n\t \t\t<td width=16px style='vertical-align:top'><img src='img/arrow-right-yellow-16.png'></td>\n\t\t\t<td>\n\t \t\t<a href=\"javascript:blur();\" \n\t \t\tOnClick=\"javascript:{$js}\" \n\t \t\tstyle='color:#black !important;font-weight:normal !important;font-size:12px;text-decoration:underline'>{$num}</a>\n\t \t\t<hr style='border:1px'>\n\t \t\t</td>\n\t \t\t</tr>\n\t \t\t"; } while (list($num, $js) = each($err)) { if ($js == null) { $js = "blur();"; } $html2[] = "\n\t \t<tr>\n\t \t<td width=16px style='vertical-align:top'><img src='img/arrow-right-red-16.png'></td>\n\t \t<td >\n\t \t\t<a href=\"javascript:blur();\" \n\t \t\tOnClick=\"javascript:{$js}\" \n\t \t\tstyle='color:#d32d2d !important;text-decoration:underline;font-weight:bold !important;font-size:12px'>{$num}</a>\n\t \t\t<hr style='border:1px'>\n\t \t</td>\n\t \t</tr>\n\t \t"; } while (list($num, $js) = each($OBS)) { if ($js == null) { $js = "blur();"; } $html2[] = "\n\t \t<tr>\n\t \t<td width=16px style='vertical-align:top'><img src='img/arrow-right-16.png'></td>\n\t \t<td >\n\t \t\t<a href=\"javascript:blur();\" \n\t \t\tOnClick=\"javascript:{$js}\" \n\t \t\tstyle='color:#46a346 !important;font-weight:bold !important;font-size:12px;text-decoration:underline'>{$num}</a>\n\t \t\t\n\t \t</td>\n\t \t\n\t \t</td>\n\t \t</tr>\n\t \t"; } $html2[] = "</table>\n\t </td>\n\t </tr>\n\t </table>\n\t <p> </p>\n\t "; echo $tpl->_ENGINE_parse_body(@implode("\n", $html2)); } $t = time(); $users = new usersMenus(); $PERF = true; $serverMem = round($users->MEM_TOTAL_INSTALLEE / 1024); $CPU = $users->CPU_NUMBER; if ($serverMem < 2000) { $PERF = FALSE; } if ($CPU < 2) { $PERF = FALSE; } if (!$PERF) { $echo1 = $echo1 . $tpl->_ENGINE_parse_body("\n\t\t<div id='{$t}' style='width:90%;margin-bottom:20px' class=form>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='top' width=99%>\n\t\t<div style='font-size:14px;color:#CC0A0A'>\n\t\t<img src='img/warning-panneau-42.png' style='float:left;margin:3px'>\n\t\t<span style='font-size:11px'>{warn_no_performance_minimal}</span>\n\t\t</div>\n\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>"); } $t = time() + 1; echo $tpl->_ENGINE_parse_body($echo1 . $html); }
function SERVICES_STATUS() { if ($_GET["section"] == "index") { INDEX(); exit; } $ini = new Bs_IniHandler(); $sock = new sockets(); $GLOBALS["ArticaWatchDogList"] = unserialize(base64_decode($sock->GET_INFO("ArticaWatchDogList"))); $users = new usersMenus(); $users->LoadModulesEnabled(); if ($_GET["section"] == null) { $_GET["section"] = "artica_services"; } //echo($sock->getfile('daemons_status')); $table_header = "<tr>\n\t\t<th width=1% style='{$style1}{$style2}'> </td>\n\t\t<th nowrap>{daemon}</td>\n\t\t<th nowrap> </td>\n\t\t<th width=1% nowrap>{memory}</td>\n\t\t<th width=1% nowrap>{virtual_memory}</td>\n\t\t<th width=1%>{version}</td>\n\t\t<th nowrap >{uptime}</td>\n\t\t</tr>"; $inifile = dirname(__FILE__) . "/ressources/logs/global.status.ini"; $ini->loadFile($inifile); if ($_GET["section"] == "artica_services") { $html = "\n\t\t\t<div style='heigth:550px;overflow:auto'>\n\t\t\t<table style='width:98%;margin:0px;padding:5px;'>{$table_header}"; if ($users->VMWARE_HOST) { if ($users->VMWARE_TOOLS_INSTALLED) { $html = $html . BuildRow($users, $ini->_params["APP_VMTOOLS"], "{APP_VMTOOLS}"); } } if ($users->VIRTUALBOX_HOST) { if ($users->APP_VBOXADDINTION_INSTALLED) { $html = $html . BuildRow($users, $ini->_params["APP_VBOXADDITIONS"], "{APP_VBOXADDITIONS}"); } } $html = $html . BuildRow($users, $ini->_params["ARTICA"], "{APP_ARTICA}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_NOTIFIER"], "{APP_ARTICA_NOTIFIER}"); $html = $html . BuildRow($users, $ini->_params["LIGHTTPD"], "{APP_LIGHTTPD}"); $html = $html . BuildRow($users, $ini->_params["ARTICA_WATCHDOG"], "{APP_ARTICA_WATCHDOG}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_STATUS"], "{APP_ARTICA_STATUS}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_EXECUTOR"], "{APP_ARTICA_EXECUTOR}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_BACKGROUND"], "{APP_ARTICA_BACKGROUND}"); $html = $html . BuildRow($users, $ini->_params["APP_SYSLOGER"], "{APP_SYSLOGER}"); $html = $html . BuildRow($users, $ini->_params["SASLAUTHD"], "{APP_SASLAUTHD}"); $html = $html . BuildRow($users, $ini->_params["BOA"], "{APP_BOA}"); $html = $html . BuildRow($users, $ini->_params["FRAMEWORK"], "{APP_FRAMEWORK}"); $html = $html . BuildRow($users, $ini->_params["APP_APACHE_SRC"], "{APP_APACHE_SRC}"); $html = $html . BuildRow($users, $ini->_params["APP_TOMCAT"], "{APP_TOMCAT}"); $html = $html . BuildRow($users, $ini->_params["APP_GROUPWARE_APACHE"], "{APP_GROUPWARE_APACHE}"); $html = $html . BuildRow($users, $ini->_params["LDAP"], "{APP_LDAP}"); $html = $html . BuildRow($users, $ini->_params["ARTICA_MYSQL"], "{APP_MYSQL_ARTICA}"); $html = $html . BuildRow($users, $ini->_params["APP_GREENSQL"], "{APP_GREENSQL}"); $html = $html . BuildRow($users, $ini->_params["APP_PDNS"], "{APP_PDNS}"); $html = $html . BuildRow($users, $ini->_params["APP_PDNS_INSTANCE"], "{APP_PDNS_INSTANCE}"); $html = $html . BuildRow($users, $ini->_params["PDNS_RECURSOR"], "{APP_PDNS_RECURSOR}"); $html = $html . BuildRow($users, $ini->_params["DNSMASQ"], "{APP_DNSMASQ}"); $html = $html . BuildRow($users, $ini->_params["APP_DDCLIENT"], "{APP_DDCLIENT}"); $html = $html . BuildRow($users, $ini->_params["BIND9"], "{APP_BIND9}"); $html = $html . BuildRow($users, $ini->_params["DHCPD"], "{APP_DHCP}"); $html = $html . BuildRow($users, $ini->_params["APP_NSCD"], "{APP_NSCD}"); $html = $html . BuildRow($users, $ini->_params["APP_ARPD"], "{APP_ARPD}"); if (!$users->KASPERSKY_WEB_APPLIANCE) { $html = $html . BuildRow($users, $ini->_params["CLAMAV"], "{APP_CLAMAV}"); $html = $html . BuildRow($users, $ini->_params["FRESHCLAM"], "{APP_FRESHCLAM}"); } $html = $html . BuildRow($users, $ini->_params["APP_SNORT"], "{APP_SNORT}"); while (list($key, $array) = each($ini->_params)) { if (preg_match("#APP_SNORT:(.+)#", $key, $re)) { $html = $html . BuildRow($users, $ini->_params[$key], "{APP_SNORT}", $re[1]); } } reset($ini->_params); $html = $html . BuildRow($users, $ini->_params["APP_KAV4FS"], "{APP_KAV4FS}"); $html = $html . BuildRow($users, $ini->_params["APP_KAV4FS_AVS"], "{APP_KAV4FS_AVS}"); $html = $html . BuildRow($users, $ini->_params["APP_OCSI"], "{APP_OCSI}"); $html = $html . BuildRow($users, $ini->_params["APP_OCSI_DOWNLOAD"], "{APP_OCSI_DOWNLOAD}"); $html = $html . BuildRow($users, $ini->_params["APP_OCSI_LINUX_CLIENT"], "{APP_OCSI_LINUX_CLIENT}"); $html = $html . BuildRow($users, $ini->_params["KRETRANSLATOR_HTTPD"], "{APP_KRETRANSLATOR_HTTPD}"); $html = $html . BuildRow($users, $ini->_params["SYSLOGNG"], "{APP_SYSLOGNG}"); $html = $html . BuildRow($users, $ini->_params["APP_OPENSSH"], "{APP_OPENSSH}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_AUTH_TAIL"], "{APP_ARTICA_AUTH_TAIL}"); $html = $html . BuildRow($users, $ini->_params["COLLECTD"], "{APP_COLLECTD}"); $html = $html . BuildRow($users, $ini->_params["SMARTD"], "{APP_SMARTMONTOOLS}"); $html = $html . BuildRow($users, $ini->_params["APP_AUDITD"], "{APP_AUDITD}"); $html = $html . BuildRow($users, $ini->_params["APP_VNSTAT"], "{APP_VNSTAT}"); $html = $html . BuildRow($users, $ini->_params["APP_ZABBIX_SERVER"], "{APP_ZABBIX_SERVER}"); $html = $html . BuildRow($users, $ini->_params["APP_ZABBIX_AGENT"], "{APP_ZABBIX_AGENT}"); $html = $html . BuildRow($users, $ini->_params["IPTABLES"], "{APP_IPTABLES}"); $html = $html . BuildRow($users, $ini->_params["APP_AMACHI"], "{APP_AMACHI}"); $html = $html . BuildRow($users, $ini->_params["NTPD"], "{APP_NTPD}"); $html = $html . BuildRow($users, $ini->_params["APP_AUTOFS"], "{APP_AUTOFS}"); $html = $html . BuildRow($users, $ini->_params["APP_NFS"], "{APP_NFS}"); $html = $html . BuildRow($users, $ini->_params["PRELOAD"], "{APP_PRELOAD}"); $html = $html . BuildRow($users, $ini->_params["CONSOLEKIT"], "{APP_CONSOLEKIT}"); $html = $html . BuildRow($users, $ini->_params["GDM"], "{APP_GDM}"); $html = $html . BuildRow($users, $ini->_params["XFCE"], "{APP_XFCE}"); $html = $html . BuildRow($users, $ini->_params["INETD"], "{APP_INETD}"); $html = $html . BuildRow($users, $ini->_params["APP_RSYNC"], "{APP_RSYNC}"); $html = $html . BuildRow($users, $ini->_params["OBM2"], "{APP_OBM2}"); $html = $html . BuildRow($users, $ini->_params["DOTCLEAR"], "{APP_DOTCLEAR}"); $html = $html . BuildRow($users, $ini->_params["PUREFTPD"], "{APP_PUREFTPD}"); $html = $html . BuildRow($users, $ini->_params["APP_MLDONKEY"], "{APP_MLDONKEY}"); $html = $html . BuildRow($users, $ini->_params["APP_DROPBOX"], "{APP_DROPBOX}"); $html = $html . BuildRow($users, $ini->_params["APP_SABNZBDPLUS"], "{APP_SABNZBDPLUS}"); $html = $html . "</table></div>"; $html_A = $html; } if ($_GET["section"] == "postfix_services") { if ($users->POSTFIX_INSTALLED) { $EnablePostfixMultiInstance = $sock->GET_INFO("EnablePostfixMultiInstance"); $html = "\n\t\t\t\t<div style='heigth:550px;overflow:auto'>\n\t\t\t\t<table style='width:98%;margin:0px;padding:5px;'>{$table_header}"; $html = $html . BuildRow($users, $ini->_params["POSTFIX"], "{APP_POSTFIX}"); if ($EnablePostfixMultiInstance == 1) { reset($ini->_params); while (list($key, $array) = each($ini->_params)) { if (preg_match("#POSTFIX-MULTI-(.+)#", $key, $re)) { $html = $html . BuildRow($users, $ini->_params["{$key}"], "{APP_POSTFIX}", $re[1]); } if (preg_match("#APP_CROSSROADS:(.+)#", $key, $re)) { $html = $html . BuildRow($users, $ini->_params["{$key}"], "{APP_CROSSROADS}", $re[1]); } } } reset($ini->_params); while (list($key, $array) = each($ini->_params)) { if (preg_match("#APP_POSTFWD2:(.+)#", $key, $re)) { $html = $html . BuildRow($users, $ini->_params[$key], "{APP_POSTFWD2}", $re[1]); } } reset($ini->_params); $html = $html . BuildRow($users, $ini->_params["APP_CROSSROADS"], "{APP_CROSSROADS}"); $html = $html . BuildRow($users, $ini->_params["ARTICA_MYSQMAIL"], "{APP_ARTICA_MYSQMAIL}"); $html = $html . BuildRow($users, $ini->_params["APP_POSTFILTER"], "{APP_POSTFILTER}"); $html = $html . BuildRow($users, $ini->_params["JCHECKMAIL"], "{APP_JCHECKMAIL}"); $html = $html . BuildRow($users, $ini->_params["MILTER_GREYLIST"], "{APP_MILTERGREYLIST}"); $html = $html . BuildRow($users, $ini->_params["ASSP"], "{APP_ASSP}"); $html = $html . BuildRow($users, $ini->_params["AMAVISD"], "{APP_AMAVISD_NEW}"); $html = $html . BuildRow($users, $ini->_params["AMAVISD_MILTER"], "{APP_AMAVISD_MILTER}"); $html = $html . BuildRow($users, $ini->_params["APP_CLUEBRINGER"], "{APP_CLUEBRINGER}"); $html = $html . BuildRow($users, $ini->_params["APP_OPENDKIM"], "{APP_OPENDKIM}"); $html = $html . BuildRow($users, $ini->_params["APP_MILTER_DKIM"], "{APP_MILTER_DKIM}"); $html = $html . BuildRow($users, $ini->_params["MAILARCHIVER"], "{APP_MAILARCHIVER}"); $html = $html . BuildRow($users, $ini->_params["DKIM_FILTER"], "{APP_DKIM_FILTER}"); $html = $html . BuildRow($users, $ini->_params["MIMEDEFANG"], "{APP_MIMEDEFANG}"); $html = $html . BuildRow($users, $ini->_params["MIMEDEFANGX"], "{APP_MIMEDEFANGX}"); $html = $html . BuildRow($users, $ini->_params["CLAMAV_MILTER"], "{APP_CLAMAV_MILTER}"); $html = $html . BuildRow($users, $ini->_params["MAILFROMD"], "{APP_MAILFROMD}"); $html = $html . BuildRow($users, $ini->_params["SQLGREY"], "{APP_SQLGREY}"); $html = $html . BuildRow($users, $ini->_params["SPAMASS_MILTER"], "{APP_SPAMASS_MILTER}"); $html = $html . BuildRow($users, $ini->_params["SPAMASSASSIN"], "{APP_SPAMASSASSIN}"); $html = $html . BuildRow($users, $ini->_params["KAVMILTER"], "{APP_KAVMILTER}"); $html = $html . BuildRow($users, $ini->_params["KAS3"], "{APP_KAS3}"); $html = $html . BuildRow($users, $ini->_params["KAS_MILTER"], "{APP_KAS3_MILTER}"); $html = $html . BuildRow($users, $ini->_params["MAILMAN"], "{APP_MAILMAN}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_POLICY"], "{APP_ARTICA_POLICY}"); $html = $html . BuildRow($users, $ini->_params["STUNNEL"], "{APP_STUNNEL}"); $html = $html . "</table></div>"; $html_B = $html; } } if ($_GET["section"] == "squid_services") { if ($users->SQUID_INSTALLED) { $html = "<table style='width:98%;margin:0px;padding:5px;'>{$table_header}"; $html = $html . BuildRow($users, $ini->_params["SQUID"], "{APP_SQUID}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_SQUID_TAIL"], "{APP_ARTICA_SQUID_TAIL}"); $html = $html . BuildRow($users, $ini->_params["APP_SQUID_CLAMAV_TAIL"], "{APP_SQUID_CLAMAV_TAIL}"); $html = $html . BuildRow($users, $ini->_params["KAV4PROXY"], "{APP_KAV4PROXY}"); $html = $html . BuildRow($users, $ini->_params["DANSGUARDIAN"], "{APP_DANSGUARDIAN}"); $html = $html . BuildRow($users, $ini->_params["ARTICA_DANS_TAIL"], "{APP_ARTICA_DANSGUARDIAN_TAIL}"); $html = $html . BuildRow($users, $ini->_params["APP_PROXY_PAC"], "{APP_PROXY_PAC}"); $html = $html . BuildRow($users, $ini->_params["APP_SQUIDGUARD_HTTP"], "{APP_SQUIDGUARD_HTTP}"); $html = $html . BuildRow($users, $ini->_params["APP_ARTICA_SQUIDGUARDTAIL"], "{APP_ARTICA_SQUIDGUARDTAIL}"); $html = $html . BuildRow($users, $ini->_params["APP_UFDBGUARD"], "{APP_UFDBGUARD}"); $html = $html . BuildRow($users, $ini->_params["APP_UFDBGUARD_TAIL"], "{APP_UFDBGUARD_TAIL}"); $html = $html . "</table></div>"; $html_C = $html; } } if ($_GET["section"] == "mail_services") { $html = "\n\t\t<div style='heigth:550px;overflow:auto'>\n\t\t<table style='width:98%;margin:0px;padding:5px;'>{$table_header}"; $html = $html . BuildRow($users, $ini->_params["CYRUSIMAP"], "{APP_CYRUS}"); $html = $html . BuildRow($users, $ini->_params["ROUNDCUBE"], "{APP_ROUNDCUBE}"); $arrayZarafa[] = "APP_ZARAFA"; $arrayZarafa[] = "APP_ZARAFA_GATEWAY"; $arrayZarafa[] = "APP_ZARAFA_SPOOLER"; $arrayZarafa[] = "APP_ZARAFA_WEB"; $arrayZarafa[] = "APP_ZARAFA_MONITOR"; $arrayZarafa[] = "APP_ZARAFA_DAGENT"; $arrayZarafa[] = "APP_ZARAFA_ICAL"; $arrayZarafa[] = "APP_ZARAFA_INDEXER"; $arrayZarafa[] = "APP_ZARAFA_LICENSED"; while (list($num, $ligne) = each($arrayZarafa)) { $html = $html . BuildRow($users, $ini->_params[$ligne], "{{$ligne}}"); } $html = $html . BuildRow($users, $ini->_params["FETCHMAIL"], "{APP_FETCHMAIL}"); $html = $html . BuildRow($users, $ini->_params["FETCHMAIL_LOGGER"], "{APP_FETCHMAIL_LOGGER}"); $html = $html . BuildRow($users, $ini->_params["P3SCAN"], "{APP_P3SCAN}"); $html = $html . BuildRow($users, $ini->_params["OBM_APACHE"], "{APP_OBM_APACHE}"); $html = $html . "</table></div>"; $html_D = $html; } if ($_GET["section"] == "samba_services") { if ($users->SAMBA_INSTALLED) { $html = "\n\t\t\t<div style='heigth:550px;overflow:auto'>\n\t\t\t<table style='width:98%;margin:0px;padding:5px;'>{$table_header}"; $html = $html . BuildRow($users, $ini->_params["SAMBA_SMBD"], "{APP_SAMBA_SMBD}"); $html = $html . BuildRow($users, $ini->_params["SAMBA_NMBD"], "{APP_SAMBA_NMBD}"); $html = $html . BuildRow($users, $ini->_params["SAMBA_WINBIND"], "{APP_SAMBA_WINBIND}"); $html = $html . BuildRow($users, $ini->_params["APP_GREYHOLE"], "{APP_GREYHOLE}"); $html = $html . BuildRow($users, $ini->_params["APP_AUDITD"], "{APP_AUDITD}"); $html = $html . BuildRow($users, $ini->_params["SAMBA_SCANNEDONLY"], "{APP_SCANNED_ONLY}"); $html = $html . BuildRow($users, $ini->_params["KAV4SAMBA"], "{APP_KAV4SAMBA}"); $html = $html . BuildRow($users, $ini->_params["APP_KAV4FS"], "{APP_KAV4FS}"); $html = $html . BuildRow($users, $ini->_params["APP_KAV4FS_AVS"], "{APP_KAV4FS_AVS}"); $html = $html . BuildRow($users, $ini->_params["CUPS"], "{APP_CUPS}"); $html = $html . BuildRow($users, $ini->_params["APP_MLDONKEY"], "{APP_MLDONKEY}"); $html = $html . BuildRow($users, $ini->_params["APP_BACKUPPC"], "{APP_BACKUPPC}"); $html = $html . BuildRow($users, $ini->_params["APP_OCSI"], "{APP_OCSI}"); $html = $html . BuildRow($users, $ini->_params["APP_OCSI_DOWNLOAD"], "{APP_OCSI_DOWNLOAD}"); $html = $html . BuildRow($users, $ini->_params["APP_DROPBOX"], "{APP_DROPBOX}"); $html = $html . BuildRow($users, $ini->_params["APP_OPENSSH"], "{APP_OPENSSH}"); $html = $html . BuildRow($users, $ini->_params["APP_SABNZBDPLUS"], "{APP_SABNZBDPLUS}"); $html = $html . "</table></div>"; $html_F = $html; } } $artica_services = "{$html_A}<br>"; $postfix_services = "{$html_B}<br>"; $mail_services = "{$html_D}<br>"; $samba_services = "{$html_F}<br>"; $squid_services = "{$html_C}<br>"; switch ($_GET["section"]) { case "artica_services": $services = $artica_services; break; case "postfix_services": $services = $postfix_services; break; case "mail_services": $services = $mail_services; break; case "samba_services": $services = $samba_services; break; case "squid_services": $services = $squid_services; break; default: $services = $artica_services; break; } $html_E = "\n\t<input type='hidden' name='service_switch' id='service_switch' value='{$_GET["section"]}'>\n\t</center>\n\t\t{$services}\n\t</center>"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html_E); }
function PostfixAutoBlockCompileCheck() { $ini = new Bs_IniHandler(); $ini->loadFile("ressources/logs/compile.iptables.progress"); $pourc = $ini->get("PROGRESS", "pourc"); $text = $ini->get("PROGRESS", "text"); $color = "#5DD13D"; $html = "\n<center>\n<div style='width:96%;text-align:center;font-size:12px;font-weight:bold;margin:5px;background-color:white;padding:5px;border:1px solid #CCCCCC'>\n\t<div style='width:95%;text-align:center;font-size:12px;font-weight:bold;margin:5px'>{$text}</div>\n\t<div style='width:100%;border:1px dotted #CCCCCC'>\n\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color};'>\n\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}%</strong></center>\n\t</div>\n\t</div>\n</div>\n</center>\n"; $html = RoundedLightWhite($html); $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html, "postfix.index.php"); }
function SERVICES_STATUS() { $users = new usersMenus(); if (!$users->AsSystemAdministrator) { return; } $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/global.status.ini"); $err = array(); $errT = array(); $c = 0; while (list($key, $array) = each($ini->_params)) { $service_name = $array["service_name"]; $service_disabled = intval($array["service_disabled"]); if ($service_disabled == 0) { continue; } $running = intval($array["running"]); $c++; if ($running == 0) { if ($key == "APP_INFLUXDB") { if (recheck_service("APP_INFLUXDB")) { continue; } } $service_cmd = $array["service_cmd"]; if ($service_cmd != null) { $js = "Loadjs('system.services.cmd.php?APPNAME={$array["service_name"]}&action=start&cmd={$service_cmd}&appcode={$key}')"; } if ($key == "SQUID") { $js = "Loadjs('squid.start.progress.php');"; } if ($key == "APP_INFLUXDB") { $js = "Loadjs('infludb.start.progress.php');"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{{$service_name}} {stopped}", "{{$service_name}} {stopped}", $js); } } if ($c > 0) { $GoToServices = "GoToServices()"; $GoToServices_underline = "underline"; $CountDeServices = "<tr>\n\t\t<td style='font-size:20px'><a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GoToServices};\" style='text-decoration:{$GoToServices_underline}'>{services}: {$c}</a></td>\n\t\t</tr>"; return $CountDeServices; } return $err; }
function squid_frontend_status() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $TITLE_REQUESTS = null; $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); if (!is_numeric($SquidCacheLevel)) { $SquidCacheLevel = 4; } $LogsWarninStop = $sock->GET_INFO("LogsWarninStop"); if ($LogsWarninStop == 1) { echo FATAL_ERROR_SHOW_128("<div style='font-size:20px'>{squid_logs_urgency}</div>\n\t\t\t\t<div style='text-align:right;font-size:22px;text-align:right;text-decoration:underline;margin-top:20px'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('system.log.emergency.php')\">{squid_logs_urgency_section}</a>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t"); } $squid5mn = unserialize(base64_decode($sock->getFrameWork("squid.php?5mncounter=yes"))); //$realMemory=unserialize(base64_decode($sock->getFrameWork("services.php?realMemory=yes"))); $CounterInfos = unserialize(base64_decode($sock->getFrameWork("squid.php?CounterInfos=yes"))); $StorageCapacity = unserialize(base64_decode($sock->getFrameWork("squid.php?StorageCapacity=yes"))); $SquidMonitorParms = unserialize(base64_decode($sock->GET_INFO("SquidMonitorParms"))); $t = time(); $server_all_kbytes_in = $SquidMonitorParms["server_all_kbytes_in"]; $server_all_kbytes_out = $SquidMonitorParms["server_all_kbytes_out"]; $HttpRequests = $SquidMonitorParms["HttpRequests"]; $ActiveRequests = $SquidMonitorParms["ActiveRequests"]; $TITLE_USERS = null; $TITLE_COMPUTERS = null; $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth")); if ($EnableKerbAuth == 1) { include_once dirname(__FILE__) . "/ressources/class.external.ad.inc"; $ldap = new external_ad_search(); $NET_RPC_INFOS = $ldap->NET_RPC_INFOS(); $NumBerOfUsers = intval($NET_RPC_INFOS["Num users"]); if ($NumBerOfUsers > 0) { $TITLE_USERS = " | <a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:AnimateDiv('BodyContent');LoadAjax('BodyContent','squid.adker.php?tabs=yes');\" \n\t\t\tstyle='text-decoration:underline'>{$NumBerOfUsers} {members}</a>"; } } $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(MAC) as tcount FROM (SELECT MAC FROM UserAutDB GROUP BY MAC) as t")); $Nodes = $ligne["tcount"]; if ($Nodes > 0) { $TITLE_COMPUTERS = " | <a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.computer-browse.php')\"\n\t\tstyle='text-decoration:underline'>{$Nodes} {computers}</a>"; } $CACHES_RATES = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/TOTAL_CACHED")); $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]); $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]); $TOTALS_DOWNLOAD = $TOTALS_NOT_CACHED + $TOTALS_CACHED; $TOTALS_NOT_CACHED = intval(@file_get_contents("/usr/share/artica-postfix/ressources/logs/stats/NOT_CACHED")); if ($TOTALS_NOT_CACHED > 0) { $TOTALS_NOT_CACHED_TEXT = " | <a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('admin.index.loadvg.squid.notcached-week.php');\"\n\t\tstyle='text-decoration:underline;font-weight:bold'>{not_cached_this_week}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>"; } $Status_cache = " | {downloaded} " . FormatBytes($TOTALS_DOWNLOAD / 1024) . " | {cached}:" . FormatBytes($TOTALS_CACHED / 1024) . $TOTALS_NOT_CACHED_TEXT; $RATE = $TOTALS_CACHED / $TOTALS_DOWNLOAD * 100; $RATE = round($RATE, 1); $TITLE_RATE = " | {cache_rate} <strong>{$RATE}%</strong>"; if (!is_numeric($server_all_kbytes_in)) { $server_all_kbytes_in = 1000; } if (!is_numeric($server_all_kbytes_out)) { $server_all_kbytes_out = 250; } if (!is_numeric($HttpRequests)) { $HttpRequests = 150; } if (!is_numeric($ActiveRequests)) { $ActiveRequests = 150; } if (!isset($squid5mn["cpu_usage"])) { $squid5mn["cpu_usage"] = 0; } $squid5mn["cpu_usage"] = round($squid5mn["cpu_usage"], 2); $squid5mn["client_http.requests"] = round($squid5mn["client_http.requests"], 2); $squid5mn["server.all.kbytes_in"] = round($squid5mn["server.all.kbytes_in"], 2); $squid5mn["server.all.kbytes_out"] = round($squid5mn["server.all.kbytes_out"], 2); $ActiveRequestsR = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/active_requests.inc")); $ActiveRequestsNumber = count($ActiveRequestsR["CON"]); $ActiveRequestsIpaddr = count($ActiveRequestsR["IPS"]); $ActiveRequestsMembers = count($ActiveRequestsR["USERS"]); if ($ActiveRequestsNumber > 0) { $TITLE_REQUESTS = " | <a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.active.requests.php')\"\n\t\tstyle='text-decoration:underline'>{$ActiveRequestsNumber} {active_requests}</a>"; } if (!is_numeric($ActiveRequestsNumber)) { $ActiveRequestsNumber = 0; } if (!is_numeric($ActiveRequestsIpaddr)) { $ActiveRequestsIpaddr = 0; } if (!is_numeric($ActiveRequestsMembers)) { $ActiveRequestsMembers = 0; } $server_all_kbytes_in_text = $tpl->javascript_parse_text("{server_all_kbytes_in}"); $server_all_kbytes_out_text = $tpl->javascript_parse_text("{server_all_kbytes_out}"); $active_requests = $tpl->javascript_parse_text("{active_requests}"); $proxy_status = $tpl->javascript_parse_text("{proxy_status}"); $second = $tpl->javascript_parse_text("{second}"); $requests = $tpl->javascript_parse_text("{requests}"); $countStorages = count($StorageCapacity); for ($i = 0; $i < $countStorages; $i++) { $tS[] = "<div id='squid-s{$i}-{$t}' style='width:160px; height:100px'>"; $js[] = " var s{$i} = new JustGage({\n\t\tid: 'squid-s{$i}-{$t}',\n\t\tvalue: {$StorageCapacity[$i]},\n\t\tmin: 0,\n\t\tmax: 100,\n\t\ttitle: 'Storage Capacity Kid " . ($i + 1) . "',\n\t\tlabel: '%',\n\t\tlevelColorsGradient: true\n\t}); "; } $storages = CompileTr4($tS, true, null, true); $ini = new Bs_IniHandler(); $color = "black"; $ini->loadFile("/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS"); if ($ini->_params["SQUID"]["running"] == 0) { $color = "#d32d2d"; $status = "{stopped}"; } else { if ($ini->_params["SQUID"]["master_time"]) { $status2 = " {running} {since} " . distanceOfTimeInWords($ini->_params["SQUID"]["master_time"], time()); } } $version = @file_get_contents("/usr/share/artica-postfix/ressources/databases/SQUID.version"); if ($version != null) { $version = " v.{$version}"; } if ($SquidCacheLevel == 0) { $nocache = " <span style='color:#d32d2d'>{no_cached_sites_warn}</span>"; } $squi1_text = $tpl->javascript_parse_text("{monitor}"); $squi1_onmouse = "OnMouseOver=\"javascript:AffBulle('{$squi1_text}');this.style.cursor='pointer'\" OnMouseOut=\"javascript:HideBulle();this.style.cursor='default'\""; $squi1_onClick = "OnClick=\"javascript:Loadjs('squid.task.monitor.php')\""; echo $tpl->_ENGINE_parse_body("\n<table style='width:99%' >\n\t<tr>\n\t\t<td colspan=4 style='font-size:22px'>\n\t\t\t<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:LoadAjax('BodyContent','squid.caches.status.php?tabs=yes')\" \n\t\t\tstyle='text-decoration:underline;color:{$color}'>{$proxy_status} {$status} {$version}</a>\n\t\t\t{$TITLE_RATE}{$TITLE_USERS}{$TITLE_REQUESTS}{$TITLE_COMPUTERS}\n\t\t\t<br>\n\t\t\t<div style='font-size:11px'><i>{$status2}{$nocache}{$Status_cache}</i></div>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t\t<td valign='top' width=25%>\n\t\t\t\t<div id='squid-1-{$t}' style='width:160px; height:100px' {$squi1_onmouse} {$squi1_onClick}></div>\n\t\t\t\n\t\t\t</td>\n\t\t\t<td valign='top' width=25%><div id='squid-2-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-3-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-4-{$t}' style='width:170px; height:100px'></div></td>\n\t</tr>\n\t\n</table>{$storages}\n\t\t\t\n" . "<div style='text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjaxTiny('squid-front-end-status','{$page}?squid-front-end-status=yes');") . "</div>\n<script>\nvar g = new JustGage({\n\tid: 'squid-1-{$t}',\n\tvalue: {$squid5mn["cpu_usage"]},\n\tmin: 0.1,\n\tmax: 100,\n\ttitle: 'Proxy CPU Usage',\n\tlabel: '%',\n\tlevelColorsGradient: true\n});\n\t\nvar g2 = new JustGage({\n\tid: 'squid-2-{$t}',\n\tvalue: {$squid5mn["client_http.requests"]},\n\tmin: 0.1,\n\tmax: {$HttpRequests},\n\ttitle: 'HTTP {$requests}/{$second}',\n\tlabel: 'RQ/s',\n\tlevelColorsGradient: true\n});\n\nvar g3 = new JustGage({\n\tid: 'squid-3-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_in"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_in},\n\ttitle: '{$server_all_kbytes_in_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n\t});\nvar g4 = new JustGage({\n\tid: 'squid-4-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_out"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_out},\n\ttitle: '{$server_all_kbytes_out_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n});\n" . @implode("\n", $js) . "\nif(document.getElementById('squid-rttrqs-status')){\n\tLoadAjaxSilent('squid-rttrqs-status','admin.index.loadavg.squidrtt.php');\n}\n\n\t</script>\n\t"); }
function orangefr_popup() { $sasl = new smtp_sasl_password_maps(); $domain = new DomainsTools(); $ISP = $_GET["isp"]; $ini = new Bs_IniHandler(); $ldap = new clladp(); $ini->loadFile("ressources/databases/isp.defaults.settings.conf"); $default_server = $ini->_params[$ISP]["default_server"]; $default_port = $ini->_params[$ISP]["default_port"]; $serverstring = $domain->transport_maps_implode($default_server, $default_port, null, "no"); $auth = $ldap->sasl_relayhost($default_server); if ($auth != null) { if (preg_match('#(.+?):(.+)#', $auth, $re)) { $username = $re[1]; $password = $re[2]; } } $tpl = new templates(); $isp_server_address_label = $tpl->_ENGINE_parse_body('{isp_server_address}'); $isp_server_port_label = $tpl->_ENGINE_parse_body('{isp_server_port}'); if (strlen($isp_server_address_label) > 25) { $isp_server_address_label = texttooltip(substr($isp_server_address_label, 0, 22) . '...', $isp_server_address_label, null, 1); } if (strlen($isp_server_port_label) > 25) { $isp_server_port_label = texttooltip(substr($isp_server_port_label, 0, 22) . '...', $isp_server_port_label, null, 1); } $page = CurrentPageName(); $text = "\n\t<div id='anim'></div>\n\t<p class=caption style='font-size:12px'>{please_verify_addressisp}</p>\n\t<strong style='font-size:13px'>{technical_address}:<code>{$serverstring}</code></strong><br>\n\t<form name='FFMISPRELAY'>\n\t<table style='width:100%;background-color:#FFFFFF;border:1px solid #CCCCCC;padding:5px'>\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{$isp_server_address_label}</td>\n\t\t\t<td>" . Field_text('isp_address', $default_server, 'width:220px;') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{$isp_server_port_label}</td>\n\t\t\t<td>" . Field_text('isp_port', $default_port, 'width:30px;') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{username}</td>\n\t\t\t<td>" . Field_text('isp_username', $username, 'width:190px;') . "</td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{password}</td>\n\t\t\t<td>" . Field_password('isp_password', $password, 'width:90px;') . "</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2> </td></tr>\n\t\t<tr>\n\t\t\t<td colspan=2 style='padding-top:4px;border-top:1px solid #CCCCCC' align='right'>\n\t\t\t" . button("{apply}", "FFMISPRELAY_SAVE()") . "\n\t\t\t\t\n\t\t\t</td\n\t\t</tr>\n\t</table>\t\n\t\n\t"; $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' width=1%><img src='img/{$ini->_params[$ISP]["default_icon"]}' style='margin:4px;padding:5px;border:1px solid #7B787E;background-color:white'></td>\n\t\t<td style='vertical-align:top'>{$text}</td>\n\t</tr>\n\t</table>\n\t<script>\t\t\n\tvar x_FFMISPRELAY_SAVE=function(obj){\n \tvar tempvalue=trim(obj.responseText);\n\t \tif(tempvalue.length>3){alert(tempvalue);}\n\t\tdocument.getElementById('anim').innerHTML='';\n\t\t}\n\t\n\t\tfunction FFMISPRELAY_SAVE(){\n\t\t\tvar XHR = new XHRConnection(); \n\t\t\tXHR.appendData('isp_address',document.getElementById('isp_address').value);\n\t\t\tXHR.appendData('isp_password',document.getElementById('isp_password').value);\n\t\t\tXHR.appendData('isp_port',document.getElementById('isp_port').value);\n\t\t\tXHR.appendData('isp_username',document.getElementById('isp_username').value);\n\t\t\tdocument.getElementById('anim').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_FFMISPRELAY_SAVE);\n\t\t}\t\t\n\t\t\n\t</script>\n\t"; echo $tpl->_ENGINE_parse_body($html); }
function build() { $users = new usersMenus(); $sock = new sockets(); $unix = new unix(); $SystemLoadNotif = $sock->GET_INFO("SystemLoadNotif"); if (!is_numeric($SystemLoadNotif)) { $SystemLoadNotif = 0; } $EnableSyslogDB = $sock->GET_INFO("EnableSyslogDB"); if (!is_numeric($EnableSyslogDB)) { $EnableSyslogDB = 0; } $MySQLSyslogType = $sock->GET_INFO("MySQLSyslogType"); if (!is_numeric($MySQLSyslogType)) { $MySQLSyslogType = 1; } $ZarafaDedicateMySQLServer = $sock->GET_INFO("ZarafaDedicateMySQLServer"); if (!is_numeric($ZarafaDedicateMySQLServer)) { $ZarafaDedicateMySQLServer = 0; } $ini = new Bs_IniHandler(); $ini->loadFile('/etc/artica-postfix/smtpnotif.conf'); if (!is_numeric($ini->_params["SMTP"]["EnableNotifs"])) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } if (!is_numeric($ini->_params["SMTP"]["tls_enabled"])) { $ini->_params["SMTP"]["tls_enabled"] = 0; } $smtp_server = trim($ini->_params["SMTP"]['smtp_server_name']); $smtp_server_port = $ini->_params["SMTP"]['smtp_server_port']; $smtp_dest = $ini->_params["SMTP"]['smtp_dest']; $smtp_sender = $ini->_params["SMTP"]['smtp_sender']; $smtp_auth_user = $ini->_params["SMTP"]['smtp_auth_user']; $smtp_auth_passwd = $ini->_params["SMTP"]['smtp_auth_passwd']; $tls_enabled = $ini->_params["SMTP"]["tls_enabled"]; $recipientsZ = explode("\n", "/etc/artica-postfix/settings/Daemons/SmtpNotificationConfigCC"); $recipients = array(); while (list($index, $to) = each($recipientsZ)) { if (trim($to) == null) { continue; } $recipients[] = $to; } if ($smtp_server == null) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } if ($smtp_dest == null) { if (count($recipients) == 0) { $ini->_params["SMTP"]["EnableNotifs"] = 0; } } if (!is_numeric($smtp_server_port)) { $smtp_server_port = 25; } $EnableNotifs = $ini->_params["SMTP"]["EnableNotifs"]; $monit_not_on = 'instance,action'; $f[] = 'set daemon 60 with start delay 5'; $f[] = 'set idfile /var/run/monit/monit.id'; $cpunum = $unix->CPU_NUMBER(); $normal = $cpunum * 2 + 1; $normal2 = $cpunum * 2; $busy = $cpunum * 4; $EnableMONITSmtpNotif = $sock->GET_INFO("EnableMONITSmtpNotif"); if (!is_numeric($EnableMONITSmtpNotif)) { $EnableMONITSmtpNotif = 1; } $EnableWatchMemoryUsage = $sock->GET_INFO("EnableWatchMemoryUsage"); if (!is_numeric($EnableWatchMemoryUsage)) { $EnableWatchMemoryUsage = 1; } $EnableWatchCPUsage = $sock->GET_INFO("EnableWatchCPUsage"); if (!is_numeric($EnableWatchCPUsage)) { $EnableWatchCPUsage = 1; } $SystemWatchMemoryUsage = $sock->GET_INFO("SystemWatchMemoryUsage"); if (!is_numeric($SystemWatchMemoryUsage)) { $SystemWatchMemoryUsage = 75; } $EnableWatchCPUsage = $sock->GET_INFO("EnableWatchCPUsage"); if (!is_numeric($EnableWatchCPUsage)) { $EnableWatchCPUsage = 1; } $SystemWatchCPUUser = $sock->GET_INFO("SystemWatchCPUUser"); if (!is_numeric($SystemWatchCPUUser)) { $SystemWatchCPUUser = 80; } $SystemWatchCPUSystem = $sock->GET_INFO("SystemWatchCPUSystem"); if (!is_numeric($SystemWatchCPUSystem)) { $SystemWatchCPUSystem = 80; } $EnableLoadAvg1mnUser = $sock->GET_INFO("EnableLoadAvg1mnUser"); if (!is_numeric($EnableLoadAvg1mnUser)) { $EnableLoadAvg1mnUser = 1; } $EnableLoadAvg5mnUser = $sock->GET_INFO("EnableLoadAvg5mnUser"); if (!is_numeric($EnableLoadAvg5mnUser)) { $EnableLoadAvg5mnUser = 1; } $EnableLoadAvg15mnUser = $sock->GET_INFO("EnableLoadAvg15mnUser"); if (!is_numeric($EnableLoadAvg15mnUser)) { $EnableLoadAvg15mnUser = 1; } $Load1mn = $sock->GET_INFO("Load1mn"); if (!is_numeric($Load1mn)) { $Load1mn = $busy; } $Load15mn = $sock->GET_INFO("Load15mn"); if (!is_numeric($Load15mn)) { $Load15mn = $normal2; } $Load5mn = $sock->GET_INFO("Load5mn"); if (!is_numeric($Load5mn)) { $Load5mn = $normal; } $DoNotCheckSystem = 0; if ($EnableLoadAvg1mnUser == 0) { if ($EnableLoadAvg5mnUser == 0) { if ($EnableLoadAvg15mnUser == 0) { if ($EnableWatchMemoryUsage == 0) { if ($SystemLoadNotif == 0) { if ($EnableWatchCPUsage == 0) { $DoNotCheckSystem = 1; } } } } } } $php5 = $unix->LOCATE_PHP5_BIN(); $rmbin = $unix->find_program("rm"); $echo = $unix->find_program("echo"); if ($SystemWatchCPUSystem > 100) { $SystemWatchCPUSystem = 99; } if ($SystemWatchCPUUser > 100) { $SystemWatchCPUUser = 99; } if ($SystemWatchMemoryUsage > 10) { $SystemWatchMemoryUsage = 99; } if ($SystemWatchCPUSystem < 5) { $SystemWatchCPUSystem = 99; } if ($SystemWatchCPUUser < 5) { $SystemWatchCPUUser = 99; } if ($SystemWatchMemoryUsage < 5) { $SystemWatchMemoryUsage = 99; } $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } $f[] = 'set logfile syslog facility log_daemon'; $f[] = 'set statefile /var/run/monit/monit.state'; $f[] = ''; if ($EnableNotifs == 1) { if ($EnableMONITSmtpNotif == 1) { $f[] = "set mailserver {$smtp_server} PORT {$smtp_server_port}"; if (strlen($smtp_auth_user) > 0) { $f[] = "\tUSERNAME \"{$smtp_auth_user}\" PASSWORD \"{$smtp_auth_passwd}\""; } if ($tls_enabled == 1) { $f[] = "\tusing TLSV1"; } $f[] = "\tset eventqueue"; $f[] = "\tbasedir /var/monit"; $f[] = "\tslots 100"; $f[] = "\tset mail-format {"; $f[] = "\t\tfrom: {$smtp_sender}"; $f[] = "\t\tsubject: Artica service monitor: \$SERVICE \$EVENT"; $f[] = "\t\tmessage: Artica service monitor \$ACTION \$SERVICE at \$DATE on \$HOST: \$DESCRIPTION"; $f[] = "\t}"; $f[] = "set alert {$smtp_dest} but not on {{$monit_not_on}}"; if ($recipients > 0) { while (list($index, $to) = each($recipientsZ)) { $f[] = "set alert {$to} but not on {{$monit_not_on}}"; } } } } $allips = $unix->NETWORK_ALL_INTERFACES(true); $f[] = "set httpd port 2874 and use address 127.0.0.1"; $f[] = "\tallow 127.0.0.1"; while (list($tcpi, $to) = each($allips)) { $f[] = "\tallow {$tcpi}"; } $top = $unix->find_program("top"); $hostname = $unix->hostname_g(); if ($DoNotCheckSystem == 0) { $f[] = "check system " . $unix->hostname_g(); if ($SystemLoadNotif > 0) { $f[] = "\tif loadavg (1min) > {$SystemLoadNotif} then exec \"{$php5} /usr/share/artica-postfix/exec.watchdog.php --loadavg-notif\""; } if ($EnableLoadAvg1mnUser == 1) { $f[] = "\tif loadavg (1min) > {$Load1mn} for 5 cycles then alert"; } if ($EnableLoadAvg5mnUser == 1) { $f[] = "\tif loadavg (5min) > {$Load5mn} for 5 cycles then alert"; } if ($EnableLoadAvg15mnUser == 1) { $f[] = "\tif loadavg (15min) > {$Load15mn} for 5 cycles then alert"; } if ($EnableWatchMemoryUsage == 1) { $f[] = "\tif memory usage > {$SystemWatchMemoryUsage}% for 5 cycles then alert"; } if ($EnableWatchCPUsage == 1) { //$f[]="if cpu usage (user) > $SystemWatchCPUUser% for 5 cycles then exec \"/bin/bash -c '$top -b -n 1 >> /var/log/ArticaProc.log;/bin/date >> /var/log/ArticaProc.log'\""; //$f[]="if cpu usage (system) > $SystemWatchCPUSystem% for 5 cycles then exec \"/bin/bash -c '$top -b -n 1 >> /var/log/ArticaProc.log;/bin/date >> /var/log/ArticaProc.log'\""; } } $f[] = "check host loopback with address 127.0.0.1"; $f[] = "\tif failed icmp type echo with timeout 1 seconds then exec \"/bin/loopbackfailed.sh\""; $f[] = ""; $loopbackfailed[] = "#!/bin/sh"; $loopbackfailed[] = "{$php5} /usr/share/artica-postfix/exec.virtuals-ip.php --loopback"; $loopbackfailed[] = ""; @file_put_contents("/bin/loopbackfailed.sh", @implode("\n", $loopbackfailed)); @chmod("/bin/loopbackfailed.sh", 0755); $loopbackfailed = array(); //******************************************************************************************************************** $f[] = "check file php.log with path /var/log/php.log"; $f[] = "\tif size > 100 MB then"; $f[] = "\t\texec \"/bin/clean-phplog.sh\""; $f[] = ""; $f[] = "check file usrphp.log with path /usr/share/artica-postfix/ressources/logs/php.log"; $f[] = " if size > 100 MB then"; $f[] = "\t\texec \"/bin/clean-phplog.sh\""; $f[] = ""; $f[] = "include /etc/monit/conf.d/*"; @file_put_contents("/etc/monit/monitrc", @implode("\n", $f)); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/monit/monitrc done...\n"; } $AA[] = "#!/bin/sh"; $AA[] = "{$echo} \"\" >/var/log/php.log"; $AA[] = ""; @file_put_contents("/bin/clean-phplog.sh", @implode("\n", $AA)); @chmod("/bin/clean-phplog.sh", 0755); $AA = array(); $monit = new monit(); $monit->save(); $INITD_PATH = $unix->SLAPD_INITD_PATH(); $SLAPD_PID_FILE = $unix->SLAPD_PID_PATH(); $squidbin = $unix->LOCATE_SQUID_BIN(); @unlink("/etc/monit/conf.d/APP_OPENLDAP.monitrc"); //******************************************************************************************************************** $f = array(); //******************************************************************************************************************** $f = array(); $f[] = "check process APP_FRAMEWORK"; $f[] = "with pidfile /var/run/lighttpd/framework.pid"; $f[] = "start program = \"/etc/init.d/artica-framework start --monit\""; $f[] = "stop program = \"/etc/init.d/artica-framework stop --monit\""; $f[] = "if 5 restarts within 5 cycles then timeout"; @file_put_contents("/etc/monit/conf.d/articaframework.monitrc", @implode("\n", $f)); $f = array(); //******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_OPENSSH.monitrc"); @unlink("/etc/monit/conf.d/APP_MYSQLD.monitrc"); //******************************************************************************************************************** $f = array(); $f[] = "check process APP_ARTICA_STATUS with pidfile /etc/artica-postfix/exec.status.php.pid"; $f[] = "\tstart program = \"/etc/init.d/artica-status start --monit\""; $f[] = "\tstop program = \"/etc/init.d/artica-status stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Status...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ARTICASTATUS.monitrc", @implode("\n", $f)); //******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/squid.monitrc"); @unlink("/etc/monit/conf.d/APP_SQUIDMAIN.monitrc"); if (is_file($squidbin)) { if ($SQUIDEnable == 1) { $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig"))); $SquidMgrListenPort = trim($sock->GET_INFO("SquidMgrListenPort")); if (!is_numeric($MonitConfig["watchdog"])) { $MonitConfig["watchdog"] = 1; } if (!is_numeric($MonitConfig["watchdogCPU"])) { $MonitConfig["watchdogCPU"] = 95; } if (!is_numeric($MonitConfig["watchdogMEM"])) { $MonitConfig["watchdogMEM"] = 1500; } if ($MonitConfig["watchdog"] == 1) { if ($MonitConfig["watchdogMEM"] > 500) { $AVAILABLE_MEM = $unix->MEM_TOTAL_INSTALLEE(); $AVAILABLE_MEM = $AVAILABLE_MEM / 1024; $prc = $MonitConfig["watchdogMEM"] / $AVAILABLE_MEM; $prc = round($prc * 100); } $f = array(); $f[] = "check process APP_SQUID with pidfile /var/run/squid/squid.pid"; $f[] = "\tstart program = \"/etc/init.d/squid start --monit\""; $f[] = "\tstop program = \"/etc/init.d/squid stop --monit\""; if ($SquidMgrListenPort > 0) { $f[] = "\tif failed host 127.0.0.1 port {$SquidMgrListenPort} then restart"; } if ($MonitConfig["watchdogCPU"] > 60) { $f[] = "\tif cpu usage > {$MonitConfig["watchdogCPU"]}% for 5 cycles then restart"; } if ($prc > 10) { $f[] = "\tif mem usage > {$prc}% for 5 cycles then restart"; } $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Squid-Cache...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SQUIDMAIN.monitrc", @implode("\n", $f)); } } } // ******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_SQUIDDB.monitrc"); if (is_dir("/opt/squidsql/data")) { if ($SQUIDEnable == 1) { $f = array(); $f[] = "check process APP_SQUID_DB with pidfile /var/run/squid-db.pid"; $f[] = "\tstart program = \"/etc/init.d/squid-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/squid-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/mysqld/squid-db.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Squid MySQL DB...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SQUIDDB.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_DNSMASQ.monitrc"); if ($users->dnsmasq_installed) { $enabled = $sock->dnsmasq_enabled(); if ($enabled == 1) { $f[] = "check process APP_DNSMASQ with pidfile /var/run/dnsmasq.pid"; $f[] = "\tstart program = \"/etc/init.d/dnsmasq start --monit\""; $f[] = "\tstop program = \"/etc/init.d/dnsmasq stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DnsMASQ...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DNSMASQ.monitrc", @implode("\n", $f)); } } // ******************************************************************************************************************** // ******************************************************************************************************************** $f = array(); @unlink("/etc/monit/conf.d/APP_CICAP.monitrc"); if ($users->C_ICAP_INSTALLED) { if ($SQUIDEnable == 1) { $CicapEnabled = $sock->GET_INFO("CicapEnabled"); if (!is_numeric($CicapEnabled)) { $CicapEnabled = 0; } if ($CicapEnabled == 1) { $f[] = "check process APP_C_ICAP with pidfile /var/run/c-icap/c-icap.pid"; $f[] = "\tstart program = \"/etc/init.d/artica-postfix start cicap\""; $f[] = "\tstop program = \"/etc/init.d/artica-postfix stop cicap\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring C-ICAP...\n"; } @file_put_contents("/etc/monit/conf.d/APP_CICAP.monitrc", @implode("\n", $f)); } } } // ******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_SYSLOGDB.monitrc"); if ($EnableSyslogDB == 1) { if ($MySQLSyslogType == 1) { $f = array(); $f[] = "check process APP_SYSLOG_DB with pidfile /var/run/syslogdb.pid"; $f[] = "\tstart program = \"/etc/init.d/syslog-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/syslog-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/syslogdb.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring syslogd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SYSLOGDB.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_ZARAFASERVER.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAGATEWAY.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAAPACHE.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFAWEB.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFASPOOLER.monitrc"); @unlink("/etc/monit/conf.d/APP_ZARAFADB.monitrc"); if (is_file($unix->find_program("zarafa-server"))) { $ZarafaApacheEnable = $sock->GET_INFO("ZarafaApacheEnable"); if (!is_numeric($ZarafaApacheEnable)) { $ZarafaApacheEnable = 1; } $ZarafaApachePort = $sock->GET_INFO("ZarafaApachePort"); if (!is_numeric($ZarafaApachePort)) { $ZarafaApachePort = 9010; } if ($ZarafaDedicateMySQLServer == 1) { $f = array(); $f[] = "check process APP_ZARAFA_DB with pidfile /var/run/zarafa-db.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-db start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-db stop --monit\""; $f[] = "\tif failed unixsocket /var/run/mysqld/zarafa-db.sock then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Database...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFADB.monitrc", @implode("\n", $f)); } $f = array(); $f[] = "check process APP_ZARAFA_SERVER with pidfile /var/run/zarafa-server.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-server start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-server stop --monit\""; $f[] = "\tif failed unixsocket /var/run/zarafa then restart"; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Server...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFASERVER.monitrc", @implode("\n", $f)); $f = array(); $f[] = "check process APP_ZARAFA_SPOOLER with pidfile /var/run/zarafa-spooler.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-spooler start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-spooler stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Spooler...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFASPOOLER.monitrc", @implode("\n", $f)); $f = array(); $f[] = "check process APP_ZARAFA_GATEWAY with pidfile /var/run/zarafa-gateway.pid"; $f[] = "\tstart program = \"/etc/init.d/zarafa-gateway start --monit\""; $f[] = "\tstop program = \"/etc/init.d/zarafa-gateway stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Zarafa Gateway...\n"; } @file_put_contents("/etc/monit/conf.d/APP_ZARAFAGATEWAY.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** $EnableClamavDaemon = $sock->GET_INFO("EnableClamavDaemon"); $EnableClamavDaemonForced = $sock->GET_INFO("EnableClamavDaemonForced"); $CicapEnabled = $sock->GET_INFO("CicapEnabled"); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($EnableClamavDaemon)) { $EnableClamavDaemon = 0; } if (!is_numeric($EnableClamavDaemonForced)) { $EnableClamavDaemonForced = 0; } if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if (!is_numeric($CicapEnabled)) { $CicapEnabled = 0; } if ($SQUIDEnable == 1) { if ($CicapEnabled == 1) { $EnableClamavDaemon = 1; } } if ($EnableClamavDaemonForced == 1) { $EnableClamavDaemon = 1; } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_CLAMAV.monitrc"); $MasterBin = $unix->find_program("clamd"); if (is_file($MasterBin)) { if ($EnableClamavDaemon == 1) { $f = array(); $f[] = "check process APP_CLAMAV"; $f[] = "with pidfile /var/run/clamav/clamd.pid"; $f[] = "start program = \"/etc/init.d/clamav-daemon start --monit\""; $f[] = "stop program = \"/etc/init.d/clamav-daemon stop --monit\""; $f[] = "if 5 restarts within 5 cycles then timeout"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Clamd service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_CLAMAV.monitrc", @implode("\n", $f)); $f = array(); } } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/ufdb.monitrc"); @unlink("/etc/monit/conf.d/ufdbweb.monitrc"); $ufdbbin = $unix->find_program("ufdbguardd"); if (is_file($ufdbbin)) { $EnableUfdbGuard = $sock->EnableUfdbGuard(); $UseRemoteUfdbguardService = $sock->GET_INFO('UseRemoteUfdbguardService'); $EnableSquidGuardHTTPService = $sock->GET_INFO("EnableSquidGuardHTTPService"); $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); $SquidGuardApachePort = $sock->GET_INFO("SquidGuardApachePort"); $SquidGuardApacheSSLPort = $sock->GET_INFO("SquidGuardApacheSSLPort"); if (!is_numeric($UseRemoteUfdbguardService)) { $UseRemoteUfdbguardService = 0; } if (!is_numeric($EnableUfdbGuard)) { $EnableUfdbGuard = 0; } if (!is_numeric($EnableSquidGuardHTTPService)) { $EnableSquidGuardHTTPService = 1; } if (!is_numeric($EnableWebProxyStatsAppliance)) { $EnableWebProxyStatsAppliance = 0; } if ($EnableUfdbGuard == 0) { $EnableSquidGuardHTTPService = 0; } if ($EnableWebProxyStatsAppliance == 1) { $EnableSquidGuardHTTPService = 1; } if (!is_numeric($SquidGuardApachePort)) { $SquidGuardApachePort = "9020"; } if (!is_numeric($SquidGuardApacheSSLPort)) { $SquidGuardApacheSSLPort = 9025; } if ($SquidPerformance > 2) { $EnableSquidGuardHTTPService = 0; } if ($SQUIDEnable == 1) { if ($UseRemoteUfdbguardService == 0) { if ($EnableUfdbGuard == 1) { $f = array(); $f[] = "check process APP_UFDBGUARD"; $f[] = "with pidfile /var/run/urlfilterdb/ufdbguardd.pid"; $f[] = "start program = \"/etc/init.d/ufdb start --monit\""; $f[] = "stop program = \"/etc/init.d/ufdb stop --monit\""; $f[] = "if totalmem > 700 MB for 5 cycles then alert"; $f[] = "if cpu > 95% for 5 cycles then alert"; $f[] = "if 5 restarts within 5 cycles then timeout"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Web filtering service...\n"; } @file_put_contents("/etc/monit/conf.d/ufdb.monitrc", @implode("\n", $f)); } } if ($EnableSquidGuardHTTPService == 1) { $f = array(); $f[] = "check process APP_SQUIDGUARD_HTTP"; $f[] = "with pidfile /var/run/lighttpd/squidguard-lighttpd.pid"; $f[] = "start program = \"/etc/init.d/squidguard-http start --monit\""; $f[] = "stop program = \"/etc/init.d/squidguard-http stop --monit\""; $f[] = "if failed host 127.0.0.1 port {$SquidGuardApachePort} then restart"; $f[] = "if 5 restarts within 5 cycles then timeout"; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Web filtering HTTP service...\n"; } @file_put_contents("/etc/monit/conf.d/ufdbweb.monitrc", @implode("\n", $f)); } } } //******************************************************************************************************************** $EnableArticaFrontEndToNGninx = $sock->GET_INFO("EnableArticaFrontEndToNGninx"); $EnableArticaFrontEndToApache = $sock->GET_INFO("EnableArticaFrontEndToApache"); if (!is_numeric($EnableArticaFrontEndToNGninx)) { $EnableArticaFrontEndToNGninx = 0; } if (!is_numeric($EnableArticaFrontEndToApache)) { $EnableArticaFrontEndToApache = 0; } $EnableNginx = $sock->GET_INFO("EnableNginx"); $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb"); if (!is_numeric($EnableFreeWeb)) { $EnableFreeWeb = 0; } if (!is_numeric($EnableNginx)) { $EnableNginx = 1; } if ($EnableNginx == 0) { $EnableArticaFrontEndToNGninx = 0; } $pid = null; @unlink("/etc/monit/conf.d/APP_LIGHTTPD.monitrc"); if ($EnableArticaFrontEndToNGninx == 0) { $pid = "/var/run/lighttpd/lighttpd.pid"; if ($EnableArticaFrontEndToApache == 1) { $pid = "/var/run/artica-apache/apache.pid"; } $f = array(); $f[] = "check process APP_ARTICAWEBCONSOLE with pidfile {$pid}"; $f[] = "\tstart program = \"/etc/init.d/artica-webconsole start --monit\""; $f[] = "\tstop program = \"/etc/init.d/artica-webconsole stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Web Console...\n"; } @file_put_contents("/etc/monit/conf.d/APP_LIGHTTPD.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_NGINX.monitrc"); $nginx = $unix->find_program("nginx"); if (is_file($nginx)) { if ($EnableNginx == 1) { $f = array(); $f[] = "check process APP_NGINX with pidfile /var/run/nginx.pid"; $f[] = "\tstart program = \"/etc/init.d/nginx start --monit\""; $f[] = "\tstop program = \"/etc/init.d/nginx stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring NgINX...\n"; } @file_put_contents("/etc/monit/conf.d/APP_NGINX.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** $f = array(); if (is_file("/etc/init.d/sysklogd")) { $f[] = "check process APP_SYSLOGD with pidfile /var/run/syslogd.pid"; $f[] = "\tstart program = \"/etc/init.d/sysklogd start --monit\""; $f[] = "\tstop program = \"/etc/init.d/sysklogd stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = "\tcheck file syslogd_file with path /var/log/syslog"; $f[] = "\tif timestamp > 10 minutes then restart"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring sysklogd...\n"; } @file_put_contents("/etc/monit/conf.d/APP_SYSKLOGD.monitrc", @implode("\n", $f)); } //******************************************************************************************************************** $binpath = $unix->DHCPD_BIN_PATH(); @unlink("/etc/monit/conf.d/APP_DHCPD.monitrc"); $f = array(); if (is_file($binpath)) { $EnableDHCPServer = $sock->GET_INFO("EnableDHCPServer"); if (!is_numeric($EnableDHCPServer)) { $EnableDHCPServer = 0; } if ($EnableDHCPServer == 1) { $f[] = "check process APP_DHCP with pidfile /var/run/dhcpd.pid"; $f[] = "\tstart program = \"/etc/init.d/isc-dhcp-server start --monit\""; $f[] = "\tstop program = \"/etc/init.d/isc-dhcp-server stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DHCP Service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DHCPD.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** $binpath = $unix->find_program("rdpproxy"); @unlink("/etc/monit/conf.d/APP_RDPPROXY.monitrc"); $f = array(); if (is_file($binpath)) { $EnableRDPProxy = $sock->GET_INFO("EnableRDPProxy"); if (!is_numeric($EnableRDPProxy)) { $EnableRDPProxy = 0; } if ($EnableRDPProxy == 1) { $f[] = "check process APP_RDPPROXY with pidfile /var/run/redemption/rdpproxy.pid"; $f[] = "\tstart program = \"/etc/init.d/rdpproxy start --monit\""; $f[] = "\tstop program = \"/etc/init.d/rdpproxy stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring RDP Proxy...\n"; } @file_put_contents("/etc/monit/conf.d/APP_RDPPROXY.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** @unlink("/etc/monit/conf.d/APP_DNSMASQ.monitrc"); $f = array(); $binpath = $unix->find_program("dnsmasq"); if (is_file($binpath)) { $EnableDNSMASQ = $users->EnableDNSMASQ(); if ($EnableDNSMASQ == 1) { $f[] = "check process APP_DNSMASQ with pidfile /var/run/dnsmasq.pid"; $f[] = "\tstart program = \"/etc/init.d/dnsmasq start --monit\""; $f[] = "\tstop program = \"/etc/init.d/dnsmasq stop --monit\""; $f[] = "\tif 5 restarts within 5 cycles then timeout"; $f[] = ""; if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring DNSMasq Service...\n"; } @file_put_contents("/etc/monit/conf.d/APP_DNSMASQ.monitrc", @implode("\n", $f)); } } //******************************************************************************************************************** if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} checking syslog\n"; } if (is_file("/etc/init.d/syslog")) { checkDebSyslog(); } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} configuration done\n"; } shell_exec($GLOBALS["MONIT_CLASS"]->monitor_all_cmdline . " 2>&1"); }
function statusDB() { $tpl = new templates(); $page = CurrentPageName(); $users = new usersMenus(); $sock = new sockets(); $backbutton = null; if ($_GET["from-ufdbguard"] == "yes") { echo $tpl->_ENGINE_parse_body("\n\t\t\t\t<div style='margin:15px;text-align:right'>\n\t\t\t\t" . button("{back_to_webfiltering}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','dansguardian2.mainrules.php')", 18) . "\n\t\t\t\t</div>"); } $q = new mysql_catz(); $sock = new sockets(); $ini = new Bs_IniHandler(); $catz = $q->LIST_TABLES_CATEGORIES(); $sock->getFrameWork('cmd.php?squid-ini-status=yes'); $ini->loadFile("/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS"); $CATZ_ARRAY = unserialize(@file_get_contents("/home/artica/categories_databases/CATZ_ARRAY")); $date = $CATZ_ARRAY["TIME"]; $LOCAL_VERSION = $CATZ_ARRAY["TIME"]; $title = $tpl->_ENGINE_parse_body("{APP_ARTICADB}"); $q = new mysql_catz(); $LOCAL_VERSION_TEXT = $tpl->time_to_date($date); $CountDecategories = intval(@file_get_contents("/usr/share/artica-postfix/ressources/UFDB_ARTICA_COUNT")); $CountDeDatabases = intval(@file_get_contents("/usr/share/artica-postfix/ressources/UFDB_ARTICA_DBS")); if (!is_numeric($CountDecategories)) { $CountDecategories = 0; } $CountDecategories = numberFormat($CountDecategories, 0, "", " "); $APP_SQUID_DB = DAEMON_STATUS_ROUND("APP_SQUID_DB", $ini, null, 1); $APP_UFDBCAT = DAEMON_STATUS_ROUND("APP_UFDBCAT", $ini, null, 1); $DisableCategoriesDatabasesUpdates = intval($sock->GET_INFO("DisableCategoriesDatabasesUpdates")); $CategoriesDatabasesUpdatesAllTimes = intval($sock->GET_INFO("CategoriesDatabasesUpdatesAllTimes")); $CategoriesDatabasesByCron = $sock->GET_INFO("CategoriesDatabasesByCron"); if (!is_numeric($CategoriesDatabasesByCron)) { $CategoriesDatabasesByCron = 1; } $CategoriesDatabasesShowIndex = $sock->GET_INFO("CategoriesDatabasesShowIndex"); if (!is_numeric($CategoriesDatabasesShowIndex)) { $CategoriesDatabasesShowIndex = 1; } $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics"); if (!is_numeric($DisableArticaProxyStatistics)) { $DisableArticaProxyStatistics = 0; } $fbdize = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/categories-db.size.db")); $DBSIZE = FormatBytes($fbdize["DBSIZE"]); $POURC = $fbdize["POURC"]; if (is_numeric($POURC)) { $POURC_TXT = " {$POURC}% {used}"; } $p2 = Paragraphe_switch_img("{disable_udpates}", "{disable_udpates_explain}<br>{APP_ARTICADB_EXPLAIN}", "DisableCategoriesDatabasesUpdates", $DisableCategoriesDatabasesUpdates, null, 700); $p3 = Paragraphe_switch_img("{free_update_during_the_day}", "{free_update_during_the_day_explain}", "CategoriesDatabasesUpdatesAllTimes", $CategoriesDatabasesUpdatesAllTimes, null, 700); $p = Paragraphe_switch_img("{update_only_by_schedule}", "{articadb_update_only_by_schedule}", "CategoriesDatabasesByCron", $CategoriesDatabasesByCron, null, 700); $tt0[] = "<tr><td colspan=2>{$p3}</td></tr>"; $tt0[] = "<tr><td colspan=2>{$p2}</td></tr>"; $tt0[] = "<tr><td colspan=2>{$p}</td></tr>"; $tt0[] = "<tr>\n\t\t\t<td width=1%>" . Field_checkbox_design("CategoriesDatabasesShowIndex", 1, $CategoriesDatabasesShowIndex, "CategoriesDatabasesByCron()") . "</td>\n\t\t\t<td nowrap style='font-size:14px;'>:{display_update_info_index}</a></td>\n\t\t</tr>\n\t\t<tr><td colspan=2 align='right'>" . button("{apply}", "CategoriesDatabasesByCron()", 22) . "</td></tr>\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t"; /*$tt[]="<tr> <td width=1%><img src='img/arrow-right-16.png'> <td nowrap><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.catzdb.manual-update.php');\" style='font-size:14px;text-decoration:underline;'>{manual_update}</a></td> </tr>"; */ /*$tt[]="<tr> <td width=1%><img src='img/arrow-right-16.png'> <td nowrap><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.catzdb.changedir.php');\" style='font-size:14px;text-decoration:underline;'>{change_directory}</a></td> </tr>"; */ if ($DisableArticaProxyStatistics == 1) { $tt[] = "<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'>\n\t\t<td nowrap><a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:Loadjs('squid.artica.statistics.php');\"\n\t\tstyle='font-size:14px;text-decoration:underline;color:#D10000'>{ARTICA_STATISTICS} {disabled}</a></td>\n\t\t</tr>"; } else { $tt[] = "<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'>\n\t\t<td nowrap><a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:Loadjs('squid.artica.statistics.php');\"\n\t\tstyle='font-size:14px;text-decoration:underline;color:black'>{ARTICA_STATISTICS}</a></td>\n\t\t</tr>"; } $arrayV = unserialize(base64_decode($sock->getFrameWork("squid.php?articadb-nextversion=yes"))); $REMOTE_VERSION = $arrayV["TIME"]; if ($REMOTE_VERSION > $date) { $REMOTE_VERSION_TEXT = $tpl->time_to_date($REMOTE_VERSION); $newver = "\t<tr>\n\t\t<td colspan=2><div style='font-size:16px;color:#D52210'>{new_version}: {$REMOTE_VERSION} <i style='font-size:11px'>{$REMOTE_VERSION_TEXT}</i> </div></td>\n\t</tr>"; $updaebutton = "<div style='text-align:right'><hr>" . button("{update_now}", "Loadjs('squid.blacklist.upd.php')", 22) . "</div>"; } $nextcheck = $sock->getFrameWork("squid.php?articadb-nextcheck=yes"); $nextcheck = intval($nextcheck); if ($nextcheck > 0) { $nextcheck_text = "\t\n\t<tr>\n\t\t<td colspan=2><div style='font-size:16px'>{next_check_in}: {$nextcheck}Mn</div></td>\n\t</tr>"; } if ($nextcheck < 0) { $nextcheck = str_replace("-", "", $nextcheck); $nextcheckTime = time() - intval($nextcheck) * 60; $nextcheckTimeText = distanceOfTimeInWords($nextcheckTime, time()); $nextcheck_text = "\t\n\t<tr>\n\t\t<td colspan=2><div style='font-size:16px'>{last_check}: {$nextcheckTimeText}</div></td>\n\t</tr>"; } $dbsize = $sock->getFrameWork("squid.php?articadbsize=yes"); $items = numberFormat($q->COUNT_CATEGORIES(), 0, "", " "); $html = "\n\t<div style='width:98%' class=form>\n\t\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top'>{$APP_SQUID_DB}<br>{$APP_UFDBCAT}</td>\n\t<td valign='top'>\n\t<table style='width:100%'>" . @implode("\n", $tt0) . "</table>\n\t<hr>\n\t<table style='width:100%'>\n\t<tbody>\n\t<tr>\n\t\t<td colspan=2><div style='font-size:16px'>{pattern_database_version}: {$date} <i style='font-size:11px'>{$LOCAL_VERSION_TEXT}</i> {$POURC_TXT}</div></td>\n\t</tr>\n\t{$newver}\n\t{$nextcheck_text}\n\t<tr>\n\t\t<td colspan=2><div style='font-size:16px'>{categories}: {$CountDeDatabases}</a></div></td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2><div style='font-size:16px'>{categorized_websites}: \n\t\t<a href=\"javascript:Loadjs('squid.catz.php');\" style='font-size:16px;text-decoration:underline'>\n\t\t{$CountDecategories}</a> </div></td>\n\t</tr>\n\t" . @implode("", $tt) . "\n\t</tbody>\n\t</table>\n\t</td>\n\t</tr>\n\t</table>\n\t{$updaebutton}\n\t<div id='database-progress-status'></div>\n<script>\nvar xCategoriesDatabasesByCron= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>1){alert(results);}\n}\n\t\nfunction CategoriesDatabasesByCron(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('CategoriesDatabasesByCron',document.getElementById('CategoriesDatabasesByCron').value);\n\tXHR.appendData('DisableCategoriesDatabasesUpdates',document.getElementById('DisableCategoriesDatabasesUpdates').value);\n\tXHR.appendData('CategoriesDatabasesUpdatesAllTimes',document.getElementById('CategoriesDatabasesUpdatesAllTimes').value);\n\tif(document.getElementById('CategoriesDatabasesShowIndex').checked){XHR.appendData('CategoriesDatabasesShowIndex','1');}else{XHR.appendData('CategoriesDatabasesShowIndex','0');}\n\tXHR.sendAndLoad('{$page}', 'POST',xCategoriesDatabasesByCron);\n}\n\t\n\n</script>"; echo $tpl->_ENGINE_parse_body($html); }
function interface_error() { $ini = new Bs_IniHandler(); if (!is_file("/usr/share/artica-postfix/ressources/logs/interface.events")) { return null; } $ini->loadFile("/usr/share/artica-postfix/ressources/logs/interface.events"); while (list($num, $ligne) = each($ini->_params)) { if ($ini->_params[$num]["error"] == null) { continue; } $html = $html . Paragraphe("warning64.png", "{error} {$num}", $ini->_params[$num]["error"], "javascript:StopInterfaceError('{$num}')"); } events(__FUNCTION__ . "() done.."); return $html; }
function mysql_rrd() { $unix = new unix(); $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($unix->file_time_min($timefile) < 5) { die; } @file_put_contents($timefile, time()); $WORKING_DIR = "/usr/share/artica-postfix/ressources/databases/rrd"; @mkdir($WORKING_DIR, 0755, true); $rrdtool = $unix->find_program("rrdtool"); $mysqladmin = $unix->find_program("mysqladmin"); if (!is_file("{$rrdtool}")) { return; } if (!is_file("{$mysqladmin}")) { return; } $file0 = "{$WORKING_DIR}/mysql0.rrd"; $f[] = "DS:select:COUNTER:600:0:U"; $f[] = "DS:insert:COUNTER:600:0:U"; $f[] = "DS:update:COUNTER:600:0:U"; $f[] = "DS:delete:COUNTER:600:0:U"; $f[] = "DS:cache:COUNTER:600:0:U"; $f[] = "DS:total:COUNTER:600:0:U"; $f[] = "DS:connect:COUNTER:600:0:U"; $f[] = "DS:inbound:COUNTER:600:0:U"; $f[] = "DS:outbound:COUNTER:600:0:U"; $f[] = "RRA:AVERAGE:0.5:1:600"; $f[] = "RRA:AVERAGE:0.5:6:700"; $f[] = "RRA:AVERAGE:0.5:24:775"; $f[] = "RRA:AVERAGE:0.5:288:797"; $f[] = "RRA:MAX:0.5:1:600"; $f[] = "RRA:MAX:0.5:6:700"; $f[] = "RRA:MAX:0.5:24:775"; $f[] = "RRA:MAX:0.5:288:797"; $cmdlines = @implode(" ", $f); if (!is_file($file0)) { shell_exec("{$rrdtool} create {$file0} {$cmdlines}"); } $q = new mysql(); if ($q->mysql_password != null) { $pass = "******"{$q->mysql_password}\" "; } $cmd = "{$mysqladmin} --user={$q->mysql_admin} {$pass}extended-status"; exec($cmd, $results); $MYR = mysql_parsevals($results); $select = $MYR["Com_select"]; $insert = $MYR["Com_insert"]; $update = $MYR["Com_update"]; $delete = $MYR["Com_delete"]; $cache = $MYR["Qcache_hits"]; $total = $MYR["Questions"]; $connect = $MYR["Connections"]; $inbound = $MYR["Bytes_received"]; $outbound = $MYR["Bytes_sent"]; $cmdline = "{$rrdtool} update {$file0} N:{$select}:{$insert}:{$update}:{$delete}:{$cache}:{$total}:{$connect}:{$inbound}:{$outbound}"; echo $cmdline . "\n"; shell_exec($cmdline); if (!is_file("/etc/mysql-multi.cnf")) { echo "/etc/mysql-multi.cnf no such file\n"; return; } $ini = new Bs_IniHandler(); $ini->loadFile("/etc/mysql-multi.cnf"); $INSTANCES = array(); while (list($key, $line) = each($ini->_params)) { echo "F:{$key}\n"; if (preg_match("#^mysqld([0-9]+)#", $key, $re)) { $instance_id = $re[1]; $INSTANCES[$instance_id] = true; } } while (list($instance_id, $line) = each($INSTANCES)) { echo "I:{$instance_id}\n"; $pass = null; $file0 = "{$WORKING_DIR}/mysql{$instance_id}.rrd"; if (!is_file($file0)) { shell_exec("{$rrdtool} create {$file0} {$cmdlines}"); } $qA = new mysql_multi($instance_id); if ($qA->mysql_password != null) { $pass = "******"{$qA->mysql_password}\""; } $cmd = "{$mysqladmin} -S /var/run/mysqld/mysqld{$instance_id}.sock --user={$qA->mysql_admin} {$pass}extended-status"; echo "C:{$cmd}\n"; $results = array(); exec($cmd, $results); exec($cmd, $results); $MYR = mysql_parsevals($results); echo "I:{$instance_id}:" . count($MYR) . " items\n"; $select = $MYR["Com_select"]; $insert = $MYR["Com_insert"]; $update = $MYR["Com_update"]; $delete = $MYR["Com_delete"]; $cache = $MYR["Qcache_hits"]; $total = $MYR["Questions"]; $connect = $MYR["Connections"]; $inbound = $MYR["Bytes_received"]; $outbound = $MYR["Bytes_sent"]; $cmdline = "{$rrdtool} update {$file0} N:{$select}:{$insert}:{$update}:{$delete}:{$cache}:{$total}:{$connect}:{$inbound}:{$outbound}"; echo $cmdline . "\n"; shell_exec($cmdline); } }
$array["DNS Error"] = "DNS Error"; $array["Domain not found"] = "Domain not found"; $array["Error"] = "Error"; $array["Greylisting"] = "Greylisting"; $array["hostname not found"] = "hostname not found"; $array["RBL"] = "RBL"; $array["Relay access denied"] = "Relay access denied"; $array["Sended"] = "Sended"; $array["SPAM"] = "SPAM"; $array["SPAMMY"] = "SPAMMY"; $array["Mailbox unknown"] = "Mailbox unknown"; $array["User unknown in relay recipient table"] = "User unknown in relay recipient table"; $array[null] = "{all}"; $ini = new Bs_IniHandler(); if (is_file("/etc/artica-postfix/settings/Daemons/RTMMailConfig")) { $ini->loadFile("/etc/artica-postfix/settings/Daemons/RTMMailConfig"); } if ($ini->_params["ENGINE"]["LIMIT"] == null) { $ini->_params["ENGINE"]["LIMIT"] = "100"; } $maxmail = $ini->_params["ENGINE"]["LIMIT"]; $FILTERBY = $ini->_params["ENGINE"]["FILTERBY"]; $_GET["INI"] = $ini->_params; RTMevents("Building {$file} filter by {$FILTERBY}"); switch ($FILTERBY) { case "SPAM": $sql = "SELECT * FROM smtp_logs WHERE LENGTH(delivery_user)>0 AND SPAM='1' ORDER BY time_connect DESC LIMIT 0,{$ini->_params["ENGINE"]["LIMIT"]}"; $file = "last-100-mails-" . md5($FILTERBY) . ".html"; break; case "SPAMMY": $sql = "SELECT * FROM smtp_logs WHERE LENGTH(delivery_user)>0 AND spammy='1' ORDER BY time_connect DESC LIMIT 0,{$ini->_params["ENGINE"]["LIMIT"]}";
function PostfixLoadeMailsQueue() { $tpl = new templates(); $tot = $_GET["total"]; if (!isset($_GET["numStart"])) { $numStart = 0; } if (!isset($_GET["tab"])) { $tab = 0; } else { $tab = $_GET["tab"]; } if ($tab == '') { $tab = 0; } $queue_name = $_GET["PostfixLoadeMailsQueue"]; $ini = new Bs_IniHandler(); if (!is_file('ressources/databases/postfix-queue-cache.conf')) { return $tpl->_ENGINE_parse_body("{no_cache_created}"); } $ini->loadFile('ressources/databases/postfix-queue-cache.conf'); $PagesNumber = $ini->get($queue_name, 'PagesNumber'); if ($PagesNumber > 0) { $tabublation = Tabs($PagesNumber, $queue_name); } $filetemp = "ressources/databases/queue.list.{$tab}.{$queue_name}.cache"; if (!is_file($filetemp)) { return $tpl->_ENGINE_parse_body("<strong>{unable_to_locate}: {$filetemp}</strong>"); } $datas = explode("\n", file_get_contents($filetemp)); $countRows = count($datas); $number_pages = round($tot / $countRows); $html = "\n\t<H4>{queue} {$queue_name} {$PagesNumber} {pages} {$countRows} {lines}</H4>\n\t<div align='right' class=caption>{from_cache_file} {$filetemp}</div>\n\t{$tabublation}\n\t<table style='width:100%'>\n\t<tr class='caption'>\n\t<td><strong>{date}</strong></td>\n\t<td><strong>{operation}</strong></td>\n\t<td><strong>{mail_from}</strong></td>\n\t<td><strong>{mail_to}</strong></td>\n\t<td><strong>{delete}</strong></td>\n\t</tr>\n\t"; while (list($num, $val) = each($datas)) { $val = str_replace('<sender></sender>', '<sender>unknown</sender>', $val); if (preg_match('#<file>(.+?)</file><path>(.+?)</path><time>(.+?)</time><named_attr>(.+?)</named_attr><sender>(.+?)</sender><recipient>(.+?)</recipient><subject>(.+?)</subject>#', $val, $regs)) { $file = $regs[1]; $path = $regs[2]; $time = PostFixTimeToPhp($regs[3]); $named = $regs[4]; $sender = $regs[5]; $recipient = $regs[6]; $subject = utf8_decode($subject); $subject = htmlentities('"' . $regs[7] . '"'); $varClick = "OnClick=\"javascript:LoadMailID('{$file}','{$queue_name}','{$tab}')\""; $tooltips = "<strong>{$file}</strong><br>{$subject}"; $html = $html . "\n\t\t\t<tr " . CellRollOver(null, $tooltips) . " class=caption>\n\t\t\t<td nowrap {$varClick}>{$time}</td>\n\t\t\t<td {$varClick}>{$named}</td>\n\t\t\t<td {$varClick}>{$sender}</td>\n\t\t\t<td {$varClick}>{$recipient}</td>\n\t\t\t<td align='center' width=1%>" . imgtootltip('x.gif', '{delete}', "DeleteMailID('{$queue_name}','{$tab}','{$file}')") . "</td>\n\t\t\t</tr>\n\t\t\t"; $count = $count + 1; if ($count > 100) { break; } } } $tpl = new templates(); $html = $tpl->_ENGINE_parse_body($html); $html = $html . "</table>"; return $html; }
function parsequeue() { $unix = new unix(); $iptables = $unix->find_program("iptables"); $q = new mysql(); $q->Check_iptables_table(); $ini = new Bs_IniHandler(); $ini->loadFile('/etc/artica-postfix/settings/Daemons/PostfixAutoBlockResults'); if ($GLOBALS["VERBOSE"]) { echo "Scanning /var/log/artica-postfix/smtp-hack\n"; } foreach (glob("/var/log/artica-postfix/smtp-hack/*.hack") as $filename) { if ($GLOBALS["VERBOSE"]) { echo "Scanning {$filename}\n"; } $basename = basename($filename); $array = unserialize(@file_get_contents($filename)); $IP = $array["IP"]; if ($IP == "127.0.0.1") { @unlink($filename); continue; } $server_name = gethostbyaddr($IP); $matches = $array["MATCHES"]; $EVENTS = $array["EVENTS"]; $date = $array["DATE"]; if ($GLOBALS["VERBOSE"]) { echo "{$basename}: servername:{$server_name} IP=[{$IP}]\n"; } $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 25 -j DROP -m comment --comment \"ArticaInstantPostfix\""; $iptablesClass = new iptables_chains(); $iptablesClass->serverip = $IP; $iptablesClass->servername = $server_name; $iptablesClass->rule_string = $cmd; $iptablesClass->EventsToAdd = $EVENTS; if ($iptablesClass->addPostfix_chain()) { if ($GLOBALS["VERBOSE"]) { echo "Add IP:Addr=<{$IP}>, servername=<{$server_name}> to mysql\n"; } $ini->set($IP, "events", $matches); $ini->set($IP, "iptablerule", $cmd); $ini->set($IP, "hostname", $server_name); if ($GLOBALS["VERBOSE"]) { echo "delete {$filename}\n"; } @unlink($filename); } $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 587 -j DROP -m comment --comment \"ArticaInstantPostfix\""; $iptablesClass = new iptables_chains(587); $iptablesClass->serverip = $IP; $iptablesClass->servername = $server_name; $iptablesClass->rule_string = $cmd; $iptablesClass->EventsToAdd = $EVENTS; $iptablesClass->addPostfix_chain(); $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 465 -j DROP -m comment --comment \"ArticaInstantPostfix\""; $iptablesClass = new iptables_chains(); $iptablesClass->serverip = $IP; $iptablesClass->servername = $server_name; $iptablesClass->rule_string = $cmd; $iptablesClass->EventsToAdd = $EVENTS; $iptablesClass->addPostfix_chain(465); } $filestr = $ini->toString(); file_put_contents("/etc/artica-postfix/settings/Daemons/PostfixAutoBlockResults", $filestr); }
function fresh_clam_status() { if ($GLOBALS["VERBOSE"]) { echo "<strong>fresh_clam_status()</strong><br>\n"; } $tpl = new templates(); $sock = new sockets(); $sock->getFrameWork("clamav.php?freshclam-status=yes"); $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/web/freshclam.status"); echo $tpl->_ENGINE_parse_body(DAEMON_STATUS_ROUND("FRESHCLAM", $ini, null, 0)); }
function SendStatus() { emergency(true); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $sock = new sockets(); $EnableSargGenerator = $sock->GET_INFO("EnableSargGenerator"); if (TestsCron($pidfile)) { $ArticaMetaPingEnable = $sock->GET_INFO("ArticaMetaPingEnable"); events("SendPing={$ArticaMetaPingEnable}", __FUNCTION__, __FILE__, __LINE__); if ($ArticaMetaPingEnable == 1) { SendPing(); } return true; } $ArticaMetaEnabled = $sock->GET_INFO("ArticaMetaEnabled"); if ($ArticaMetaEnabled != 1) { return; } $t1 = time(); if (!is_file("/usr/share/artica-postfix/ressources/logs/global.status.ini")) { events("Unable to stat /usr/share/artica-postfix/ressources/logs/global.status.ini", __FUNCTION__, __FILE__, __LINE__); return null; } $unix = new unix(); $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $ptime = $unix->PROCESS_TTL($pid); if ($ptime > $GLOBALS["MAXTTL"]) { events("killing process {$pid} ttl:{$ptime} minutes", __FUNCTION__, __FILE__, __LINE__); unix_system_kill_force($pid); } else { events("Already executed, process {$pid}", __FUNCTION__, __FILE__, __LINE__); die; } } events("Running pid " . getmypid(), __FUNCTION__, __FILE__, __LINE__); @file_put_contents($pidfile, getmypid()); CheckNetwork(); $http = new httpget(); $meta = new artica_meta(); $filecache = "/etc/artica-postfix/artica-meta-files.cache"; events("My uuid=\"{$meta->uuid}\"", __FUNCTION__, __FILE__, __LINE__); $memCache = "/usr/share/artica-postfix/ressources/logs/status.memory.hash"; $cpu_graphs = "/opt/artica/share/www/system/rrd/01cpu-1day.png"; $server_status = "/usr/share/artica-postfix/ressources/logs/status.right.1.html"; $squid_realtime = "/etc/artica-postfix/squid-realtime.cache"; $datasToSend = base64_encode(serialize($meta->GLOBAL_ARRAY)); $ini = new Bs_IniHandler(); $ini->loadFile("/usr/share/artica-postfix/ressources/logs/global.status.ini"); $ArrayFileCache = unserialize(@file_get_contents($filecache)); if (is_file($memCache)) { $MEM_CACHE = base64_encode(@file_get_contents($memCache)); } else { include_once "ressources/class.os.system.tools.inc"; $os = new os_system(); $os->html_Memory_usage(); $MEM_CACHE = base64_encode(serialize($os->meta_array)); } if (is_file($cpu_graphs)) { if ($ArrayFileCache["STATS_DAY"] != filemtime($cpu_graphs)) { $http->uploads["STATS_DAY"] = $cpu_graphs; $ArrayFileCache["STATS_DAY"] = filemtime($cpu_graphs); @file_put_contents($filecache, serialize($ArrayFileCache)); } } if (is_file($server_status)) { if ($ArrayFileCache["SERVER_STATUS"] != filemtime($server_status)) { $http->uploads["SERVER_STATUS"] = $server_status; $ArrayFileCache["SERVER_STATUS"] = filemtime($server_status); @file_put_contents($filecache, serialize($ArrayFileCache)); } } if (is_file($squid_realtime)) { if ($ArrayFileCache["SQUID_REALTIME"] != filemtime($squid_realtime)) { $http->uploads["SQUID_REALTIME"] = $squid_realtime; $ArrayFileCache["SQUID_REALTIME"] = filemtime($squid_realtime); @file_put_contents($filecache, serialize($ArrayFileCache)); } } if ($EnableSargGenerator == 1) { $push_sarg = false; $sock = new sockets(); $SargOutputDir = $sock->GET_INFO("SargOutputDir"); if ($SargOutputDir == null) { $SargOutputDir = "/var/www/html/squid-reports"; } if (is_file("{$SargOutputDir}/index.html")) { if (!is_file("/etc/artica-postfix/sarg.tgz")) { shell_exec("cd {$SargOutputDir} && tar -cjf /etc/artica-postfix/sarg.tgz ./*"); $push_sarg = true; } else { if ($ArrayFileCache["SQUID_SARG"] != filemtime("{$SargOutputDir}/index.html")) { @unlink("/etc/artica-postfix/sarg.tgz"); shell_exec("cd {$SargOutputDir} && tar -cjf /etc/artica-postfix/sarg.tgz ./*"); $push_sarg = true; } } if ($push_sarg) { $http->uploads["SQUID_SARG"] = "/etc/artica-postfix/sarg.tgz"; } } } $users = new usersMenus(); $status = base64_encode(serialize($ini->_params)); $pasmoinsaux = pasmoinsaux(); if ($users->VMWARE_HOST) { $VMWARE_HOST = 1; } else { $VMWARE_HOST = 0; } shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.dmidecode.php"); $dmidecode = base64_encode(@file_get_contents("/etc/artica-postfix/dmidecode.cache")); //SQUID if ($users->SQUID_INSTALLED) { $sock = new sockets(); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if ($SQUIDEnable == 1) { $SQUID_CACHES = base64_encode(serialize($unix->squid_get_cache_infos())); } if (is_array($SQUID_CACHES)) { $squid = new squidbee(); $cacheconf = $squid->cache_list; $cacheconf[$squid->CACHE_PATH]["cache_type"] = $squid->CACHE_TYPE; $cacheconf[$squid->CACHE_PATH]["cache_size"] = $squid->CACHE_SIZE; $cacheconf[$squid->CACHE_PATH]["cache_dir_level1"] = 16; $cacheconf[$squid->CACHE_PATH]["cache_dir_level2"] = 256; events("Caches: " . count($cacheconf), __FILE__, __LINE__); $SQUID_CACHES_CONFIG = base64_encode(serialize($cacheconf)); } } if ($users->SAMBA_INSTALLED) { _CheckSambaConfig(); } if ($users->ZARAFA_INSTALLED) { if (is_file("/etc/artica-postfix/settings/Daemons/ZarafaLicenseInfos")) { $ZARAFA_LICENSE = @file_get_contents("/etc/artica-postfix/settings/Daemons/ZarafaLicenseInfos"); } else { $ZARAFA_LICENSE = "Free edition"; } } if (is_file("/etc/artica-postfix/zarafa-export.db")) { $ZARAFA_DB = @file_get_contents("/etc/artica-postfix/zarafa-export.db"); } $body = $http->send("{$meta->ArticaMetaHostname}/lic.status.server.php", "post", array("DATAS" => $datasToSend, "STATUS" => $status, "MEMORIES" => $MEM_CACHE, "VERSION" => $users->ARTICA_VERSION, "DISTRI" => $users->LinuxDistriCode, "UPTIME" => getUptime(), "DISTRINAME" => $users->LinuxDistriFullName, "MAIN_PRODUCTS" => base64_encode(serialize(array("ZARAFA" => $users->ZARAFA_INSTALLED, "POSTFIX" => $users->POSTFIX_INSTALLED, "SQUID" => $users->SQUID_INSTALLED, "SAMBA" => $users->SAMBA_INSTALLED, "CYRUS" => $users->cyrus_imapd_installed, "OPENVPN" => $users->OPENVPN_INSTALLED))), "PROCESSES" => base64_encode($pasmoinsaux), "TOP_PROCESSES" => top10cpumem(), "NETS" => Networks(), "VMWARE_HOST" => $VMWARE_HOST, "SETTINGS_INC" => base64_encode(serialize(settings_inc())), "LOCAL_VERSIONS" => LocalVersions(), "VBOXGUESTS" => VirtualBoxList(), "APTCHECK" => APTCHECK(), "DMIDECODE" => $dmidecode, "SQUID_CACHES" => $SQUID_CACHES, "SQUID_CACHES_CONFIG" => $SQUID_CACHES_CONFIG, "OPENPORTS" => OpenPorts($meta->serial, $meta->uuid), "OPENVPN_CLIENTS_STATUS" => @file_get_contents("/usr/share/artica-postfix/ressources/logs/openvpn-clients.status"), "ZARAFA_DB" => $ZARAFA_DB, "ZARAFA_LICENSE" => $ZARAFA_LICENSE)); $EXEC_NICE = EXEC_NICE(); if (is_file("/usr/bin/nohup")) { $nohup = "/usr/bin/nohup "; } if (preg_match("#NOTIFY_DISCONNECT#is", $body)) { events("NOTIFY_DISCONNECT detected -> unregister_server()", __FUNCTION__, __FILE__, __LINE__); unregister_server(); return; } if (preg_match("#NOTIFY_EXPORT_USERS#is", $body)) { events("NOTIFY_EXPORT_USERS -> {$nohup}{$EXEC_NICE}exec.artica.meta.users.php --export-all", __FUNCTION__, __FILE__, __LINE__); shell_exec($nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all >/dev/null 2>&1 &"); } if (preg_match("#NOTIFY_EXPORT_DOMAINS#is", $body)) { events("NOTIFY_EXPORT_DOMAINS -> {$nohup}{$EXEC_NICE}exec.artica.meta.users.php --export-all-domains", __FUNCTION__, __FILE__, __LINE__); shell_exec($nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-domains >/dev/null 2>&1 &"); } if (preg_match("#NOTIFY_EXPORT_OU#is", $body)) { events("NOTIFY_EXPORT_OU -> {$nohup}{$EXEC_NICE}exec.artica.meta.users.php --export-all-ou", __FUNCTION__, __FILE__, __LINE__); shell_exec($nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-ou >/dev/null 2>&1 &"); } if (preg_match("#NOTIFY_EXPORT_GROUPS#is", $body)) { events("NOTIFY_EXPORT_GROUPS -> {$nohup}{$EXEC_NICE}exec.artica.meta.users.php --export-all-groups", __FUNCTION__, __FILE__, __LINE__); shell_exec($nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-groups >/dev/null 2>&1 &"); } if (preg_match("#NOTIFY_EXPORT_SETTINGS#is", $body)) { $cmd = $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-settings >/dev/null 2>&1 &"; events("NOTIFY_EXPORT_SETTINGS -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (preg_match("#NOTIFY_EXPORT_COMPUTERS#is", $body)) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-computers >/dev/null 2>&1 &"; events("NOTIFY_EXPORT_SETTINGS -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (preg_match("#NOTIFY_EXPORT_DNS_ENTRIES#is", $body)) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-dns >/dev/null 2>&1 &"; events("NOTIFY_EXPORT_DNS_ENTRIES -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (preg_match("#NOTIFY_EXPORT_GROUPWARES#is", $body)) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-groupwares >/dev/null 2>&1 &"; events("NOTIFY_EXPORT_GROUPWARES -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (preg_match("#NOTIFY_EXPORT_FETCHMAIL_RULES#is", $body)) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-fetchmail-rules >/dev/null 2>&1 &"; events("NOTIFY_EXPORT_FETCHMAIL_RULES -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (preg_match("#<TASKS>(.+?)</TASKS>#is", $body, $re)) { events("Save tasks to /etc/artica-postfix/artica-meta.tasks", __FUNCTION__, __FILE__, __LINE__); @file_put_contents("/etc/artica-postfix/artica-meta.tasks", $re[1]); $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.tasks.php >/dev/null 2>&1 &"; events("TASKS ->{$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } else { events("No tasks ordered for me...", __FUNCTION__, __FILE__, __LINE__); @unlink("/etc/artica-postfix/artica-meta.tasks"); } if (preg_match("#<HOST_CONF>(.+?)</HOST_CONF>#is", $body, $re)) { ParseMyConf($re[1]); } else { events("No configuration for me...", __FUNCTION__, __FILE__, __LINE__); } shell_exec($nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --socks >/dev/null 2>&1 &"); if (users_queue()) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --user-queue >/dev/null 2>&1 &"; events("users settings queue is not empty -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if (computer_queue()) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --computer-queue >/dev/null 2>&1 &"; events("computer settings queue is not empty -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } if ($users->OPENVPN_INSTALLED) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-openvpn-logs >/dev/null 2>&1 &"; events("OpenVpn is installed -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); } $time_iptables = file_time_min("/etc/artica-postfix/artica.meta.iptables.time"); if ($time_iptables > 180) { $cmd = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --iptables >/dev/null 2>&1 &"; events("iptables -> {$cmd}", __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-settings >/dev/null 2>&1 &"; events("{$cmd}", __FUNCTION__, __FILE__, __LINE__); @unlink("/etc/artica-postfix/artica.meta.iptables.time"); @file_put_contents("/etc/artica-postfix/artica.meta.iptables.time", "#"); } $t2 = time(); $time_duration = distanceOfTimeInWords($t1, $t2); events("Send status to {$meta->ArticaMetaHostname} DONE ({$time_duration})", __FUNCTION__, __FILE__, __LINE__); }
function service_status() { $t = $_GET["t"]; $page = CurrentPageName(); $tpl = new templates(); $ini = new Bs_IniHandler(); $sock = new sockets(); $ini->loadFile("/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS"); $tr[] = DAEMON_STATUS_ROUND("APP_UFDBGUARD", $ini, null, 1); $tr[] = DAEMON_STATUS_ROUND("APP_UFDBGUARD_CLIENT", $ini, null, 1); $tr[] = DAEMON_STATUS_ROUND("APP_SQUIDGUARD_HTTP", $ini, null, 1); $tr[] = DAEMON_STATUS_ROUND("APP_UFDBCAT", $ini, null, 1); $status = @implode("\n", $tr); $html = "\n\t<div id='rules-toolbox-left' style='margin-bottom:15px'></div>\n\t{$status}\n\t<script>\n\t\tLoadAjax('rules-toolbox-left','dansguardian2.mainrules.php?rules-toolbox-left=yes');\n\t\tLoadAjaxTiny('rules-toolbox','dansguardian2.mainrules.php?rules-toolbox=yes');\n\t\tLoadAjax('main-status-{$t}','{$page}?main=yes&t={$t}');\n\t</script>\t\n\t"; echo $tpl->_ENGINE_parse_body($html); }
function status_versions() { $tpl = new templates(); $sock = new sockets(); $EnableArticaMetaClient = intval($sock->GET_INFO("EnableArticaMetaClient")); if ($EnableArticaMetaClient == 1) { return; } $f = "/usr/share/artica-postfix/ressources/index.ini"; $ini = new Bs_IniHandler(); $ini->loadFile($f); $Lastest_patch = trim(strtolower($ini->_params["NEXT"]["artica-patch"])); $Lastest = trim(strtolower($ini->_params["NEXT"]["artica"])); $nightly = trim(strtolower($ini->_params["NEXT"]["artica-nightly"])); if ($Lastest == null) { $Lastest = "-"; } if ($Lastest_patch == null) { $Lastest_patch = "-"; } if ($Lastest == null) { $Lastest = "-"; } $html = "\n\t\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td colspan=3 style='font-size:22px'>{available_versions}:</td>\n\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td width=1% nowrap><img src=img/arrow-blue-left-32.png></td>\n\t\t\t\t<td class=legend style='font-size:18px' nowrap>{release}:</td>\n\t\t\t\t<td style='font-size:18px'><a href=\"http://www.artica.fr/releases.php\" target=_new>{$Lastest}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td width=1% nowrap><img src=img/arrow-blue-left-32.png ></td>\n\t\t\t\t<td class=legend style='font-size:18px' nowrap>Nightly:</td>\n\t\t\t\t<td style='font-size:18px' width=99%><a href=\"http://www.artica.fr/nightly.php\" target=_new>{$nightly}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td width=1% nowrap><img src=img/arrow-blue-left-32.png ></td>\n\t\t\t\t<td class=legend style='font-size:18px' nowrap>Patch:</td>\n\t\t\t\t<td style='font-size:18px' width=99%><a href=\"http://www.artica.fr/patch-p0.php\" target=_new>{$Lastest_patch}</td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr><td colspan=3 style='font-size:22px'> </td></tr>\n\t\t\t\n\t\t\t\n\t\t</table>\n"; echo $tpl->_ENGINE_parse_body($html); }
function build_system_defaults() { $unix = new unix(); $sock = new sockets(); $nice = $unix->EXEC_NICE(); $php = $unix->LOCATE_PHP5_BIN(); $ArticaBackupEnabled = intval($sock->GET_INFO("ArticaBackupEnabled")); $users = new usersMenus(); @unlink("/etc/cron.d/artica-cron-backup"); @unlink("/etc/cron.d/artica-cron-pflogsumm"); if (is_file('/etc/artica-postfix/artica-backup.conf')) { if ($ArticaBackupEnabled == 1) { $ini = new Bs_IniHandler(); $ini->loadFile('/etc/artica-postfix/artica-backup.conf'); if (!isset($ini->_params["backup"]["backup_time"])) { $ini->_params["backup"]["backup_time"] = "03:00"; } if (preg_match("#([0-9]+):([0-9]+)#", $ini->_params["backup"]["backup_time"], $re)) { $backup_hour = intval($re[1]); $backup_min = intval($re[2]); $f[] = "MAILTO=\"\""; $f[] = "{$backup_min} {$backup_hour} * * * root {$nice} /usr/share/artica-postfix/bin/artica-backup --backup >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-cron-backup", @implode("\n", $f)); $f = array(); } } } if (is_file('/etc/artica-postfix/settings/Daemons/pflogsumm')) { $ini = new Bs_IniHandler(); $ini->loadFile('/etc/artica-postfix/settings/Daemons/pflogsumm'); $schedule_time = trim($ini->_params['SETTINGS']['schedule']); if ($schedule_time != null) { $f[] = "MAILTO=\"\""; $f[] = "{$schedule_time} root {$nice} {$php} /usr/share/artica-postfix/exec.postfix.reports.php >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-cron-pflogsumm", @implode("\n", $f)); $f = array(); } } $prefix = "/usr/share/artica-postfix"; $f = array(); $f[] = "MAILTO=\"\""; $f[] = "@reboot root {$nice} /sbin/modprobe cifs && echo 0 > /proc/fs/cifs/OplockEnabled >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/cifs-fix", @implode("\n", $f)); $f = array(); $f[] = "MAILTO=\"\""; $f[] = "@reboot root {$nice} {$php} {$prefix}/exec.schedules.php >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/schedules", @implode("\n", $f)); $f = array(); $f[] = "MAILTO=\"\""; $f[] = "7,14,21,28,35,42,49,56 0 * * * * root {$nice} {$php} {$prefix}/exec.dnsmasq.php --varrun >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-dnsmasqrun", @implode("\n", $f)); $f = array(); $f[] = "MAILTO=\"\""; $f[] = "10,34,51 0 * * * * root {$nice} {$php} {$prefix}/exec.watchdog.php --monit >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-dnsmasqrun", @implode("\n", $f)); $f = array(); $f[] = "MAILTO=\"\""; $f[] = "0,2,4,6,8,10,12,14,16,18,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,58 * * * * root {$nice} {$php} {$prefix}/exec.parse-orders.php >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-parseorders", @implode("\n", $f)); $f = array(); if ($users->spamassassin_installed) { $f[] = "MAILTO=\"\""; $f[] = "10 3,6,9,12,15,18,21,23 * * * root {$nice} {$php} {$prefix}/exec.sa-learn-cyrus.php --execute >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-salearn-cyrus", @implode("\n", $f)); $f = array(); } if ($users->fetchmail_installed) { $f[] = "MAILTO=\"\""; $f[] = "0,2,4,6,8,10,12,14,16,18,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,58 * * * * root {$nice} {$php} {$prefix}/exec.fetchmail.sql.php >/dev/null 2>&1"; $f[] = ""; @file_put_contents("/etc/cron.d/artica-ftechmailsql", @implode("\n", $f)); $f = array(); } }
function interface_events($product, $line) { $ini = new Bs_IniHandler(); if (is_file("/usr/share/artica-postfix/ressources/logs/interface.events")) { $ini->loadFile("/usr/share/artica-postfix/ressources/logs/interface.events"); } $ini->set($product, 'error', $line); $ini->saveFile("/usr/share/artica-postfix/ressources/logs/interface.events"); @chmod("/usr/share/artica-postfix/ressources/logs/interface.events", 0755); }
$UsersNumber = 0; } $uriplus = "{$SYSTEMID};{$MEMORY_INSTALLED};{$SystemCpuNumber};{$LinuxDistributionFullName};{$ARTICA_VERSION};{$hostname};{$UsersNumber};{$datas}"; $uriplus = str_replace(" ", "%20", $uriplus); $ini = new Bs_IniHandler(); $ini->loadFile("/etc/artica-postfix/artica-update.conf"); $uri = $ini->get("AUTOUPDATE", "uri"); if (trim($uri) == null) { $uri = "http://93.88.245.88/auto.update.php"; } $uri = str_replace("www.artica.fr", "93.88.245.88", $uri); $localFile = '/usr/share/artica-postfix/ressources/index.ini'; $curl = new ccurl("{$uri}?datas={$uriplus}"); $tmpfile = "/tmp/artica." . basename(__FILE__) . '.tmp'; @unlink("/usr/share/artica-postfix/ressources/logs/INTERNET_FAILED"); if (!$curl->GetFile($tmpfile)) { $unix->send_email_events("Check Internet connexion Failed", "System is unable to connect trough internet: {$curl->error}", "update"); @file_put_contents("/usr/share/artica-postfix/ressources/logs/INTERNET_FAILED", $curl->error); shell_exec("{$chmod} 777 /usr/share/artica-postfix/ressources/logs/INTERNET_FAILED"); return; } $ini = new Bs_IniHandler(); $ini->loadFile("{$tmpfile}"); $articaversion = $ini->get("NEXT", "artica"); if ($GLOBALS["VERBOSE"]) { echo "Artica version:{$articaversion}\n"; } if (preg_match("#^[0-9\\.]+#", $articaversion)) { @copy($tmpfile, "/usr/share/artica-postfix/ressources/index.ini"); shell_exec("{$chmod} 777 /usr/share/artica-postfix/ressources/index.ini"); }