function quicklinks_section_server() { $tpl = new templates(); include_once dirname(__FILE__) . "/ressources/class.os.system.inc"; include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc"; $os = new os_system(); $users = new usersMenus(); $page = CurrentPageName(); $sock = new sockets(); $cpunum = intval($users->CPU_NUMBER); $array_load = sys_getloadavg(); $org_load = $array_load[2]; $load = intval($org_load); $hash_mem = $os->realMemory(); $mem_used_p = $hash_mem["ram"]["percent"]; $mem_used_kb = FormatBytes($hash_mem["ram"]["used"]); $total = FormatBytes($hash_mem["ram"]["total"]); $swapar = $os->swap(); $sock = new sockets(); $max_vert_fonce = $cpunum; $max_vert_tfonce = $cpunum + 1; $max_orange = $cpunum * 0.75; $max_over = $cpunum * 2; $purc1 = $load / $cpunum; $pourc = round($purc1 * 100, 2); $color = "#5DD13D"; if ($load >= $max_orange) { $color = "#F59C44"; } if ($load > $max_vert_fonce) { $color = "#C5792D"; } if ($load > $max_vert_tfonce) { $color = "#83501F"; } if ($load >= $max_over) { $color = "#640000"; $text = "{overloaded}"; } $DisableMessaging = intval($sock->GET_INFO("DisableMessaging")); if ($DisableMessaging == 1) { if ($users->POSTFIX_INSTALLED) { $EnablePostfix = $tr[] = paragrapheWin("enable-messaging-white-64.png", "{enable_messaging}", "Loadjs('postfix.disable.php');"); } } $OnlySMTP = false; if ($users->SMTP_APPLIANCE) { $OnlySMTP = true; } if ($users->KASPERSKY_SMTP_APPLIANCE) { $OnlySMTP = true; } $SambaEnabled = $sock->GET_INFO("SambaEnabled"); if (!is_numeric($SambaEnabled)) { $SambaEnabled = 1; } $SambaJS = "QuickLinksSamba()"; if ($SambaEnabled == 0) { $SambaJS = "Loadjs('samba.disable.php')"; } $IsPostfixlockedInt = 0; $IsPostfixlocked = base64_decode($sock->getFrameWork("postfix.php?islocked=yes")); if ($IsPostfixlocked == "TRUE") { $IsPostfixlockedInt = 1; } if (!$users->SQUID_INSTALLED) { if (!$users->POSTFIX_INSTALLED) { if ($users->SAMBA_INSTALLED) { if ($SambaEnabled == 1) { $ONLY_SAMBA = true; } } } } $DisableFrontBrowseComputers = $sock->GET_INFO('DisableFrontBrowseComputers'); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); if (!is_numeric($DisableFrontBrowseComputers)) { $DisableFrontBrowseComputers = 0; } if (!is_numeric($EnableRemoteStatisticsAppliance)) { $EnableRemoteStatisticsAppliance = 0; } $ProductName = "Artica"; $ProductNamef = dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf"; if (is_file($ProductNamef)) { $ProductName = trim(@file_get_contents($ProductNamef)); } if ($users->AsSystemAdministrator) { $artica_meta = paragrapheWin("management-console-64.png", "{$ProductName} Meta", "AnimateDiv('BodyContent');\n\t\t\t\tLoadAjax('BodyContent','artica-meta.php');"); $time_ntp = paragrapheWin("ntp-time-64-white.png", "{server_time2}", "AnimateDiv('BodyContent');\n\t\t\t\tLoadAjax('BodyContent','index.time.php?tabs=yes');"); $sensors = paragrapheWin("temperature-64.png", "{temperature}", "AnimateDiv('BodyContent');\n\t\t\t\tLoadAjax('BodyContent','system.sensors.php');"); } $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); $LDAP = paragrapheWin("mysql-white-64.png", "{APP_LDAP}", "AnimateDiv('BodyContent');Loadjs('system.ldap.php');"); $MySQL = paragrapheWin("mysql-white-64.png", "MySQL", "AnimateDiv('BodyContent');Loadjs('system.mysql.php');"); if (!$users->KASPERSKY_WEB_APPLIANCE) { if (!$users->SQUID_APPLIANCE) { if (!$users->SQUID_REVERSE_APPLIANCE) { if ($users->AsSambaAdministrator) { if ($users->SAMBA_INSTALLED) { $samba = paragrapheWin("nas-white-64.png", "{APP_SAMBA}", "{$SambaJS}"); } } } } } if ($users->OCSI_INSTALLED) { if ($users->AsInventoryAdmin) { $ocs = paragrapheWin("computers2-white-64.png", "{APP_OCSI}", "Loadjs('ocs.ng.php?in-front-ajax=yes&newinterface=yes')"); } } if ($users->APACHE_INSTALLED) { if ($users->AsAnAdministratorGeneric) { if ($GLOBALS["VERBOSE"]) { echo "FreeWebs\n"; } $freewebs = paragrapheWin("freewebs-white-64.png", "{webservers}", "QuickLinkSystems('section_freeweb')"); $wp = paragrapheWin("wp-64-white.png", "Wordpress", "LoadAjax('BodyContent','wordpress.php');"); } } if ($users->EJABBERD_INSTALLED) { if ($users->AsPostfixAdministrator) { $ejabberd = paragrapheWin("chat-white-64.png", "{INSTANT_MESSAGING}", "LoadAjax('BodyContent','ejabberd.php');"); } } if ($users->UPDATE_UTILITYV2_INSTALLED) { $updateutility = paragrapheWin("update-kaspersky-64.png", "UpdateUtility", "LoadAjax('BodyContent','UpdateUtility.php');"); } if ($users->AsSystemAdministrator) { if ($users->FREERADIUS_INSTALLED) { $freeradius = paragrapheWin("radius-white-64.png", "{APP_FREERADIUS}", "LoadAjax('BodyContent','freeradius.php');"); } if ($users->HAPROXY_INSTALLED) { $haProxy = paragrapheWin("load-balance-white-64.png", "{load_balancing}", "Loadjs('haproxy.php')"); } } if ($users->AsSambaAdministrator) { if ($SambaEnabled == 1) { if ($users->DROPBOX_INSTALLED) { $dropbox = paragrapheWin("dropbox-white-64.png", "{APP_DROPBOX}", "Loadjs('samba.dropbox.php')"); } } } if ($users->AsSystemAdministrator) { $logrotate = paragrapheWin("traces-white-64.png", "{system_logs}", "Loadjs('logrotate.php?in-front-ajax=yes')"); if ($users->VMWARE_HOST) { $vmware = paragrapheWin("vmware-white-64.png", "{APP_VMTOOLS}", "Loadjs('VMWareTools.php')"); } } if ($OnlySMTP) { $samba = null; $computers = null; $fetchmail = null; } // if ($users->AsSystemAdministrator) { $tr[] = paragrapheWin("hostname-white-64.png", "{hostname}", "Loadjs('system.nic.config.php?change-hostname-js=yes');"); $tr[] = paragrapheWin("harddrive-white-64.png", "{internal_hard_drives}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','{$page}?function=section_btrfs');"); $tr[] = $sensors; $tr[] = $time_ntp; $tr[] = paragrapheWin("optimize-64.png", "{system_optimization}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','system.optimize.php')"); $tr[] = paragrapheWin("settings-server-64.png", "{general_settings}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','{$page}?function=section_computers_infos')"); $tr[] = paragrapheWin("directory-white-64.png", "{explorer}", "Loadjs('tree.php')"); $tr[] = paragrapheWin("snmp-64-white.png", "SNMP", "Loadjs('system.snmp.php');"); $tr[] = paragrapheWin("ssh-64.png", "{APP_OPENSSH}", "AnimateDiv('BodyContent');Loadjs('sshd.php?in-front-ajax=yes&tabsize=14');"); $tr[] = paragrapheWin("clamav-64-white.png", "{APP_CLAMAV}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','clamd.php?tabs=yes');"); $tr[] = paragrapheWin("sync-64-white.png", "{APP_SYNCTHING}", "LoadAjax('BodyContent','syncthing.php');"); } if ($users->POWER_DNS_INSTALLED) { $PowerDNS = paragrapheWin("dns-white-64.png", "PowerDNS", "AnimateDiv('BodyContent');LoadAjax('BodyContent','pdns.php?tabs=yes&expand=yes');"); } $tr[] = paragrapheWin("certificate-white-64.png", "{certificates_center}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','certificates.center.php?tabs=yes');"); $hostname = paragrapheWin("hostname-white-64.png", "{hostname}", "Loadjs('system.nic.config.php?change-hostname-js=yes');"); // if (!$users->dnsmasq_installed) { $dnsmasq = null; } if (!$users->dhcp_installed) { $dhcp = null; } if (!$users->OPENVPN_INSTALLED) { $openvpn = null; } if ($users->OCSI_INSTALLED) { $computers = null; } else { $ocs = null; } $stats = paragrapheWin("statistics3-white-64.png", "{statistics}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','quicklinks.network.php?function=section_statistics')"); if (!$users->AsSystemAdministrator) { $hostname = null; } $tr[] = $artica_meta; $tr[] = $dhcp; $tr[] = $PowerDNS; $tr[] = $dnsmasq; $tr[] = $logrotate; $tr[] = $vmware; $tr[] = $freewebs; $tr[] = $wp; $tr[] = paragrapheWin("FTP-white-64.png", "FTP", "AnimateDiv('BodyContent');LoadAjax('BodyContent','vsftpd.php');"); $tr[] = $roundcube; $tr[] = $haProxy; $tr[] = $computers; if ($users->AsSystemAdministrator) { $tr[] = $MySQL; $tr[] = $LDAP; } $tr[] = $samba; $tr[] = $ocs; $tr[] = $updateutility; $tr[] = $ejabberd; $tr[] = $hamachi; $tr[] = $openvpn; $tr[] = $freeradius; $tr[] = $stats; $html = $tpl->_ENGINE_parse_body("<div style='font-size:48px;color:white'>\n\t<table style='width:50%'>\n\t<tr>\n\t\t<td nowrap style='padding-left:10px;font-size:48px;color:white' nowrap>{load}: {$org_load}</td>\n\t\t<td nowrap style='padding-left:10px;border-left:2px solid white;font-size:48px;color:white' nowrap>{memory}: {$mem_used_p}%</td>\n\t\t<td nowrap style='padding-left:10px;border-left:2px solid white;font-size:48px;color:white' nowrap>SWAP: {$swapar[0]}%</td>\t\t\n\t</tr>\n\t</table>\t\t\n\t</div>\n\t") . CompileTr5_win($tr); echo $html; }
function quicklinks_section_server() { $tpl = new templates(); include_once dirname(__FILE__) . "/ressources/class.os.system.inc"; include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc"; $os = new os_system(); $users = new usersMenus(); $page = CurrentPageName(); $sock = new sockets(); if ($GLOBALS["AS_ROOT"]) { $users->AsSystemAdministrator = true; } $CachePage = "/usr/share/artica-postfix/ressources/logs/web/" . __FUNCTION__ . ".html"; if (!$GLOBALS["AS_ROOT"]) { if ($users->AsSystemAdministrator) { if (is_file($CachePage)) { $tpl = new templates(); echo $tpl->_ENGINE_parse_body(@file_get_contents($CachePage)); return; } } } $SQUIDEnable = trim($sock->GET_INFO("SQUIDEnable")); $EnableNginx = intval($sock->GET_INFO("EnableNginx")); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } $cpunum = intval($users->CPU_NUMBER); $array_load = sys_getloadavg(); $org_load = $array_load[2]; $load = intval($org_load); $hash_mem = $os->realMemory(); $mem_used_p = $hash_mem["ram"]["percent"]; $mem_used_kb = FormatBytes($hash_mem["ram"]["used"]); $total = FormatBytes($hash_mem["ram"]["total"]); $swapar = $os->swap(); $sock = new sockets(); $max_vert_fonce = $cpunum; $max_vert_tfonce = $cpunum + 1; $max_orange = $cpunum * 0.75; $max_over = $cpunum * 2; $purc1 = $load / $cpunum; $pourc = round($purc1 * 100, 2); $color = "#5DD13D"; if ($load >= $max_orange) { $color = "#F59C44"; } if ($load > $max_vert_fonce) { $color = "#C5792D"; } if ($load > $max_vert_tfonce) { $color = "#83501F"; } if ($load >= $max_over) { $color = "#640000"; $text = "{overloaded}"; } $DisableMessaging = intval($sock->GET_INFO("DisableMessaging")); if ($DisableMessaging == 1) { if ($users->POSTFIX_INSTALLED) { $EnablePostfix = $tr[] = paragrapheWin("enable-messaging-white-64.png", "{enable_messaging}", "Loadjs('postfix.disable.php');"); } } $OnlySMTP = false; if ($users->SMTP_APPLIANCE) { $OnlySMTP = true; } if ($users->KASPERSKY_SMTP_APPLIANCE) { $OnlySMTP = true; } $SambaEnabled = $sock->GET_INFO("SambaEnabled"); if (!is_numeric($SambaEnabled)) { $SambaEnabled = 1; } $SambaJS = "QuickLinksSamba()"; if ($SambaEnabled == 0) { $SambaJS = "Loadjs('samba.disable.php')"; } $IsPostfixlockedInt = 0; $IsPostfixlocked = base64_decode($sock->getFrameWork("postfix.php?islocked=yes")); if ($IsPostfixlocked == "TRUE") { $IsPostfixlockedInt = 1; } if (!$users->SQUID_INSTALLED) { if (!$users->POSTFIX_INSTALLED) { if ($users->SAMBA_INSTALLED) { if ($SambaEnabled == 1) { $ONLY_SAMBA = true; } } } } $DisableFrontBrowseComputers = $sock->GET_INFO('DisableFrontBrowseComputers'); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); if (!is_numeric($DisableFrontBrowseComputers)) { $DisableFrontBrowseComputers = 0; } if (!is_numeric($EnableRemoteStatisticsAppliance)) { $EnableRemoteStatisticsAppliance = 0; } $ProductName = "Artica"; $ProductNamef = dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf"; if (is_file($ProductNamef)) { $ProductName = trim(@file_get_contents($ProductNamef)); } if ($users->AsSystemAdministrator) { } $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); if (!$users->KASPERSKY_WEB_APPLIANCE) { if (!$users->SQUID_APPLIANCE) { if (!$users->SQUID_REVERSE_APPLIANCE) { if ($users->AsSambaAdministrator) { if ($users->SAMBA_INSTALLED) { $samba = paragrapheWin("nas-white-64.png", "{APP_SAMBA}", "{$SambaJS}"); } } } } } if ($users->OCSI_INSTALLED) { if ($users->AsInventoryAdmin) { $ocs = paragrapheWin("computers2-white-64.png", "{APP_OCSI}", "Loadjs('ocs.ng.php?in-front-ajax=yes&newinterface=yes')"); } } if ($users->EJABBERD_INSTALLED) { if ($users->AsPostfixAdministrator) { $ejabberd = paragrapheWin("chat-white-64.png", "{INSTANT_MESSAGING}", "LoadAjax('BodyContent','ejabberd.php');"); } } if ($users->UPDATE_UTILITYV2_INSTALLED) { $updateutility = paragrapheWin("update-kaspersky-64.png", "UpdateUtility", "LoadAjax('BodyContent','UpdateUtility.php');"); } if ($OnlySMTP) { $samba = null; $computers = null; $fetchmail = null; } // // if (!$users->dnsmasq_installed) { $dnsmasq = null; } if (!$users->dhcp_installed) { $dhcp = null; } if (!$users->OPENVPN_INSTALLED) { $openvpn = null; } if ($users->OCSI_INSTALLED) { $computers = null; } else { $ocs = null; } $stats = paragrapheWin("statistics3-white-64.png", "{statistics}", "AnimateDiv('BodyContent');LoadAjax('BodyContent','quicklinks.network.php?function=section_statistics')"); if (!$users->AsSystemAdministrator) { $hostname = null; } $tr[] = $artica_meta; $tr[] = $dhcp; $tr[] = $PowerDNS; $tr[] = $dnsmasq; $tr[] = $logrotate; $tr[] = $tasks; $tr[] = $vmware; $tr[] = $freewebs; $tr[] = $wp; $tr[] = $haProxy; $tr[] = $computers; if ($users->AsSystemAdministrator) { $tr[] = $MySQL; $tr[] = $LDAP; } $tr[] = $reactive_squid; $tr[] = $nginx; $tr[] = $samba; $tr[] = $ocs; $tr[] = $updateutility; $tr[] = $ejabberd; $tr[] = $openvpn; $tr[] = $freeradius; $tr[] = $stats; $html = $tpl->_ENGINE_parse_body("<div style='font-size:48px;color:white'>\n\t<table style='width:50%'>\n\t<tr>\n\t\t<td nowrap style='padding-left:10px;font-size:48px;color:white' nowrap>{load}: {$org_load}</td>\n\t\t<td nowrap style='padding-left:10px;border-left:2px solid white;font-size:48px;color:white' nowrap>{memory}: {$mem_used_p}%</td>\n\t\t<td nowrap style='padding-left:10px;border-left:2px solid white;font-size:48px;color:white' nowrap>SWAP: {$swapar[0]}%</td>\t\t\n\t</tr>\n\t</table>\t\t\n\t</div>\n\t") . CompileTr7_win($tr); if ($GLOBALS['AS_ROOT']) { @file_put_contents($CachePage, $html); } echo $html; }
function loadmem(){ include_once("ressources/class.os.system.tools.inc"); $unix=new unix(); $timefile="/etc/artica-postfix/croned.1/".basename(__FILE__).__FUNCTION__; if(file_time_min($timefile)<15){return null;} @unlink($timefile); @file_put_contents($timefile,"#"); $sys=new os_system(); $mem=$sys->realMemory(); $pourc=$mem["ram"]["percent"]; $ram_used=$mem["ram"]["used"]; $ram_total=$mem["ram"]["total"]; $datas=loadavg_table(); if($GLOBALS["VERBOSE"]){echo strlen($datas)." bytes body text\n";} $unix->send_email_events("System Memory $pourc% used exceed rule",$datas,"system"); checkProcess1(); }
function loadmem() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "/pids/" . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { writelogs("Already process {$pid} exists", __FUNCTION__, __FILE__, __LINE__); return; } @file_put_contents($pidfile, getmypid()); include_once "ressources/class.os.system.tools.inc"; $unix = new unix(); $timefile = "/etc/artica-postfix/croned.1/" . basename(__FILE__) . __FUNCTION__; if (file_time_min($timefile) < 15) { return null; } @unlink($timefile); @file_put_contents($timefile, time()); $sys = new os_system(); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $datas = loadavg_table(); if ($GLOBALS["VERBOSE"]) { echo strlen($datas) . " bytes body text\n"; } $unix->send_email_events("System Memory {$pourc}% used exceed rule", $datas, "system"); checkProcess1(); }
function high_menus() { return; $sock = new sockets(); $FixedLanguage = $sock->GET_INFO("FixedLanguage"); if (!isset($GLOBALS["CLASS_USERS_MENUS"])) { $users = new usersMenus(); $GLOBALS["CLASS_USERS_MENUS"] = $users; } else { $users = $GLOBALS["CLASS_USERS_MENUS"]; } $tpl = new templates(); if (is_file("ressources/templates/{$_COOKIE["artica-template"]}/HEAD_MENUS")) { $html = @file_get_contents("ressources/templates/{$_COOKIE["artica-template"]}/HEAD_MENUS"); $html = str_replace("%articaver%", $users->ARTICA_VERSION, $html); echo $tpl->_ENGINE_parse_body($html); return; } include_once dirname(__FILE__) . "/ressources/class.html.tools.inc"; $htmlT = new htmltools_inc(); $lang = $htmlT->LanguageArray(); $users = new usersMenus(); if (!is_numeric($_SESSION["SWITCH_HIGH_MENUS"])) { $_SESSION["SWITCH_HIGH_MENUS"] = 1; } if ($users->AsAnAdministratorGeneric) { if ($_SESSION["SWITCH_HIGH_MENUS"] == 1) { $html = "\t\n\t\t\t<table style='width:80%;padding:0px;margin:0px;border:0px;margin-top:2px'>\n\t\t\t<tr>\n\t\t\t"; if ($_SESSION["uid"] == -100) { $html = $html . "<td><a href='#' OnClick=\"javascript:Loadjs('artica.settings.php?js=yes&func-AccountsInterface=yes');\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>Manager</a></td>\n\t\t\t<td style='color:white;font-size:11px;'> | </td>"; } $html = $html . "\n\t\t\t\t<td><a href='#' OnClick=\"javascript:logoff();\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>{logoff}</a></td>\n\t\t\t\t<td style='color:white;font-size:11px;'> | </td>\n\t\t\t<td><a href='#' OnClick=\"javascript:Loadjs('chg.language.php');\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>{language}: {$tpl->language}</a></td>\n\t\t\t<td style='color:white;font-size:11px;'> | </td>\n\t\t\t<td><a href='#' OnClick=\"javascript:Loadjs('artica.update.php?js=yes')\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>{version}: {$users->ARTICA_VERSION}</a></td>\n\t\t\t<td style='color:white;font-size:11px;'> | </td>\n\t\t\t<td><a href='#' OnClick=\"javascript:AjaxTopMenuTiny('div-high-menus','Inotify.php?switch-high=yes');\" \n\t\t\tstyle='color:#CCCCCC;font-size:11px;'>»»</a></td>\t\t\t\t\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t"; $_SESSION["SWITCH_HIGH_MENUS"] = 0; echo $tpl->_ENGINE_parse_body($html); } else { include_once dirname(__FILE__) . "/ressources/class.os.system.inc"; include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc"; $os = new os_system(); $cpunum = intval($users->CPU_NUMBER); $array_load = sys_getloadavg(); $org_load = $array_load[2]; $load = intval($org_load); $hash_mem = $os->realMemory(); $mem_used_p = $hash_mem["ram"]["percent"]; $mem_used_kb = FormatBytes($hash_mem["ram"]["used"]); $total = FormatBytes($hash_mem["ram"]["total"]); $swapar = $os->swap(); $max_vert_fonce = $cpunum; $max_vert_tfonce = $cpunum + 1; $max_orange = $cpunum * 0.75; $max_over = $cpunum * 2; $purc1 = $load / $cpunum; $pourc = round($purc1 * 100, 2); $color = "#5DD13D"; if ($load >= $max_orange) { $color = "#F59C44"; } if ($load > $max_vert_fonce) { $color = "#C5792D"; } if ($load > $max_vert_tfonce) { $color = "#83501F"; } if ($load >= $max_over) { $color = "#640000"; $text = "{overloaded}"; } $html = "\t\n\t\t\t<table style='width:80%;padding:0px;margin:0px;border:0px;margin-top:2px'>\n\t\t\t<tbody>\n\t\t\t<tr>"; if ($_SESSION["uid"] == -100) { $html = $html . "<td><a href='#' OnClick=\"javascript:Loadjs('artica.settings.php?js=yes&func-AccountsInterface=yes');\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>Manager</a></td>\n\t\t\t<td style='color:white;font-size:11px;'> | </td>"; } $html = $html . "<td nowrap><a href='#' OnClick=\"javascript:logoff();\" style='color:#CCCCCC;font-size:11px;text-decoration:underline'>{logoff}</a></td>\n\t\t\t<td style='color:white;font-size:11px;'> | </td>\t\t\n\t\t\t<td nowrap><a href='#' OnClick=\"javascript:Loadjs('chg.language.php');\" \n\t\t\tstyle='color:#CCCCCC;font-size:11px;'>{load}: {$org_load}</a></td>\t\n\t\t\t<td style='color:white;font-size:11px;' nowrap> | </td>\n\t\t\t<td nowrap><a href='#' OnClick=\"javascript:Loadjs('chg.language.php');\" \n\t\t\tstyle='color:#CCCCCC;font-size:11px;' nowrap>mem: {$mem_used_p}%</a></td>\n\t\t\t<td style='color:white;font-size:11px;' nowrap> | </td>\n<td nowrap><a href='#' OnClick=\"javascript:Loadjs('chg.language.php');\" \n\t\t\tstyle='color:#CCCCCC;font-size:11px;' nowrap>swap: {$swapar[0]}%</a></td>\t\n\t\t\t<td style='color:white;font-size:11px;'> | </td>\n\t\t\t<td nowrap><a href='#' OnClick=\"javascript:AjaxTopMenuTiny('div-high-menus','Inotify.php?switch-high=yes');\" \n\t\t\tstyle='color:#CCCCCC;font-size:11px;'>»»</a></td>\t\t\t\t\t\t\n\t\t\t</tR>\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t"; $_SESSION["SWITCH_HIGH_MENUS"] = 1; echo $tpl->_ENGINE_parse_body($html); } } }
function CHECK_MEMORY_USE_ACTION() { $sys = new os_system(); $unix = new unix(); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $MAX_MEM_ALERT_TTIME = "/etc/artica-postfix/pids/MAX_MEM_ALERT_TTIME"; $MAX_MEM_PRC_TTIME = "/etc/artica-postfix/pids/MAX_MEM_PRC_TTIME"; $ram_log[] = "Before Action = {$pourc}% {$ram_used}/{$ram_total}"; $w = new squid_watchdog(); $MonitConfig = $w->MonitConfig; $MAX_MEM_RST_MYSQL = $MonitConfig["MAX_MEM_RST_MYSQL"]; $MAX_MEM_RST_UFDB = $MonitConfig["MAX_MEM_RST_UFDB"]; $MAX_MEM_RST_APACHE = $MonitConfig["MAX_MEM_RST_APACHE"]; $MAX_MEM_RST_SQUID = $MonitConfig["MAX_MEM_RST_SQUID"]; $MAX_MEM_PRC = $MonitConfig["MAX_MEM_PRC"]; $text_ram = FormatBytes($ram_used, true) . "/" . FormatBytes($ram_total, true); Events("#1 Memory {$pourc}% Used:{$ram_used} Total: {$ram_total}"); $unix->send_email_events("Memory exceed {$MAX_MEM_PRC}% ({$text_ram}) [action=stop-services]", "MySQL and Categories database will be restarted\n", "system"); squid_admin_mysql(0, "Memory exceed {$MAX_MEM_PRC}% ({$text_ram}) [action=stop-services]", null, __FILE__, __LINE__); if ($MAX_MEM_RST_MYSQL == 1) { squid_admin_mysql(1, "Memory exceed - Restarting MySQL services", null, __FILE__, __LINE__); shell_exec("/etc/init.d/mysql restart --force --framework=" . basename(__FILE__)); shell_exec("/etc/init.d/squid-db restart --force"); shell_exec("/etc/init.d/ufdbcat restart --force"); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $text_ram = FormatBytes($ram_used, true) . "/" . FormatBytes($ram_total, true); $ram_log[] = "After restarting MySQL services {$pourc}% {$text_ram}"; } $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; Events("#2 Memory {$pourc}% Used:{$ram_used} Total: {$ram_total}"); if ($pourc < $MAX_MEM_PRC) { $report = $unix->ps_mem_report(); squid_admin_mysql(1, "Memory OK {$pourc}% [action=report]", @implode("\n", $ram_log) . "\n{$report}", __FILE__, __LINE__); @unlink($MAX_MEM_ALERT_TTIME); @unlink($MAX_MEM_PRC_TTIME); return; } if ($MAX_MEM_RST_UFDB == 1) { squid_admin_mysql(1, "Memory exceed {$pourc}% - Restarting Webfiltering service", null, __FILE__, __LINE__); shell_exec("/etc/init.d/ufdb restart --force --framework=" . basename(__FILE__)); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $text_ram = FormatBytes($ram_used, true) . "/" . FormatBytes($ram_total, true); $ram_log[] = "After restarting Webfiltering service {$pourc}% {$text_ram}"; } $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; Events("#3 Memory {$pourc}% Used:{$ram_used} Total: {$ram_total}"); if ($pourc < $MAX_MEM_PRC) { $report = $unix->ps_mem_report(); squid_admin_mysql(1, "Memory OK {$pourc}% [action=report]", @implode("\n", $ram_log) . "\n{$report}", __FILE__, __LINE__); @unlink($MAX_MEM_ALERT_TTIME); @unlink($MAX_MEM_PRC_TTIME); return; } if ($MAX_MEM_RST_APACHE == 1) { squid_admin_mysql(1, "Memory exceed {$pourc}% - Restarting Web Servers services", null, __FILE__, __LINE__); shell_exec("/etc/init.d/apache2 restart --force --framework=" . basename(__FILE__)); shell_exec("/etc/init.d/artica-webconsole restart --force --framework=" . basename(__FILE__)); shell_exec("/etc/init.d/squidguard-http restart --force --framework=" . basename(__FILE__)); shell_exec("/etc/init.d/artica-memcache restart --force --framework=" . basename(__FILE__)); shell_exec("/etc/init.d/ntopng restart --force --framework=" . basename(__FILE__)); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $ram_log[] = "After restarting web servers services {$pourc}% {$ram_used}/{$ram_total}"; } $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; Events("#4 Memory {$pourc}% Used:{$ram_used} Total: {$ram_total}"); if ($pourc < $MAX_MEM_PRC) { $report = $unix->ps_mem_report(); squid_admin_mysql(1, "Memory OK {$pourc}% [action=report]", @implode("\n", $ram_log) . "\n{$report}", __FILE__, __LINE__); @unlink($MAX_MEM_ALERT_TTIME); @unlink($MAX_MEM_PRC_TTIME); return; } if ($MAX_MEM_RST_SQUID == 1) { squid_admin_mysql(1, "Memory exceed {$pourc}% - Restarting Proxy service", null, __FILE__, __LINE__); stop_squid(true); start_squid(true); $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; $text_ram = FormatBytes($ram_used, true) . "/" . FormatBytes($ram_total, true); $ram_log[] = "After restarting Proxy service {$pourc}% {$text_ram}"; } $mem = $sys->realMemory(); $pourc = $mem["ram"]["percent"]; $ram_used = $mem["ram"]["used"]; $ram_total = $mem["ram"]["total"]; Events("#5 Memory {$pourc}% Used:{$ram_used} Total: {$ram_total}"); $report = $unix->ps_mem_report(); if ($pourc < $MAX_MEM_PRC) { squid_admin_mysql(1, "Memory OK {$pourc}% [action=report]", @implode("\n", $ram_log) . "\n{$report}", __FILE__, __LINE__); @unlink($MAX_MEM_ALERT_TTIME); @unlink($MAX_MEM_PRC_TTIME); return; } squid_admin_mysql(0, "Clean memory failed after restarting all services!!! [action=report]", @implode("\n", $ram_log) . "\n{$report}", __FILE__, __LINE__); }