本文整理汇总了PHP中unix::KILL_PROCESS方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::KILL_PROCESS方法的具体用法?PHP unix::KILL_PROCESS怎么用?PHP unix::KILL_PROCESS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::KILL_PROCESS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
function uninstall()
{
$unix = new unix();
$sock = new sockets();
build_progress("{uninstall}", 15);
$pid = sealion_pid();
if ($unix->process_exists($pid)) {
for ($i = 0; $i < 6; $i++) {
build_progress("{stop_service} {$i}/5", 30);
$unix->KILL_PROCESS($pid, 9);
$pid = sealion_pid();
if ($unix->process_exists($pid)) {
break;
}
}
}
build_progress("{uninstall}", 50);
chdir("/usr/local/sealion-agent");
system("cd /usr/local/sealion-agent");
system("./uninstall.sh");
chdir("/root");
system("cd /root");
$unix = new unix();
$rm = $unix->find_program("rm");
if (is_dir("/usr/local/sealion-agent")) {
shell_exec("rm -rf /usr/local/sealion-agent");
}
build_progress("{uninstall} {done}", 100);
}
示例2: reload
function reload()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
start(true);
return;
}
buildconfig();
BuildSSLTables();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: Reloading PID {$pid}\n";
}
$unix->KILL_PROCESS($pid, 1);
}
示例3: KillSquid
function KillSquid()
{
$unix = new unix();
$pidof = $unix->find_program("pidof");
$kill = $unix->find_program("kill");
if (strlen($pidof) < 4) {
return;
}
exec("{$pidof} {$GLOBALS["SQUIDBIN"]}", $results);
$f = explode(" ", @implode("", $results));
while (list($num, $val) = each($f)) {
$val = trim($val);
if (!is_numeric($val)) {
continue;
}
echo "Starting......: " . date("H:i:s") . " stopping pid {$val}\n";
$unix->KILL_PROCESS($val, 9);
usleep(10000);
}
}
示例4: repair_locks
function repair_locks()
{
$Myfile = basename(__FILE__);
$timeFile = "/etc/artica-postfix/pids/{$Myfile}." . __FUNCTION__ . ".time";
$pidFile = "/etc/artica-postfix/pids/{$Myfile}." . __FUNCTION__ . ".pid";
$unix = new unix();
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid, $Myfile)) {
writelogs("Die, already process {$pid} running ", __FUNCTION__, __FILE__, __LINE__);
return;
}
$time = $unix->file_time_min($timeFile);
if ($time < 5) {
writelogs("Die, No more than 5mn ", __FUNCTION__, __FILE__, __LINE__);
return;
}
@unlink($timeFile);
@mkdir(dirname($timeFile), 0755, true);
@file_put_contents($timeFile, time());
@file_put_contents($pidFile, getmypid());
echo "Starting......: " . date("H:i:s") . " Stopping postfix\n";
shell_exec("{$GLOBALS["postfix"]} stop");
$daemon_directory = $unix->POSTCONF_GET("daemon_directory");
$queue_directory = $unix->POSTCONF_GET("queue_directory");
echo "Starting......: " . date("H:i:s") . " Daemon directory: {$daemon_directory}\n";
echo "Starting......: " . date("H:i:s") . " Queue directory.: {$queue_directory}\n";
$pid = $unix->PIDOF("{$daemon_directory}/master", true);
echo "Starting......: " . date("H:i:s") . " Process \"{$daemon_directory}/master\" PID:\"{$pid}\"\n";
for ($i = 0; $i < 10; $i++) {
if (is_numeric($pid)) {
if ($pid > 5) {
echo "Starting......: " . date("H:i:s") . " Killing bad pid {$pid}\n";
$unix->KILL_PROCESS($pid, 9);
sleep(1);
}
} else {
echo "Starting......: " . date("H:i:s") . " No {$daemon_directory}/master ghost process\n";
break;
}
$pid = $unix->PIDOF("{$daemon_directory}/master");
echo "Starting......: " . date("H:i:s") . " Process \"{$daemon_directory}/master\" PID:\"{$pid}\"\n";
}
if (file_exists("{$daemon_directory}/master.lock")) {
echo "Starting......: " . date("H:i:s") . " Delete {$daemon_directory}/master.lock\n";
@unlink("{$daemon_directory}/master.lock");
}
if (file_exists("{$queue_directory}/pid/master.pid")) {
echo "Starting......: " . date("H:i:s") . " Delete {$queue_directory}/pid/master.pid\n";
@unlink("{$queue_directory}/pid/master.pid");
}
if (file_exists("{$queue_directory}/pid/inet.127.0.0.1:33559")) {
echo "Starting......: " . date("H:i:s") . " {$queue_directory}/pid/inet.127.0.0.1:33559\n";
@unlink("{$queue_directory}/pid/inet.127.0.0.1:33559");
}
echo "Starting......: " . date("H:i:s") . " Starting postfix\n";
exec("{$GLOBALS["postfix"]} start -v 2>&1", $results);
while (list($template, $nothing) = each($results)) {
echo "Starting......: " . date("H:i:s") . " Starting postfix {$nothing}\n";
}
}
示例5: mQuotaWebFilter
function mQuotaWebFilter()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/exec.squid.stats.hours.php.mQuotaWebFilter.pid";
$timefile = "/etc/artica-postfix/pids/exec.squid.stats.hours.php.mQuotaWebFilter.time";
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance > 1) {
die;
}
$pid = $unix->get_pid_from_file($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
$rpcessTime = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$rpcessTime}Mn\n";
}
if ($rpcessTime < 10) {
return;
}
$unix->KILL_PROCESS($pid, 9);
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 30) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
build_last_hour();
$ipClass = new IP();
if ($GLOBALS["VERBOSE"]) {
echo "Time File: {$timefile}\n";
}
$ARRAY["TIME_BUILD"] = time();
$q = new mysql_squid_builder();
$influx = new influx();
$date_from = InfluxQueryFromUTC(strtotime("-1 hour"));
$sql = "SELECT SUM(SIZE) as size,USERID,IPADDR,MAC,CATEGORY FROM access_log GROUP BY time(1h) ,USERID,IPADDR,MAC,CATEGORY WHERE time > {$date_from}s";
if ($GLOBALS["VERBOSE"]) {
echo "{$sql}\n";
}
$main = $influx->QUERY_SQL($sql);
foreach ($main as $row) {
$CATEGORY = $row->CATEGORY;
$USERID = strtolower($row->USERID);
$IPADDR = $row->IPADDR;
$MAC = $row->MAC;
$size = intval($row->size);
if ($size == 0) {
continue;
}
if ($CATEGORY != null) {
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$USERID])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$USERID] = $size;
} else {
$size_old = intval($ARRAY["categories"][$CATEGORY]["HOUR"][$USERID]);
$size_old = $size_old + $size;
$ARRAY["categories"][$CATEGORY]["HOUR"][$USERID] = $size_old;
}
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR] = $size;
} else {
$size_old = $ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR];
$size_old = $size_old + $size;
if ($size_old == 0) {
echo "Warning {$CATEGORY}/{$IPADDR} {$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR]} + {$size} = 0\n";
}
$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR] = $size_old;
}
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$MAC])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$MAC] = $size;
} else {
$size_old = $ARRAY["categories"][$CATEGORY]["HOUR"][$MAC];
$size_old = $size_old + $size;
$ARRAY["categories"][$CATEGORY]["HOUR"][$MAC] = $size_old;
}
}
if (!isset($ARRAY["UID"][$USERID]["HOUR"])) {
$ARRAY["UID"][$USERID]["HOUR"] = $size;
} else {
$size_old = $ARRAY["UID"][$USERID]["HOUR"];
$size_old = $size_old + $size;
$ARRAY["UID"][$USERID]["HOUR"] = $size_old;
}
if (!isset($ARRAY["IPADDR"][$IPADDR]["HOUR"])) {
$ARRAY["IPADDR"][$IPADDR]["HOUR"] = $size;
} else {
$size_old = $ARRAY["IPADDR"][$IPADDR]["HOUR"];
$size_old = $size_old + $size;
$ARRAY["IPADDR"][$IPADDR]["HOUR"] = $size_old;
}
if ($ipClass->IsvalidMAC($MAC)) {
if (!isset($ARRAY["MAC"][$MAC]["HOUR"])) {
$ARRAY["MAC"][$MAC]["HOUR"] = $size;
} else {
//.........这里部分代码省略.........
示例6: logs_urgency
function logs_urgency($aspid = false)
{
$unix = new unix();
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$Pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($GLOBALS["VERBOSE"]) {
echo "TimeFile: {$TimeFile}\n";
}
if ($GLOBALS["VERBOSE"]) {
echo "Pidfile: {$Pidfile}\n";
}
if (!$GLOBALS["FORCE"]) {
$timefile = $unix->file_time_min($TimeFile);
if ($timefile < 60) {
return;
}
}
if ($aspid) {
$pid = $unix->get_pid_from_file($Pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeprc = $unix->PROCCESS_TIME_MIN($pid);
if ($timeprc > 60) {
$unix->KILL_PROCESS($pid, 9);
} else {
if ($GLOBALS["VERBOSE"]) {
echo "Aborting Task already running pid {$pid} " . __FUNCTION__ . "()\n";
}
return;
}
}
@file_put_contents($Pidfile, getmypid());
}
$df = $unix->find_program("df");
$php = $unix->LOCATE_PHP5_BIN();
exec("{$df} -h /var/log 2>&1", $results);
while (list($index, $line) = each($results)) {
if (!preg_match("#^(.+?)\\s+([0-9\\.,]+)([A-Z])\\s+([0-9\\.,]+).*?\\s+([0-9\\.,]+)%\\s+#", $line, $re)) {
continue;
}
$purc = $re[5];
break;
}
if ($purc < 100) {
return;
}
$echo = $unix->find_program("echo");
$logf["artica-router.log"] = true;
$logf["artica-smtp.log"] = true;
$logf["auth.log"] = true;
$logf["daemon.log"] = true;
$logf["debug"] = true;
$logf["dpkg.log"] = true;
$logf["fetchmail.log"] = true;
$logf["kern.log"] = true;
$logf["mail.err"] = true;
$logf["mail.log"] = true;
$logf["mail.warn"] = true;
$logf["messages"] = true;
$logf["syslog"] = true;
$logf["user.log"] = true;
$logf["lighttpd/access.log"] = true;
$logf["squid/store.log"] = true;
$logf["apache2/unix-varrunnginx-authenticator.sock/nginx.access.log"] = true;
$logf["apache2/unix-varrunnginx-authenticator.sock/nginx.error.log"] = true;
$logf["artica-postfix/framework.log"] = true;
$logf["samba/log.winbindd"] = true;
$logf["samba/log.winbindd.old"] = true;
$logf["clamav/clamav.log"] = true;
$logf["clamav/clamd.log"] = true;
$logf["clamav/freshclam.log"] = true;
$sock = new sockets();
$BaseWorkDirUrgency = "/home/artica/squidlogs_urgency";
$LogsRotateDefaultSizeRotation = $sock->GET_INFO("LogsRotateDefaultSizeRotation");
if (!is_numeric($LogsRotateDefaultSizeRotation)) {
$LogsRotateDefaultSizeRotation = 100;
}
$LogRotatePath = $sock->GET_INFO("LogRotatePath");
if ($LogRotatePath == null) {
$LogRotatePath = "/home/logrotate";
}
$LogRotatePath = "{$LogRotatePath}/work/cache_logs";
while (list($filname, $line) = each($logf)) {
$path = "/var/log/{$filname}";
if (!is_file($path)) {
continue;
}
shell_exec("{$echo} \" \" > {$path} 2>&1");
}
}
示例7: build
function build()
{
$timefile = "/etc/artica-postfix/pids/exec.squid.rotate.php.build.time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
// /etc/artica-postfix/pids/exec.squid.rotate.php.build.time
$sock = new sockets();
$unix = new unix();
$ls = $unix->find_program("ls");
$pid = $unix->PIDOF_PATTERN(basename(__FILE__));
$MyPid = getmypid();
if ($MyPid != $pid) {
if ($unix->process_exists($pid)) {
$timeFile = $unix->PROCESS_TIME_INT($pid);
$pidCmdline = @file_get_contents("/proc/{$pid}/cmdline");
if ($timeFile < 30) {
echo "Already PID {$pid} is running since {$timeFile}Mn\n";
squid_admin_mysql(1, "[LOG ROTATION]: Skip task, already running {$pid} since {$timeFile}Mn", "Running: {$pidCmdline}", __FILE__, __LINE__);
die;
} else {
squid_admin_mysql(1, "[LOG ROTATION]: Killing old task {$pid} running more than 30mn ({$timeFile}Mn)", "Running: {$pidCmdline}", __FILE__, __LINE__);
$unix->KILL_PROCESS($pid);
}
}
}
@file_put_contents($pidfile, getmypid());
if (!$GLOBALS["FORCE"]) {
$time = $unix->file_time_min($timefile);
if ($time < 60) {
echo "Only each 60mn\n";
die;
}
@unlink($timefile);
@file_put_contents($timefile, time());
}
$syslog = new mysql_storelogs();
$SquidLogRotateFreq = intval($sock->GET_INFO("SquidLogRotateFreq"));
if ($SquidLogRotateFreq < 10) {
$SquidLogRotateFreq = 1440;
}
$LastRotate = $unix->file_time_min("/etc/artica-postfix/pids/squid-rotate-cache.time");
$LogsRotateDefaultSizeRotation = $sock->GET_INFO("LogsRotateDefaultSizeRotation");
$SquidRotateOnlySchedule = intval($sock->GET_INFO("SquidRotateOnlySchedule"));
if (!is_numeric($LogsRotateDefaultSizeRotation)) {
$LogsRotateDefaultSizeRotation = 100;
}
$BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
if ($BackupMaxDaysDir == null) {
$BackupMaxDaysDir = "/home/logrotate_backup";
}
$BackupSquidLogsUseNas = intval($sock->GET_INFO("BackupSquidLogsUseNas"));
$SquidRotateAutomount = intval($sock->GET_INFO("SquidRotateAutomount"));
$SquidRotateClean = intval($sock->GET_INFO("SquidRotateClean"));
$SquidRotateAutomountRes = $sock->GET_INFO("SquidRotateAutomountRes");
$SquidRotateAutomountFolder = $sock->GET_INFO("SquidRotateAutomountFolder");
if ($SquidRotateAutomount == 1) {
shell_exec("{$ls} /automounts/{$SquidRotateAutomountRes} >/dev/null 2>&1");
if (ifdirMounted("/automounts/{$SquidRotateAutomountRes}")) {
$BackupSquidLogsUseNas = 0;
$BackupMaxDaysDir = "/automounts/{$SquidRotateAutomountRes}/{$SquidRotateAutomountFolder}";
} else {
$syslog->events("/automounts/{$SquidRotateAutomountRes} not mounted", __FUNCTION__, __LINE__);
squid_admin_mysql(1, "[ROTATE],Auto-mount {$SquidRotateAutomountRes} not mounted", null, __FILE__, __LINE__);
}
}
$BackupMaxDaysDir = str_replace("//", "/", $BackupMaxDaysDir);
$BackupMaxDaysDir = str_replace("\\", "/", $BackupMaxDaysDir);
if (!is_dir($BackupMaxDaysDir)) {
@mkdir($BackupMaxDaysDir, 0755, true);
}
if (!is_dir($BackupMaxDaysDir)) {
$syslog->events("{$BackupMaxDaysDir} not such directory or permission denied", __FUNCTION__, __LINE__);
squid_admin_mysql(1, "[ROTATE],{$BackupMaxDaysDir} not such directory or permission denied", null, __FILE__, __LINE__);
if ($SquidRotateAutomount == 1) {
$BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
if ($BackupMaxDaysDir == null) {
$BackupMaxDaysDir = "/home/logrotate_backup";
}
if (!is_dir($BackupMaxDaysDir)) {
@mkdir($BackupMaxDaysDir, 0755, true);
}
$syslog->events("Return back to {$BackupMaxDaysDir}", __FUNCTION__, __LINE__);
} else {
return;
}
}
$php = $unix->LOCATE_PHP5_BIN();
$hostname = $unix->hostname_g();
$InFluxBackupDatabaseDir = $sock->GET_INFO("InFluxBackupDatabaseDir");
if ($InFluxBackupDatabaseDir == null) {
$InFluxBackupDatabaseDir = "/home/artica/influx/backup";
}
$LogRotatePath = $sock->GET_INFO("LogRotatePath");
if ($LogRotatePath == null) {
$LogRotatePath = "/home/logrotate";
}
$LogRotateAccess = "{$LogRotatePath}/access";
$LogRotateTail = "{$LogRotatePath}/tail";
$LogRotateCache = "{$LogRotatePath}/cache";
$syslog->events("Launch rotation only by schedule.: {$SquidRotateOnlySchedule}", __FUNCTION__, __LINE__);
$syslog->events("SquidLogRotateFreq...............: {$SquidLogRotateFreq}Mn", __FUNCTION__, __LINE__);
//.........这里部分代码省略.........
示例8: reload_stats
function reload_stats()
{
$unix = new unix();
$sock = new sockets();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$kavicapserverEnabled = intval($sock->GET_INFO("kavicapserverEnabled"));
if ($kavicapserverEnabled == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Reloading......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Not enabled,stop it\n";
}
stop();
return;
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Not running, start it\n";
}
start();
return;
}
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} TTL of {$timepid}Mn for statistics\n";
}
$unix->KILL_PROCESS($pid, 12);
}
示例9: unix
echo @implode("\n", $conf);
die;
}
if ($argv[1] == "--functions") {
$arr = get_defined_functions();
print_r($arr);
die;
}
if ($argv[1] == "--all-squid") {
$unix = new unix();
$processes = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?{$argv[1]}", true);
events(count($processes) . " Running " . @implode(";", $processes), "{$argv[1]}", __LINE__);
if (count($processes) > 2) {
while (list($num, $pid) = each($processes)) {
events("Killing pid {$pid} ", "MAIN", __LINE__);
$unix->KILL_PROCESS($pid, 9);
}
$processes = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?{$argv[1]}", true);
events(count($processes) . " Running " . @implode(";", $processes), "{$argv[1]}", __LINE__);
}
if (count($processes) > 0) {
events("ALL_SQUID: Processes already exists, aborting", "{$argv[1]}", __LINE__);
die;
}
$cachefile = "/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS";
$GLOBALS["DISABLE_WATCHDOG"] = true;
$TimeFile = $cachefile;
if ($GLOBALS["SCHEDULE_ID"] > 0) {
if ($unix->file_time_min($TimeFile) > 5) {
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
示例10: reload
function reload()
{
$unix = new unix();
$sock = new sockets();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Not running, start it\n";
}
start();
return;
}
build();
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Reloading.....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} TTL of {$timepid}Mn\n";
}
$unix->KILL_PROCESS($pid, 1);
$echo = $unix->find_program("echo");
$sock = new sockets();
$ip_queue_maxlen = intval($sock->GET_INFO("ip_queue_maxlen"));
if ($ip_queue_maxlen == 0) {
$ip_queue_maxlen = 2048;
}
if (is_file("/proc/sys/net/ipv4/ip_queue_maxlen")) {
shell_exec("{$echo} \"{$ip_queue_maxlen}\" >/proc/sys/net/ipv4/ip_queue_maxlen");
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /proc/sys/net/ipv4/ip_queue_maxlen no such file.\n";
}
}
}
示例11: if_process_import_exists
function if_process_import_exists($filename, $killbefore = 0)
{
$unix = new unix();
$RESULTS = FALSE;
$pgrep = $unix->find_program("pgrep");
exec("{$pgrep} -l -f \"bzip2.*{$filename}\" 2>&1", $results);
while (list($index, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#pgrep#", $line)) {
continue;
}
if (!preg_match("#^([0-9]+)#", $line, $re)) {
continue;
}
$TTL = $unix->PROCESS_TTL($re[1]);
$RESULTS = true;
if ($GLOBALS["VERBOSE"]) {
echo "{$re[1]} - {$TTL}Mn\n";
}
if ($killbefore > 0) {
if ($TTL < $killbefore) {
if ($GLOBALS["VERBOSE"]) {
echo "KILL!!! {$re[1]} - {$TTL}Mn\n";
}
$unix->KILL_PROCESS($re[1], 9);
}
}
Export_logs("{$filename} is already processed by PID {$re[1]} since {$TTL}Mn");
}
return $RESULTS;
}
示例12: nmap_scan_pingnet
function nmap_scan_pingnet()
{
nmap_scan_pingnet_progress("{ping_networks}", 5);
$unix = new unix();
$sock = new sockets();
$nmap = $unix->find_program("nmap");
$nohup = $unix->find_program("nohup");
$NmapTimeOutPing = intval($sock->GET_INFO("NmapTimeOutPing"));
$NmapFastScan = intval($sock->GET_INFO("NmapFastScan"));
if ($NmapTimeOutPing == 0) {
$NmapTimeOutPing = 30;
}
$MaxTime = 10;
$net = new networkscanner();
while (list($num, $maks) = each($net->networklist)) {
if (trim($maks) == null) {
continue;
}
$hash[$maks] = $maks;
}
while (list($num, $maks) = each($hash)) {
if (!$net->Networks_disabled[$maks]) {
if ($GLOBALS["VERBOSE"]) {
echo "Network: {$maks} OK\n";
}
$cdir[] = $maks;
}
}
if (count($cdir) == 0) {
nmap_scan_pingnet_progress("No network", 110);
return;
}
$nets = trim(@implode(" ", $cdir));
nmap_scan_pingnet_progress("Scanning Networks {$nets}", 10);
echo "Scanning Networks {$nets}\n";
$TMP = $unix->FILE_TEMP();
$NmapTimeOutPing++;
$prc = 10;
nmap_scan_pingnet_progress("{fast_scan}: {$NmapFastScan}", 6);
while (list($num, $cd) = each($cdir)) {
$prc = $prc + 5;
if ($prc > 99) {
$prc = 99;
}
nmap_scan_pingnet_progress("Scanning Network {$cd}", $prc);
$CONTINUE = true;
if ($NmapFastScan == 1) {
nmap_scan_pingnet_progress("{$cd} -> arp-scan", $prc);
$f1 = arp_scanner($cdir);
if (count($f1) > 0) {
while (list($num, $line) = each($f1)) {
$f[] = $line;
}
$CONTINUE = false;
}
}
if ($CONTINUE) {
echo "{$nmap} -T4 -sP -oX {$TMP} {$cd}\n";
system("{$nohup} {$nmap} -T4 -sP -oX {$TMP} {$cd} >/dev/null 2>&1 &");
for ($i = 1; $i < $NmapTimeOutPing; $i++) {
$pid = $unix->PIDOF("{$nmap}");
if (!$unix->process_exists($pid)) {
break;
}
echo "Waiting scanner PID {$pid} {$i}/{$NmapTimeOutPing}\n";
sleep(1);
}
$pid = $unix->PIDOF("{$nmap}");
if ($unix->process_exists($pid)) {
echo "Timed-Out scanner PID {$pid}\n";
nmap_scan_pingnet_progress("{$cd} Timed Out!!", $prc);
sleep(3);
$unix->KILL_PROCESS($pid, 9);
continue;
}
$date = date("Y-m-d H:i:s");
$xmlstr = @file_get_contents($TMP);
@unlink($TMP);
$XMLZ = new SimpleXMLElement($xmlstr);
foreach ($XMLZ->host as $Hostz) {
$ipaddr = mysql_escape_string2($Hostz->address[0]["addr"][0]);
$mac = mysql_escape_string2($Hostz->address[1]["addr"][0]);
$vendor = mysql_escape_string2($Hostz->address[1]["vendor"][0]);
$f[] = "('{$ipaddr}','{$mac}','{$vendor}','{$date}')";
}
}
}
$prc = $prc + 5;
if ($prc > 99) {
$prc = 99;
}
nmap_scan_pingnet_progress("Build report", $prc);
$q = new mysql();
$sql = "CREATE TABLE IF NOT EXISTS `nmap_scannet` (\n\t`MAC` varchar(90) NOT NULL,\n\t`ipaddr` varchar(90) NOT NULL,\n\t`vendor` varchar(90) NOT NULL DEFAULT '',\n\t`zDate` datetime NOT NULL,\n\tPRIMARY KEY (`MAC`),\n\tKEY `ipaddr` (`ipaddr`),\n\tKEY `vendor` (`vendor`)\n\t) ENGINE=MYISAM;";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error . "\n";
nmap_scan_pingnet_progress("MySQL error", "110");
return;
}
//.........这里部分代码省略.........
示例13: stop
function stop()
{
$unix = new unix();
$sock = new sockets();
$masterbin = $unix->find_program("squid27");
$EnableArticaHotSpot = $sock->GET_INFO("EnableArticaHotSpot");
$SquidHotSpotPort = $sock->GET_INFO("SquidHotSpotPort");
$ArticaHotSpotPort = $sock->GET_INFO("ArticaHotSpotPort");
$ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort");
$ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort");
$ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL");
if (!is_numeric($ArticaHotSpotPort)) {
$ArticaHotSpotPort = 0;
}
if (!is_numeric($ArticaSplashHotSpotPort)) {
$ArticaSplashHotSpotPort = 16080;
}
if (!is_numeric($ArticaSplashHotSpotPortSSL)) {
$ArticaSplashHotSpotPortSSL = 16443;
}
$pid = squid_27_pid();
if (!is_file($masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Not installed\n";
}
return;
}
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Already stopped...\n";
}
return;
}
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Shutdown pid {$pid}...\n";
}
shell_exec("{$masterbin} -f /etc/squid27/squid.conf -k shutdown");
for ($i = 0; $i < 5; $i++) {
$pid = squid_27_pid();
if (!$unix->process_exists($pid)) {
break;
}
shell_exec("{$masterbin} -f /etc/squid27/squid.conf -k shutdown");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = squid_27_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} shutdown - force - pid {$pid}...\n";
}
shell_exec("{$masterbin} -f /etc/squid27/squid.conf -k kill");
for ($i = 0; $i < 5; $i++) {
$pid = squid_27_pid();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
shell_exec("{$masterbin} -f /etc/squid27/squid.conf -k kill");
sleep(1);
}
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success stopped...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Killing processes\n";
}
for ($i = 0; $i < 5; $i++) {
$pid = squid_27_pid();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} kill pid:{$pid} {$i}/5...\n";
}
$unix->KILL_PROCESS($pid, 9);
}
$pid = squid_27_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success stopped...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
//.........这里部分代码省略.........
示例14: BUILD_NETWORK
function BUILD_NETWORK()
{
$SUBNIC = null;
$unix = new unix();
$sock = new sockets();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$savedsettings = unserialize(base64_decode(file_get_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings")));
$KEEPNET = $savedsettings["KEEPNET"];
if ($KEEPNET == 1) {
return;
}
$netbiosname = $savedsettings["netbiosname"];
if (strlen($netbiosname) > 15) {
$netbiosname = substr(0, 15, $netbiosname);
}
if (isset($savedsettings["domain"])) {
$domainname = $savedsettings["domain"];
$SEARCH_DOMAIN = $domainname;
}
$EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
if ($EnableKerbAuth == 1) {
$array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
if (isset($array["WINDOWS_DNS_SUFFIX"])) {
$SEARCH_DOMAIN = $array["WINDOWS_DNS_SUFFIX"];
$domainname = $SEARCH_DOMAIN;
}
}
$Encoded = base64_encode(serialize($savedsettings));
@file_put_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings", $Encoded);
if (!isset($savedsettings["NIC"])) {
$savedsettings["NIC"] = "eth0";
}
$NIC = $savedsettings["NIC"];
if (preg_match("#(.+?):([0-9]+)#", $savedsettings["NIC"], $re)) {
$NIC = trim($re[1]);
$SUBNIC = $re[2];
}
writeprogress(60, "{building_networks}");
$nics = new system_nic($NIC);
$nics->CheckMySQLFields();
$dhclient = $unix->find_program("dhclient");
if (is_file($dhclient)) {
$pid = $unix->PIDOF($dhclient);
if ($unix->process_exists($pid)) {
$unix->KILL_PROCESS($pid, 9);
}
}
$nics->eth = $NIC;
if ($SUBNIC != null) {
$nics->IPADDR = "127.0.0.2";
$nics->NETMASK = "255.255.255.255";
$nics->GATEWAY = "0.0.0.0";
$nics->BROADCAST = "0.0.0.0";
$nics->DNS1 = $savedsettings["DNS1"];
$nics->DNS2 = $savedsettings["DNS2"];
$nics->dhcp = 0;
$nics->metric = $savedsettings["metric"];
$nics->enabled = 1;
$nics->defaultroute = 1;
} else {
$nics->IPADDR = $savedsettings["IPADDR"];
$nics->NETMASK = $savedsettings["NETMASK"];
$nics->GATEWAY = $savedsettings["GATEWAY"];
$nics->BROADCAST = $savedsettings["BROADCAST"];
$nics->DNS1 = $savedsettings["DNS1"];
$nics->DNS2 = $savedsettings["DNS2"];
$nics->dhcp = 0;
$nics->metric = $savedsettings["metric"];
$nics->enabled = 1;
$nics->defaultroute = 1;
}
writeprogress(60, "{saving_network}");
$nics->SaveNic();
if ($SUBNIC != null) {
$q = new mysql();
$sql = "INSERT INTO nics_virtuals (ID,nic,org,ipaddr,netmask,cdir,gateway,ForceGateway,failover,metric)\n\t\tVALUES('{$SUBNIC}','{$NIC}','','{$savedsettings["IPADDR"]}','{$savedsettings["NETMASK"]}',\n\t\t'','{$savedsettings["GATEWAY"]}',0,0,1);";
$q->QUERY_SQL($sql, "artica_backup");
$sql = "UPDATE nics_virtuals SET nic='{$NIC}',\n\t\torg='',\n\t\tipaddr='{$savedsettings["IPADDR"]}',\n\t\tnetmask='{$savedsettings["NETMASK"]}',\n\t\tcdir='',\n\t\t\t\tgateway='{$savedsettings["GATEWAY"]}',\n\t\t\t\tForceGateway='0',\n\t\t\t\tfailover='0',\n\t\t\t\tmetric='1'\n\t\t\t\tWHERE ID={$SUBNIC}";
$q->QUERY_SQL($sql, "artica_backup");
}
writeprogress(60, "Loading resolv library");
$resolv = new resolv_conf();
$arrayNameServers[0] = $savedsettings["DNS1"];
$arrayNameServers[1] = $savedsettings["DNS2"];
$resolv->MainArray["DNS1"] = $arrayNameServers[0];
$resolv->MainArray["DNS2"] = $arrayNameServers[1];
$resolv->MainArray["DOMAINS1"] = $SEARCH_DOMAIN;
writeprogress(60, "Saving DNS settings");
$resolv->save();
$nic = new system_nic();
writeprogress(60, "{set_new_hostname} {$netbiosname}.{$domainname}");
$nic->set_hostname("{$netbiosname}.{$domainname}");
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
writeprogress(60, "{building_resolv_configuration}");
shell_exec(trim("{$nohup} " . $unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.virtuals-ip.php --resolvconf >/dev/null 2>&1"));
writeprogress(60, "{building_networks_scripts}");
shell_exec("{$php5} /usr/share/artica-postfix/exec.virtuals-ip.php >/dev/null 2>&1");
}
示例15: reload
function reload()
{
$scriptlog = null;
if ($GLOBALS["BYSCRIPT"]) {
$scriptlog = " by init.d script";
}
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$pid = LIGHTTPD_PID();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Reloading framework PID:{$pid}...\n";
}
FrmToSyslog("Reloading framework{$scriptlog}");
$unix->KILL_PROCESS($pid, 1);
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Starting framework...\n";
}
start(true);
}