function mysql_server() { if (!$GLOBALS["CLASS_USERS"]->mysql_installed) { return; } $master_pid = mysql_server_pid(); $mysqlversion = mysqld_version(); $l[] = "[ARTICA_MYSQL]"; $l[] = "service_name=APP_MYSQL_ARTICA"; $l[] = "master_version={$mysqlversion}"; $l[] = "service_cmd=/etc/init.d/mysql"; $l[] = "service_disabled=1"; $l[] = "watchdog_features=1"; $l[] = "family=system"; $status = $GLOBALS["CLASS_UNIX"]->PROCESS_STATUS($master_pid); events("mysqld status = {$status}", __FUNCTION__, __LINE__); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --watch --framework=" . __FILE__ . " >/dev/null 2>&1 &"); $GLOBALS["CLASS_UNIX"]->chown_func("mysql", "mysql", "/var/run/mysqld"); $GLOBALS["CLASS_UNIX"]->chown_func("mysql", "mysql", "/var/log/mysql"); @chmod("/var/run/mysqld", 0777); if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { events("mysqld not running....", __FUNCTION__, __LINE__); if (!$GLOBALS["DISABLE_WATCHDOG"]) { exec("{$GLOBALS["TAILBIN"]} -n 120 /var/lib/mysql/mysqld.err 2>&1", $tailR); $GLOBALS["CLASS_UNIX"]->send_email_events("MySQL not running, starting MySQL service and repair", @implode("\n", $GLOBALS["MYSQL_WATCHOG_EVENTS"]) . "\n" . @implode("\n", $tailR), "system"); if ($GLOBALS["SQUID_INSTALLED"]) { squid_admin_mysql(0, "MySQL not running, starting MySQL service and repair", @implode("\n", $GLOBALS["MYSQL_WATCHOG_EVENTS"]) . "\n" . @implode("\n", $tailR), __FILE__, __LINE__); } shell_exec2("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.initd-mysql.php >/dev/null 2>&1"); shell_exec2("{$GLOBALS["nohup"]} /etc/init.d/mysql start >/dev/null 2>&1 &"); shell_exec2("{$GLOBALS["nohup"]} /usr/share/artica-postfix/exec.exec.mysqld.crash.php --crashed --force >/dev/null 2>&1 &"); } $l[] = ""; return implode("\n", $l); return; } else { events("mysqld running -> exec.rrd.php --mysql ....", __FUNCTION__, __LINE__); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.rrd.php --mysql >/dev/null 2>&1 &"); events("mysqld running -> mysql_watchdog() ....", __FUNCTION__, __LINE__); mysql_watchdog(); } $l[] = "running=1"; $l[] = GetMemoriesOf($master_pid); $l[] = ""; $AS_CGROUP = false; if ($GLOBALS["CLASS_SOCKETS"]->EnableIntelCeleron == 1) { $AS_CGROUP = true; } if ($AS_CGROUP) { events("mysqld cgroup must be enabled ....", __FUNCTION__, __LINE__); $cgroups = new status_cgroups(); $limit = $cgroups->GetLimit($master_pid); if ($cgroups->GetLimit($master_pid) == "unlimited") { $cgroups->set_limit("mysql", $master_pid); } } if (!$GLOBALS["DISABLE_WATCHDOG"]) { mysqld_init_fix(); } exec("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.build.php --multi-status 2>&1", $result1s); $l[] = "" . @implode("\n", $result1s); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --engines --framework=" . __FILE__ . " >/dev/null 2>&1 &"); if (!$GLOBALS["DISABLE_WATCHDOG"]) { if (!$GLOBALS["CLASS_UNIX"]->is_socket("/var/run/mysqld/mysqld.sock")) { $xxx = array(); exec("/usr/bin/stat /var/run/mysqld/mysqld.sock 2>&1", $xxx); mysql_admin_mysql(0, "/var/run/mysqld/mysqld.sock no such socket [action=restart]", @implode("\n", $xxx)); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --restart --socketfailed --framework=" . __FILE__ . " >/dev/null 2>&1 &"); } $DisableMessaging = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableMessaging")); if ($DisableMessaging == 0) { $dir = "/var/lib/mysql/postfixlog"; $unix = new unix(); $countDefiles = $GLOBALS["CLASS_UNIX"]->COUNT_FILES($dir) / 2; if ($countDefiles > 500) { shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix.miltergrey.stats.php >/dev/null 2>&1 &"); } } } $CacheSchedules = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.mysqld.crash.php.check_crashed.time"); events("exec.mysqld.crash.php.check_crashed.time = {$CacheSchedules}/240Min", __FUNCTION__, __LINE__); if ($CacheSchedules > 240) { if (!system_is_overloaded()) { $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysqld.crash.php --crashed >/dev/null 2>&1 &"); if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec2($cmd); } } $CacheSchedules = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.mysql.start.php.test_sockets.time"); events("exec.mysql.start.php.test_sockets.time = {$CacheSchedules}/15Min", __FUNCTION__, __LINE__); if ($CacheSchedules > 15) { $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --test-sock >/dev/null 2>&1 &"); if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec2($cmd); } return implode("\n", $l); return; }
function mysql_server(){ if(!$GLOBALS["CLASS_USERS"]->mysql_installed ){return;} $program_path=$GLOBALS["CLASS_UNIX"]->find_program("mysqld"); if($program_path==null){ if(is_file("/usr/sbin/mysqld")){$program_path="/usr/sbin/mysqld";} } $pid_path=GetVersionOf("mysql-pid"); if($pid_path==null){ if($GLOBALS["VERBOSE"]){echo "Pid path is null -> PIDOF($program_path)";} $master_pid=$GLOBALS["CLASS_UNIX"]->PIDOF($program_path); }else{ $master_pid=trim(@file_get_contents($pid_path)); } if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){ if($GLOBALS["VERBOSE"]){echo "Pid $master_pid not in memory -> PIDOF($program_path)\n";} $master_pid=$GLOBALS["CLASS_UNIX"]->PIDOF($program_path); } $l[]="[ARTICA_MYSQL]"; $l[]="service_name=APP_MYSQL_ARTICA"; $l[]="master_version=".GetVersionOf("mysql-ver"); $l[]="service_cmd=mysql"; $l[]="service_disabled=1"; $l[]="pid_path=$pid_path"; $l[]="bin_path=$program_path"; $l[]="watchdog_features=1"; $l[]="family=system"; if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){ WATCHDOG("APP_MYSQL_ARTICA",'mysql'); $l[]="";return implode("\n",$l);return; }else{ mysql_watchdog(); } $l[]="running=1"; $l[]=GetMemoriesOf($master_pid); $l[]=""; return implode("\n",$l);return; }
function mysql_server() { if (!$GLOBALS["CLASS_USERS"]->mysql_installed) { return; } $program_path = $GLOBALS["CLASS_UNIX"]->find_program("mysqld"); if ($program_path == null) { if (is_file("/usr/sbin/mysqld")) { $program_path = "/usr/sbin/mysqld"; } } $pid_path = GetVersionOf("mysql-pid"); if ($pid_path == null) { if ($GLOBALS["VERBOSE"]) { echo "Pid path is null -> PIDOF({$program_path})"; } $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($program_path); } else { $master_pid = trim(@file_get_contents($pid_path)); } if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { if ($GLOBALS["VERBOSE"]) { echo "Pid {$master_pid} not in memory -> PIDOF({$program_path})\n"; } $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($program_path); } $mysqlversion = mysqld_version(); $l[] = "[ARTICA_MYSQL]"; $l[] = "service_name=APP_MYSQL_ARTICA"; $l[] = "master_version={$mysqlversion}"; $l[] = "service_cmd=/etc/init.d/mysql"; $l[] = "service_disabled=1"; $l[] = "pid_path={$pid_path}"; $l[] = "bin_path={$program_path}"; $l[] = "watchdog_features=1"; $l[] = "family=system"; $status = $GLOBALS["CLASS_UNIX"]->PROCESS_STATUS($master_pid); if ($GLOBALS["VERBOSE"]) { echo "Mysqld status = {$status}\n"; print_r($status); } shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --watch --framework=" . __FILE__ . " >/dev/null 2>&1 &"); $GLOBALS["CLASS_UNIX"]->chown_func("mysql", "mysql", "/var/run/mysqld"); $GLOBALS["CLASS_UNIX"]->chown_func("mysql", "mysql", "/var/log/mysql"); if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { if (!$GLOBALS["DISABLE_WATCHDOG"]) { $GLOBALS["CLASS_UNIX"]->send_email_events("MySQL not running, starting MySQL service", null, "system"); if ($GLOBALS["SQUID_INSTALLED"]) { squid_admin_mysql(0, "MySQL not running, starting MySQL service", null, __FILE__, __LINE__); } shell_exec2("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.initd-mysql.php >/dev/null 2>&1"); shell_exec2("{$GLOBALS["nohup"]} /etc/init.d/mysql start >/dev/null 2>&1 &"); } $l[] = ""; return implode("\n", $l); return; } else { shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.rrd.php --mysql >/dev/null 2>&1 &"); mysql_watchdog(); } $l[] = "running=1"; $l[] = GetMemoriesOf($master_pid); $l[] = ""; if (!$GLOBALS["DISABLE_WATCHDOG"]) { mysqld_init_fix(); } exec("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.build.php --multi-status 2>&1", $result1s); $l[] = "" . @implode("\n", $result1s); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --engines --framework=" . __FILE__ . " >/dev/null 2>&1 &"); if (!$GLOBALS["DISABLE_WATCHDOG"]) { if (!$GLOBALS["CLASS_UNIX"]->is_socket("/var/run/mysqld/mysqld.sock")) { $xxx = array(); exec("/usr/bin/stat /var/run/mysqld/mysqld.sock 2>&1", $xxx); mysql_admin_mysql(0, "/var/run/mysqld/mysqld.sock no such socket [action=restart]", @implode("\n", $xxx)); shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --restart --socketfailed --framework=" . __FILE__ . " >/dev/null 2>&1 &"); } $DisableMessaging = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableMessaging")); if ($DisableMessaging == 0) { $dir = "/var/lib/mysql/postfixlog"; $unix = new unix(); $countDefiles = $GLOBALS["CLASS_UNIX"]->COUNT_FILES($dir) / 2; if ($countDefiles > 500) { shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix.miltergrey.stats.php >/dev/null 2>&1 &"); } } } $CacheSchedules = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.mysqld.crash.php.check_crashed.time"); if ($CacheSchedules > 240) { if (!system_is_overloaded()) { $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysqld.crash.php --crashed >/dev/null 2>&1 &"); if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec2($cmd); } } $CacheSchedules = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.mysql.start.php.test_sockets.time"); if ($CacheSchedules > 15) { $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.mysql.start.php --test-sock >/dev/null 2>&1 &"); if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec2($cmd); } return implode("\n", $l); return; }