function proxy_status() { $ntmlauthenticators_array = array(); $COUNT_DE_CACHES_TEXT = null; $webfilters_paranoid_text = null; $users = new usersMenus(); if ($users->STATS_APPLIANCE) { return influxdb_status(); } if ($users->POSTFIX_INSTALLED) { return postfix_status(); } $sock = new sockets(); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } $EnableArticaMetaServer = intval($sock->GET_INFO("EnableArticaMetaServer")); $EnableNginx = intval($sock->GET_INFO("EnableNginx")); $EnableHaProxy = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableHaProxy")); if ($SQUIDEnable == 0) { if ($EnableArticaMetaServer == 1) { return meta_server_status(); } if ($EnableNginx == 1) { return nginx_server_status(); } if ($EnableHaProxy == 1) { return haproxy_server_status(); } } $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); $HTTrackInSquid = intval($sock->GET_INFO("HTTrackInSquid")); if (!is_numeric($SquidCacheLevel)) { $SquidCacheLevel = 4; } unset($_GET["_"]); $sock = new sockets(); if (!isset($_GET["ForceCache"])) { $md5CacheF = md5("proxy_status{$_SESSION["uid"]}{$tpl->language}" . serialize($_GET)); $cachefile = "/usr/share/artica-postfix/ressources/interface-cache/{$md5CacheF}"; if (file_time_sec_Web($cachefile) < 5) { return @file_get_contents($cachefile); } } if (isset($_GET["ForceCache"])) { $sock->getFrameWork("cmd.php?Global-Applications-Status=yes"); } $q = new mysql_squid_builder(); $tpl = new templates(); $page = CurrentPageName(); $ini = new Bs_IniHandler(); $users = new usersMenus(); $perc_cache = null; $active_resquests = null; $important_events = null; $CountDeServices = null; $icon = "disks-128-ok.png"; $rqs = null; $NOT_CATEGORIZED_ROW = null; $mgr_client_list = $q->COUNT_ROWS("mgr_client_list"); $SNMP_WALK = proxy_snmp(); $EnableUfdbGuard = intval($sock->EnableUfdbGuard()); $SquidUrgency = intval($sock->GET_INFO("SquidUrgency")); $MacToUidUrgency = intval($sock->GET_INFO("MacToUidUrgency")); $SquidSSLUrgency = intval($sock->GET_INFO("SquidSSLUrgency")); $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth")); $LogsWarninStop = intval($sock->GET_INFO("LogsWarninStop")); $SquidUFDBUrgency = intval($sock->GET_INFO("SquidUFDBUrgency")); $IsPortsConverted = intval($sock->GET_INFO("IsPortsConverted")); $SquidCacheFullHideWarn = intval($sock->GET_INFO("SquidCacheFullHideWarn")); $ActiveDirectoryEmergency = intval($sock->GET_INFO("ActiveDirectoryEmergency")); $BasicAuthenticatorEmergency = intval($sock->GET_INFO("BasicAuthenticatorEmergency")); $eCAPClamavEmergency = intval($sock->GET_INFO("eCAPClamavEmergency")); $ParanoidBlockerEmergency = intval($sock->GET_INFO("ParanoidBlockerEmergency")); $EnableeCapClamav = intval($sock->GET_INFO("EnableeCapClamav")); $curs = "OnMouseOver=\"this.style.cursor='pointer';\"\n\tOnMouseOut=\"this.style.cursor='auto'\""; $WebFiltering_blocked = null; $CACHES_AVG = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHES_AVG"), 1); $COUNT_DE_BLOCKED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_BLOCKED")); $SquidDebugAcls = intval($sock->GET_INFO("SquidDebugAcls")); $AsTransparent = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_TRANSPARENT")); $WATCHDOG_COUNT_EVENTS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/WATCHDOG_COUNT_EVENTS")); $COUNT_DE_CACHES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_CACHES")); $SUM_FAMILYSITES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/SUM_FAMILYSITES")); $WindowsUpdateCaching = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCaching")); $TOP_WEBSITE = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOP_WEBSITE")); $NOT_CATEGORIZED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/NOT_CATEGORIZED")); $CACHES_RATES = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOTAL_CACHED_ARRAY")); $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]); $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]); if ($users->AsProxyMonitor) { if ($EnableKerbAuth == 1) { $ntmlauthenticators = _ntmlauthenticators(); while (list($cpu, $purc) = each($ntmlauthenticators)) { $color = "black"; if ($purc > 95) { $color = "#d32d2d"; } $ntmlauthenticators_array[] = "\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"javscript:Loadjs('squid.ntmlauthenticators.php?cpu={$cpu}')\"\n\t\t\t\t\tstyle='text-decoration:underline;color:{$color}'>{ntlm_processes}: CPU#{$cpu} {$purc}%</a></td>\n\t\t\t\t\t</tr>"; } } } $SERVICES_STATUS = SERVICES_STATUS(); if (!is_array($SERVICES_STATUS)) { $CountDeServices = $SERVICES_STATUS; } else { $icon = "disks-128-warn.png"; $err = $SERVICES_STATUS; } $scriptEnd = "LoadAjaxTiny('active-directory-dash-infos','{$page}?active-directory-dash-infos=yes');"; $EnableUfdbGuard = $sock->EnableUfdbGuard(); $realsquidversion = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidRealVersion"); $sql = "SELECT COUNT(*) as tcount FROM proxy_ports WHERE enabled=1"; $results = $q->QUERY_SQL($sql); $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { $err[] = proxy_status_warning("MySQL error", $q->mysql_error_html(), "blur()"); } $COUNTDePorts = $ligne["tcount"]; $js_icon_stats = null; $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'><img src='img/statistics-24-grey.png'></div>"; $GotoNotCategorized = "GotoNotCategorized()"; $ActiveRequests_js = "Loadjs('squid.active.requests.php')"; $GotoNotCategorized_underline = "underline"; $ActiveRequests_underline = "underline"; $GotoMysQLAllWebsites_underline = "underline"; $GoToCachedStatistics = "GoToCachedStatistics()"; $GotoMysQLAllWebsites = "GotoMysQLAllWebsites()"; $LoadProxyUpdate = "LoadProxyUpdate();"; $LOadUfdbUpdate = "GoToWebfilteringDBstatus();"; if (!$users->AllowViewStatistics) { $GotoNotCategorized = "blur();"; $ActiveRequests_js = "blur()"; $GotoNotCategorized_underline = "none"; $ActiveRequests_underline = "none"; $GoToCachedStatistics = "blur()"; $GotoMysQLAllWebsites = "blur()"; $GotoMysQLAllWebsites_underline = "none"; } if (!$users->AsSquidAdministrator) { $LoadProxyUpdate = "blur()"; $LOadUfdbUpdate = "blur()"; } $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); if ($SquidPerformance < 2) { $prec = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHED_AVG"), 1); $PROXY_REQUESTS_NUMBER = @file_get_contents("{$GLOBALS["BASEDIR"]}/PROXY_REQUESTS_NUMBER"); $PROXY_REQUESTS_NUMBER = FormatNumber($PROXY_REQUESTS_NUMBER); if ($COUNT_DE_CACHES > 0) { $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024; $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB); } $js_icon_stats = "OnMouseOver=\"this.style.cursor='pointer';\"\n\t\tOnMouseOut=\"this.style.cursor='auto'\"\n\t\tOnClick=\"javascript:{$GoToCachedStatistics};\""; if (is_file("{$GLOBALS["BASEDIR"]}/CACHED_ROW_DAY")) { $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'>\n\t\t\t\t\t<img src='img/statistics-24.png'></div>"; } if ($SUM_FAMILYSITES > 0) { $SUM_FAMILYSITES = FormatNumber($SUM_FAMILYSITES); $SUM_FAMILYSITES_TEXT = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>{websites}:\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$GotoMysQLAllWebsites};\"\n\t\t\tstyle='text-decoration:{$GotoMysQLAllWebsites_underline}'>{$SUM_FAMILYSITES}</a></td>\n\t\t\t</tr>"; } } $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 ($NOT_CATEGORIZED > 0) { $NOT_CATEGORIZED = FormatNumber($NOT_CATEGORIZED); $NOT_CATEGORIZED_ROW = "<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$GotoNotCategorized}\"\n\t\tstyle='text-decoration:{$GotoNotCategorized_underline}'>{websites}: {$NOT_CATEGORIZED} {not_categorized}</a></td>\n\t\t</tr>"; } $TITLE_REQUESTS = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$ActiveRequests_js}\"\n\t\tstyle='text-decoration:{$ActiveRequests_underline}'>{$ActiveRequestsNumber} {active_requests}</a></td>\n\t\t</tr>"; if ($COUNTDePorts == 0) { $err[] = proxy_status_warning("{no_listening_port_defined}", "{no_listening_port_proxydefined_explain}", "GotoSquidPorts()"); } if ($SquidDebugAcls == 1) { $err[] = proxy_status_warning("{debug_acls}", "{debug_acls_explain}", "Loadjs('squid.acls.options.php')"); } if ($SNMP_WALK["ERROR"]) { $err[] = proxy_status_warning("SNMP:{need_to_restart_webconsole}", "{click_to_install}", "Loadjs('php-snmp.progress.php'"); } preg_match("#^([0-9]+)\\.([0-9]+)#", $realsquidversion, $re); $MAJOR = intval($re[1]); $MINOR = intval($re[2]); $INCOMPATIBLE = true; $REV = 0; $BUILD = 0; if ($MAJOR > 2) { if ($MINOR > 4) { $INCOMPATIBLE = false; } } if ($MAJOR == 0) { $INCOMPATIBLE = false; } if ($MAJOR == 4) { $INCOMPATIBLE = false; } if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $realsquidversion, $re)) { $REV = intval($re[3]); } if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $realsquidversion, $re)) { $BUILD = intval($re[4] . $re[5]); } if ($SQUIDEnable == 1) { if ($INCOMPATIBLE) { $incompatible_proxy_version = $tpl->_ENGINE_parse_body("{incompatible_proxy_version}"); $incompatible_proxy_version = str_replace("%s", $realsquidversion, $incompatible_proxy_version); $err[] = proxy_status_warning($incompatible_proxy_version, $incompatible_proxy_version, $LoadProxyUpdate); } $ArticaTechNetSquidRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetSquidRepo"))); $NEWVER = null; while (list($key, $array) = each($ArticaTechNetSquidRepo)) { $AVVERSION = $array["VERSION"]; $XREV = 0; $XBUILD = 0; preg_match("#^([0-9]+)\\.([0-9]+)#", $AVVERSION, $re); $XMAJOR = intval($re[1]); $XMINOR = intval($re[2]); if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $AVVERSION, $re)) { $XREV = intval($re[3]); } if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $AVVERSION, $re)) { $XBUILD = intval($re[4] . $re[5]); } $KEY = intval("{$XMAJOR}{$XMINOR}{$XREV}{$XBUILD}"); if ($MAJOR > $XMAJOR) { continue; } if ($GLOBALS["VERBOSE"]) { echo "<strong> squidver check {$XMAJOR}/{$XMINOR}/{$XREV}/{$XBUILD} - {$MAJOR}/{$MINOR}/{$REV}/{$BUILD}</strong>\n<br>"; } if ($XMAJOR > $MAJOR) { if ($GLOBALS["VERBOSE"]) { echo "<strong> squidver check {$XMAJOR}>{$MAJOR}</strong>\n<br>"; } $NEWVER = $AVVERSION; break; } if ($XMAJOR == $MAJOR) { if ($XMINOR > $MINOR) { $NEWVER = $AVVERSION; break; } } if ($XMAJOR == $MAJOR) { if ($XMINOR == $MINOR) { if ($XREV > $REV) { $NEWVER = $AVVERSION; break; } } } if ($XMAJOR == $MAJOR) { if ($XMINOR == $MINOR) { if ($XREV == $REV) { if ($XBUILD > $BUILD) { $NEWVER = $AVVERSION; break; } } } } } if ($users->AsSquidAdministrator) { if ($NEWVER != null) { $INFOS[] = status_info_event("{SQUID_NEWVERSION} {$NEWVER}", "{SQUID_NEWVERSION_TEXT}", $LoadProxyUpdate); } } } if ($SquidUrgency == 1) { $jsOn = "Loadjs('squid.urgency.php?justbutton=yes')"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $err[] = proxy_status_warning("{proxy_in_emergency_mode}", "{proxy_in_emergency_mode_explain}", $jsOn); $icon = "disks-128-red.png"; //proxy_in_emergency_mode //proxy_in_emergency_mode_explain } if ($SquidSSLUrgency == 1) { $jsOn = "Loadjs('squid.urgency.php?ssl=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-red.png"; $err[] = proxy_status_warning("{proxy_in_ssl_emergency_mode}", "{proxy_in_ssl_emergency_mode_explain}", $jsOn); } if ($MacToUidUrgency == 1) { $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-red.png"; $err[] = proxy_status_warning("{proxy_in_MacToUid_emergency_mode}", "{proxy_in_MacToUid_emergency_mode_explain}", $jsOn); } if ($SQUIDEnable == 1) { if ($SquidUFDBUrgency == 1) { $jsOn = "Loadjs('squid.urgency.php?ufdb=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-red.png"; $err[] = proxy_status_warning("{proxy_in_webfiltering_emergency_mode}", "{proxy_in_webfiltering_emergency_mode_explain}", $jsOn); } if ($EnableUfdbGuard == 1) { if ($users->CORP_LICENSE) { $ufdbguard_artica_cloud_version = ufdbguard_artica_cloud_version(); if ($ufdbguard_artica_cloud_version == 0) { $jsOn = "Loadjs('dansguardian2.articadb-progress.php')"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $important_events[] = status_important_event("{update_webfiltering_artica_databases}", "{update_webfiltering_artica_databases_not_updated}", $jsOn); } if ($ufdbguard_artica_cloud_version > 1) { $jsOn = "Loadjs('dansguardian2.articadb-progress.php')"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $important_events[] = status_important_event("{webfiltering_artica_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn); } } $ufdbguard_toulouse_cloud_version = ufdbguard_toulouse_cloud_version(); if ($ufdbguard_toulouse_cloud_version == 0) { $jsOn = "Loadjs('dansguardian2.articadb-progress.php')"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $important_events[] = status_important_event("{update_webfiltering_toulouse_databases}", "{update_webfiltering_toulouse_databases_not_updated}", $jsOn); } if ($ufdbguard_toulouse_cloud_version > 1) { $jsOn = "Loadjs('dansguardian2.articadb-progress.php')"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $important_events[] = status_important_event("{webfiltering_toulouse_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn); } } } if ($SQUIDEnable == 1) { if ($LogsWarninStop == 1) { $jsOn = "Loadjs('system.log.emergency.php');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $help = help_icon("{squid_logs_urgency}"); $text = texttooltip("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn); $icon = "disks-128-red.png"; $err[] = proxy_status_warning("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn); } } if ($SQUIDEnable == 1) { if ($IsPortsConverted == 0) { $jsOn = "Loadjs('squid.compile.progress.php');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{IsPortsConverted_requested}", "{squid_IsPortsConverted_explain}", $jsOn); } else { if ($AsTransparent > 0) { $FireHolConfigured = intval($sock->GET_INFO("FireHolConfigured")); if ($FireHolConfigured == 0) { $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{transparent_mode_issue}", "{squid_transparent_no_firewall}", $jsOn); } } } } $GoToCategoriesServiceA = "GoToCategoriesServiceA()"; $GotoAdConnection = "GotoAdConnection()"; $LoadMainDashProxy = "LoadMainDashProxy()"; $GoToServices = "GoToServices()"; $GoToUfdb = "GoToUfdb()"; $GoToCaches = "GoToCaches()"; $GoToCaches_underline = "underline"; if (!$users->AsDansGuardianAdministrator) { $GoToCategoriesServiceA = "blur()"; $GoToUfdb = "blur()"; } if (!$users->AsSquidAdministrator) { $GotoAdConnection = "blur()"; $LoadMainDashProxy = "blur()"; $GoToServices = "blur()"; $GoToCaches = "blur()"; $GoToCaches_underline = "none"; } if ($SQUIDEnable == 1) { $catz = new mysql_catz(); if ($catz->UfdbCatEnabled == 1) { $categories = $catz->ufdbcat("google.com"); if (!$catz->ok) { $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{APP_UFDBCAT}: {connection_error}", $catz->mysql_error, $GoToCategoriesServiceA); } } } if ($SQUIDEnable == 1) { if ($sock->SQUID_IS_EXTERNAL_LDAP()) { $tests = CHECK_SQUID_EXTERNAL_LDAP(); if ($tests != null) { $err[] = proxy_status_warning("{$tests}", "{$tests}", "GotoOpenldap()"); } } } if ($BasicAuthenticatorEmergency == 1) { $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{authentication_emergency_mode}", "{authentication_emergency_mode_explain}", $jsOn); } if ($SQUIDEnable == 1) { if ($EnableKerbAuth == 1) { if ($ActiveDirectoryEmergency == 1) { $jsOn = "Loadjs('squid.urgency.php?activedirectory=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{activedirectory_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn); } if (!$users->CORP_LICENSE) { $Days = 86400 * 30; $DayToLeft = 30; if (is_file("/usr/share/artica-postfix/ressources/class.pinglic.inc")) { include_once "/usr/share/artica-postfix/ressources/class.pinglic.inc"; $EndTime = $GLOBALS['ADLINK_TIME'] + $Days; $seconds_diff = $EndTime - time(); $DayToLeft = floor($seconds_diff / 3600 / 24); } $MAIN_ERROR = $tpl->_ENGINE_parse_body("{warn_no_license_activedirectory_30days}"); $MAIN_ERROR = str_replace("%s", $DayToLeft, $MAIN_ERROR); $important_events[] = status_important_event($MAIN_ERROR, $MAIN_ERROR, $jsOn); } if ($ActiveDirectoryEmergency == 0) { $IsConnected = IsKerconnected(); if ($IsConnected != "TRUE") { $err[] = proxy_status_warning("{proxy_is_not_configured_ad}", null, $GotoAdConnection); } } $TestLDAPAD = TestLDAPAD(); if ($TestLDAPAD != null) { $err[] = $TestLDAPAD; } $AdminAsSeenNTLMPerfs = intval($sock->GET_INFO("AdminAsSeenNTLMPerfs")); if ($AdminAsSeenNTLMPerfs == 0) { $err[] = proxy_status_warning("{NTLM_PERFORMANCES_NOT_DEFINED}", null, $GotoAdConnection); } } } if ($EnableeCapClamav == 1) { if ($eCAPClamavEmergency == 1) { $jsOn = "Loadjs('squid.urgency.php?eCAPClamavEmergency=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{eCAPClamav_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn); } } if ($ParanoidBlockerEmergency == 1) { $jsOn = "Loadjs('squid.urgency.php?ParanoidBlockerEmergency=yes');"; if (!$users->AsSquidAdministrator) { $jsOn = "blur()"; } $icon = "disks-128-warn.png"; $err[] = proxy_status_warning("{paranoid_emergency_mode}", "{paranoid_emergency_mode_explain}", $jsOn); } if ($SquidCacheFullHideWarn == 0) { if ($COUNT_DE_CACHES > 0) { if ($CACHES_AVG > 85) { $err[] = proxy_status_warning("{caches_are_full}", "{caches_are_full_explain}", $GoToCaches); } } } if ($COUNT_DE_CACHES > 0) { $COUNT_DE_MEMBERS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/MEMBERS_COUNT")); if ($COUNT_DE_MEMBERS > 15) { if ($COUNT_DE_CACHES < 20000) { $undersized_proxy_caches_explain = $tpl->_ENGINE_parse_body("{undersized_proxy_caches_explain}"); $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024; $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB); $undersized_proxy_caches_explain = str_replace("%S", $COUNT_DE_CACHES_TEXT, $undersized_proxy_caches_explain); $undersized_proxy_caches_explain = str_replace("%U", $COUNT_DE_MEMBERS, $undersized_proxy_caches_explain); if ($SquidCacheLevel > 0) { $err[] = proxy_status_warning("{undersized_proxy_caches}", $undersized_proxy_caches_explain, $GoToCaches); } } } } if (!$users->AsSquidAdministrator) { $err = array(); } if (count($err) > 0) { $errT[] = "<tr><td style='font-size:32px;color:#d32d2d;vertical-align:middle'>" . count($err) . " {issues}</td></tr>\n\t\t<tr><td colspan=2> </td></tr>\t\n\t\t\t\t"; } $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"]); $GotoParanoidMode = "GotoParanoidMode()"; $GotoParanoidMode_underline = "underline"; $GoToUfdb_underline = "underline"; if (!$users->AsDansGuardianAdministrator) { $GotoParanoidMode = "blur()"; $GoToUfdb = "blur()"; $GotoParanoidMode_underline = "none"; $GoToUfdb_underline = "none"; } $UfdbEnableParanoidMode = intval($sock->GET_INFO("UfdbEnableParanoidMode")); if ($UfdbEnableParanoidMode == 1) { $q = new mysql_squid_builder(); $webfilters_paranoid = $q->COUNT_ROWS("webfilters_paranoid"); if ($webfilters_paranoid > 0) { $webfilters_paranoid_text = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GotoParanoidMode}\"\n\t\tstyle='text-decoration:{$GotoParanoidMode_underline}'>{paranoid_mode}: " . FormatNumber($webfilters_paranoid) . " {rules}</a></td>\n\t\t</tr>"; } } if ($EnableUfdbGuard == 1) { if ($COUNT_DE_BLOCKED > 0) { $WebFiltering_blocked = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GoToUfdb}\"\n\t\tstyle='text-decoration:{$GoToUfdb_underline}'>{blocked_events}: " . FormatNumber($COUNT_DE_BLOCKED) . "</a></td>\n\t\t</tr>"; } } if (intval($ini->_params["SQUID"]["service_disabled"]) == 1) { if ($ini->_params["SQUID"]["running"] == 0) { $icon = "disks-128-red.png"; } } $mgr_client_list_TR = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoMgrClientList()\"\n\t\t\tstyle='text-decoration:underline'>{active_clients}: " . FormatNumber($SNMP_WALK["CLIENTS_NUMBER"]) . "</a></td>\n\t\t</tr>"; $active_resquests_js = "Loadjs('squid.active.requests.php')"; $active_resquests_underline = "underline"; if (!$users->AsSquidAdministrator) { $active_resquests_js = "blur()"; $active_resquests_underline = "none"; } if ($ActiveRequestsNumber > 1) { $active_resquests = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$active_resquests_js}\"\n\t\t\tstyle='text-decoration:underline'>{active_requests}: {$ActiveRequestsNumber}</a></td>\n\t\t</tr>"; } if (intval($WATCHDOG_COUNT_EVENTS) > 0) { $important_events[] = status_important_event("{$WATCHDOG_COUNT_EVENTS} {important_events_48h}", null, "GotoWatchdog()"); } $CACHES_AVG_COLOR = "black"; if ($CACHES_AVG > 85) { if ($SquidCacheFullHideWarn == 0) { $CACHES_AVG_COLOR = "#d32d2d"; } } if (count($important_events) > 0) { $important_events_text = "<tr><td colspan=2> </td></tr>" . @implode("\n", $important_events); } if ($SQUIDEnable == 0) { $icon = "disks-128-ok-grey.png"; } if (count($INFOS) > 0) { $INFOS[] = "<tr><td><br></td></tr>"; } if ($SquidCacheLevel == 0) { $SNMP_WALK["PERC_CACHE"] = 0; $SNMP_WALK["STORED_OBJECTS"] = 0; } $prec = intval($SNMP_WALK["PERC_CACHE"]); if ($prec > 0) { $perc_cache = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>{$prec}% {cache} ({currently})</td>\n\t\t</tr>"; } $REQUESTS = intval($SNMP_WALK["REQUESTS"]); if ($REQUESTS > 0) { $current_req = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($REQUESTS) . " {requests}</td>\n\t\t</tr>"; } if ($SNMP_WALK["CPU"] > 0) { $current_cpu_use = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>{$SNMP_WALK["CPU"]}% {cpu_use}</td>\n\t\t</tr>"; } $windowsUpdate = null; if ($WindowsUpdateCaching == 1) { $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/WindowsUpdate.state"; $ARRAY = unserialize(@file_get_contents($cacheFile)); if (intval($ARRAY["SIZEKB"]) > 4) { $windowsUpdate = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'> \n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWindowsUpdate()\"\n\t\t\tstyle='text-decoration:underline'>Windows Update:</a> " . FormatBytes($ARRAY["SIZEKB"]) . "</td>\n\t\t\t</tr>"; } } $HTTrack = null; if ($HTTrackInSquid == 1) { $HTTRackSize = $sock->GET_INFO("HTTRackSize"); if ($HTTRackSize > 0) { $HTTrack = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWebCopy()\"\n\t\t\tstyle='text-decoration:underline'>WebCopy:</a> " . FormatBytes($HTTRackSize / 1024) . "</td>\n\t\t\t</tr>"; } } if ($SNMP_WALK["STORED_OBJECTS"] > 0) { $current_stored_objects = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($SNMP_WALK["STORED_OBJECTS"]) . " {stored_objects}</td>\n\t\t</tr>"; } if ($SquidCacheLevel > 0) { if ($COUNT_DE_CACHES_TEXT != null) { $INFO_STORAGE_CACHE = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:{$CACHES_AVG_COLOR}'>\n\t\t\t\t\t\t{storage}: {$CACHES_AVG}% / {$COUNT_DE_CACHES_TEXT}</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>"; } } $CACHED_DETAILS_TOTAL = null; $NOT_CACHED_DETAILS_TOTAL = null; if ($TOTALS_CACHED > 0) { $CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{cached}: " . FormatBytes($TOTALS_CACHED / 1024) . "</a>\n\t\t\t</td>\n\t\t</tr>\n\t"; } if ($TOTALS_NOT_CACHED > 0) { $NOT_CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{not_cached}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t"; } if (!$users->AsSquidAdministrator) { $important_events_text = null; $errT = array(); $windowsUpdate = null; $mgr_client_list_TR = null; } $icon = imgtootltip($icon, "position:right:{configure_your_proxy}", "{$LoadMainDashProxy}"); $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' style='width:128px' >\n\t\t\t{$icon}\n\t\t\t<div id='active-directory-dash-infos'>" . active_directory_infos() . "</div>\t\n\t\t</td>\n\t\t<td>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:30px'>\n\t\t\t\t" . texttooltip("{your_proxy}", "{configure_your_proxy}", "{$LoadMainDashProxy}") . "\n\t\t\t\t <span style='font-size:22px'>[ <a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.infos.php');\"\n\t\t\t\tstyle='text-decoration:underline'>Infos.</a> ]</span>\t\t\n\t\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<!-- perc_cache -->\n\t\t\t{$perc_cache}\n\t\t\t<!-- TOTALS_CACHED:{$TOTALS_CACHED} -->\n\t\t\t{$CACHED_DETAILS_TOTAL}\n\t\t\t<!-- TOTALS NOT CACHED:{$TOTALS_NOT_CACHED} -->\n\t\t\t{$NOT_CACHED_DETAILS_TOTAL}\n\t\t\t<!-- windowsUpdate -->\n\t\t\t{$windowsUpdate}\n\t\t\t<!-- HTTrack -->\n\t\t\t{$HTTrack}\n\t\t\t<!-- current_req -->\n\t\t\t{$current_req}\n\t\t\t<!-- SUM_FAMILYSITES_TEXT -->\n\t\t\t{$SUM_FAMILYSITES_TEXT}\n\t\t\n\t\t\t{$active_resquests}\n\t\t\t{$mgr_client_list_TR}\n\t\t\t{$rqs}\n\t\t\t\t" . @implode("", $ntmlauthenticators_array) . "\n\t\t\t\n\t\t\t\n\t\t<!-- WebFiltering_blocked -->\n\t\t{$WebFiltering_blocked}\n\t\t<!-- webfilters_paranoid -->\n\t\t{$webfilters_paranoid_text}\t\n\t\t<!-- INFO_STORAGE_CACHE -->\n\t\t{$INFO_STORAGE_CACHE}\n\t\t\n\t\t\n\t\t\n\t<!-- current_stored_objects -->\n\t\t\t{$current_stored_objects}\n\t<!-- TITLE_REQUESTS -->\n\t\t\t{$TITLE_REQUESTS}\n\t<!-- TOP_GRAPHS -->\n\t\t\t" . TOP_GRAPHS() . "\n\t\t\t{$CountDeServices}\n\t\t\t" . @implode("", $INFOS) . "\n\t\t\t" . @implode("", $errT) . "\n\t\t\t" . @implode("", $err) . "\n\t\t\t{$important_events_text}\n\t\t\t\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjaxSilent('proxy_dashboard_counters','{$page}?proxy_dashboard_counters=yes');\n\t</script>\n\t"; $html = $tpl->_ENGINE_parse_body($html); if (!is_dir("/usr/share/artica-postfix/ressources/interface-cache")) { @mkdir("/usr/share/artica-postfix/ressources/interface-cache"); } @file_put_contents($cachefile, $html); return $html; }
function start_watchdog() { if ($GLOBALS["VERBOSE"]) { $GLOBALS["FORCE"] = true; } $pidtime = "/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.time"; $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtimeNTP = "/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.ntp.time"; $unix = new unix(); $pid = $unix->get_pid_from_file($pidFile); if ($unix->process_exists($pid)) { $pptime = $unix->PROCCESS_TIME_MIN($pid, 10); if ($GLOBALS["VERBOSE"]) { echo "Process already running PID {$pid} since {$pptime}Mn\n"; } return; } @file_put_contents($pidFile, getmypid()); $time = $unix->file_time_min($pidtime); $sock = new sockets(); $nohup = $unix->find_program("nohup"); $php = $unix->LOCATE_PHP5_BIN(); $NtpdateAD = intval($sock->GET_INFO("NtpdateAD")); $EnableFailover = $sock->GET_INFO("EnableFailover"); $GLOBALS["EnableFailover"] = $sock->GET_INFO("EnableFailover"); $SQUIDEnable = trim($sock->GET_INFO("SQUIDEnable")); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if (!is_numeric($EnableFailover)) { $EnableFailover = 1; } if (!is_file("/usr/share/squid3/icons/silk/bigshield-256.png")) { @copy("/usr/share/artica-postfix/img/bigshield-256.png", "/usr/share/squid3/icons/silk/bigshield-256.png"); } if (!is_file("/usr/share/squid3/icons/silk/logo-artica-64.png")) { @copy("/usr/share/artica-postfix/img/logo-artica-64.png", "/usr/share/squid3/icons/silk/logo-artica-64.png"); } $articafiles = $unix->SquidPHPFiles(); while (list($num, $filename) = each($articafiles)) { $filepath = "/usr/share/artica-postfix/{$num}"; @chmod($filepath, 0755); @chown($filepath, "squid"); @chgrp($filepath, "squid"); } @unlink($pidtime); @file_put_contents($pidtime, time()); Events("* * * * * * * * * * * * * * * * START WATCHDOG * * * * * * * * * * * * * * * *"); if ($SQUIDEnable == 0) { die; } Events("Testing Memory"); CHECK_MEMORY_USE(); PARANOID_MODE_CLEAN(); Events("Testing Active Directory"); TEST_ACTIVE_DIRECTORY(); Events("Testing Active Directory Emergency...."); CheckActiveDirectoryEmergency(); Events("Testing port...."); TEST_PORT(); Events("ALL_STATUS"); ALL_STATUS(true); $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig"))); $MonitConfig["EnableFailover"] = $EnableFailover; $MonitConfig = watchdog_config_default($MonitConfig); $unix->chmod_func(0755, "/etc/artica-postfix/settings/Daemons/*"); @mkdir("{$GLOBALS["ARTICALOGDIR"]}/squid/mysql-failed", 0755, true); $unix->chown_func("squid", "squid", "{$GLOBALS["ARTICALOGDIR"]}/squid/mysql-failed"); if (!$GLOBALS["VERBOSE"]) { if ($time < $MonitConfig["MIN_INTERVAL"]) { return; } } $STAMP_MAX_RESTART_TIME = $unix->file_time_min($GLOBALS["STAMP_MAX_RESTART"]); if ($STAMP_MAX_RESTART_TIME > 60) { @unlink($GLOBALS["STAMP_MAX_RESTART"]); } //Events("Start: ". basename($pidtime).":{$time}Mn / {$MonitConfig["MIN_INTERVAL"]}Mn STAMP_MAX_RESTART_TIME={$STAMP_MAX_RESTART_TIME}Mn"); if (!is_file("/etc/artica-postfix/SQUID_TEMPLATE_DONE")) { mysql_admin_mysql(1, "SQUID_TEMPLATE_DONE: No such file, launch build template action...", null, __FILE__, __LINE__); shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.squid.php --tpl-save >/dev/null 2>&1 &"); } $GLOBALS["ALL_SCORES"] = 0; $pid = SQUID_PID(); $processtime = $unix->PROCCESS_TIME_MIN($pid); if (!$GLOBALS["FORCE"]) { if ($processtime < 2) { return; } } verify_var_log(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after START"; Checks_mgrinfos($MonitConfig, true); ntlmauthenticator(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after ntlmauthenticator()"; CheckOldCachesLog(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after CheckOldCachesLog()"; DeletedCaches(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after DeletedCaches()"; caches_center(true); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after caches_center()"; squid_stores_status(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after squid_stores_status()"; squid_mem_status(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after squid_mem_status()"; squid_memory_monitor(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after squid_memory_monitor()"; caches_size(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after caches_size()"; if ($MonitConfig["watchdog"] == 0) { if ($GLOBALS["VERBOSE"]) { echo "Watchdog is disabled...\n"; } counters(true); return; } if ($processtime < 5) { return; } if ($GLOBALS["VERBOSE"]) { echo "Check DefaultRoute\n"; } DefaultRoute(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after DefaultRoute()"; if ($GLOBALS["VERBOSE"]) { echo "Check UFDB\n"; } Events("CheckUFDBGuardLocalThreads...."); CheckUFDBGuardLocalThreads(); Events("CheckUFDBGuardConfig...."); CheckUFDBGuardConfig(); Events("CheckUFDBGuardPort...."); CheckUFDBGuardPort(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after CheckUFDBGuardConfig()"; if ($GLOBALS["VERBOSE"]) { echo "PING_GATEWAY()\n"; } Events("PING_GATEWAY...."); PING_GATEWAY(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after PING_GATEWAY()"; if ($GLOBALS["VERBOSE"]) { echo "SwapWatchdog()\n"; } Events("SwapWatchdog...."); SwapWatchdog(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after SwapWatchdog()"; if ($GLOBALS["VERBOSE"]) { echo "Checks_Winbindd()\n"; } Events("Checks_Winbindd...."); Checks_Winbindd(); if ($GLOBALS["VERBOSE"]) { echo "CheckStoreDirs()\n"; } $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after Checks_Winbindd()"; Events("CheckStoreDirs...."); CheckStoreDirs(); Events("CHECK_SQUID_EXTERNAL_LDAP()...."); CHECK_SQUID_EXTERNAL_LDAP(); if ($GLOBALS["VERBOSE"]) { echo "MemBoosters()\n"; } $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after CheckStoreDirs()"; Events("MemBoosters...."); MemBoosters(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after MemBoosters()"; if ($GLOBALS["VERBOSE"]) { echo "SwapCache()\n"; } Events("SwapCache...."); SwapCache($MonitConfig); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after SwapCache()"; Events("MaxSystemLoad...."); MaxSystemLoad($MonitConfig); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after MaxSystemLoad()"; if ($GLOBALS["VERBOSE"]) { echo "CheckAvailableSize()\n"; } Events("CheckAvailableSize...."); CheckAvailableSize(); $GLOBALS["ALL_SCORES_WHY"][] = "score: {$GLOBALS["ALL_SCORES"]} after CheckAvailableSize()"; Events("FailOverCheck...."); FailOverCheck(); Events("DNSCACHE...."); DNSCACHE(); Events("cache_center_status...."); cache_center_status(); if ($GLOBALS["VERBOSE"]) { echo "counters()\n"; } counters(true); if ($NtpdateAD == 1) { $pidtimeNTPT = $unix->file_time_min($pidtimeNTP); if ($pidtimeNTPT > 120) { if ($GLOBALS["VERBOSE"]) { echo "/usr/share/artica-postfix/exec.kerbauth.php --ntpdate\n"; } shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.kerbauth.php --ntpdate >/dev/null 2>&1 &"); @unlink($pidtimeNTP); @file_put_contents($pidtimeNTP, time()); } } Events("* * * * * * * * * * * * * * * * END WATCHDOG * * * * * * * * * * * * * * * *"); }