本文整理汇总了PHP中unix::PIDOF_PATTERN_ALL方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::PIDOF_PATTERN_ALL方法的具体用法?PHP unix::PIDOF_PATTERN_ALL怎么用?PHP unix::PIDOF_PATTERN_ALL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::PIDOF_PATTERN_ALL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_status_table
function user_status_table()
{
if (isset($GLOBALS["user_status_table_executed"])) {
if ($GLOBALS["VERBOSE"]) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
echo "user_status_table Already executed {$called}\n";
}
}
return;
}
$GLOBALS["user_status_table_executed"] = true;
$unix = new unix();
$sock = new sockets();
$timefile = "/usr/share/artica-postfix/ressources/databases/ZARAFA_DB_STATUS.db";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$mns = $unix->file_time_min($timefile);
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile} = {$mns}Mn\n";
}
if (!$GLOBALS["FORCE"]) {
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overload system, aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
return;
}
if ($mns < 180) {
return;
}
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeProcess = $unix->PROCCESS_TIME_MIN($pid);
system_admin_events("{$pid}, task is already executed (since {$timeProcess}Mn}), aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
if ($timeProcess < 15) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
system_admin_events("{$pid}, killed (since {$timeProcess}Mn}), aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
}
}
@file_put_contents($pidfile, getmypid());
@unlink($timefile);
@file_put_contents($timefile, time());
$ZarafaIndexPath = $sock->GET_INFO("ZarafaIndexPath");
$ZarafaStoreOutsidePath = $sock->GET_INFO("ZarafaStoreOutsidePath");
$ZarafaMySQLServiceType = $sock->GET_INFO("ZarafaMySQLServiceType");
if (!is_numeric($ZarafaMySQLServiceType)) {
$ZarafaMySQLServiceType = 1;
}
// $ZarafaMySQLServiceType =1 ou 2 /var/lib/mysql
// $ZarafaMySQLServiceType =3 --> dedicated instance
if ($ZarafaIndexPath == null) {
$ZarafaIndexPath = "/var/lib/zarafa/index";
}
if ($ZarafaStoreOutsidePath == null) {
$ZarafaStoreOutsidePath = "/var/lib/zarafa";
}
$ARRAY["ZARAFA_INDEX"] = $unix->DIRSIZE_BYTES($ZarafaIndexPath);
if ($ZarafaMySQLServiceType == 1 or $ZarafaMySQLServiceType == 2) {
$ARRAY["ZARAFA_DB"] = $unix->DIRSIZE_BYTES("/var/lib/mysql");
}
if ($ZarafaMySQLServiceType == 3) {
$WORKDIR = $sock->GET_INFO("ZarafaDedicateMySQLWorkDir");
if ($WORKDIR == null) {
$WORKDIR = "/home/zarafa-db";
}
$ARRAY["ZARAFA_DB"] = $unix->DIRSIZE_BYTES($WORKDIR);
}
$ARRAY["ATTACHS"] = $unix->DIRSIZE_BYTES($ZarafaStoreOutsidePath);
@file_put_contents($timefile, serialize($ARRAY));
@chmod($timefile, 0750);
unset($ARRAY);
$zarafaadmin = $unix->find_program("zarafa-admin");
$kill = $unix->find_program("kill");
$pids = $unix->PIDOF_PATTERN_ALL("zarafa-admin -l");
if (count($pids) > 0) {
while (list($pid, $line) = each($pids)) {
$time = $unix->PROCESS_TTL($pid);
if ($time > 15) {
$unix->_syslog("killing zarafa-admin -l pid {$pid} ({$time}mn)", basename(__FILE__));
unix_system_kill_force($pid);
}
}
}
$pid = $unix->PIDOF_PATTERN("zarafa-admin -l");
if ($unix->process_exists($pid)) {
$unix->_syslog("zarafa-admin -l pid {$pid} still running", basename(__FILE__));
}
if ($GLOBALS["VERBOSE"]) {
echo "{$zarafaadmin} -l 2>&1\n--------------------------------------------------------------------\n";
}
exec("{$zarafaadmin} -l 2>&1", $results);
while (list($num, $line) = each($results)) {
$line = trim($line);
if ($GLOBALS["VERBOSE"]) {
echo "\"{$line}\"\n";
}
if (preg_match("#User list for\\s+(.+?)\\(#i", $line, $re)) {
$ou = $re[1];
//.........这里部分代码省略.........
示例2: phpcgi
function phpcgi()
{
$unix = new unix();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
$pids = $unix->PIDOF_PATTERN_ALL($phpcgi);
if (count($pids) == 0) {
return;
}
$c = 0;
while (list($pid, $ligne) = each($pids)) {
$time = $unix->PROCESS_TTL($pid);
if ($time > 1640) {
$c++;
$unix->KILL_PROCESS($pid, 9);
}
}
}
示例3: start
function start($xtime = 0)
{
if ($GLOBALS["VERBOSE"]) {
"echo Loading...\n";
}
$unix = new unix();
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__));
if (count($pids) > 5) {
die;
}
if ($xtime == 0) {
if ($GLOBALS["VERBOSE"]) {
"echo Loading done...\n";
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = @file_get_contents($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 720) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
if ($xtime > 0) {
$dateRequested = date("Y-m-d", $xtime);
$dateRequested_sql = " WHERE zDate='{$dateRequested}'";
if (SquidStatisticsTasksOverTime()) {
stats_admin_events(1, "Statistics overtime... Aborting ( requested for {$dateRequested} ) ", null, __FILE__, __LINE__);
return;
}
}
$sql = "SELECT\n\tDATE_FORMAT(zDate,'%Y%m%d') as tprefix,DATE_FORMAT(zDate,'%Y-%m-%d') as CurDay,tablename FROM tables_day{$dateRequested_sql} \n\tORDER BY zDate DESC";
$q = new mysql_squid_builder();
$results = $q->QUERY_SQL($sql);
//bigint(100)
if ($q->FIELD_TYPE("tables_day", "totalBlocked", "syslogs") == "bigint(100)") {
$q->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `size` `size` BIGINT( 255 ) NOT NULL');
$q->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `totalBlocked` `totalBlocked` BIGINT( 255 ) NOT NULL');
$q->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `requests` `requests` BIGINT( 255 ) NOT NULL');
$q->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `totalsize` `totalsize` BIGINT( 255 ) NOT NULL');
$q->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `size_cached` `size_cached` BIGINT( 255 ) NOT NULL');
}
if (!$q->FIELD_EXISTS("tables_day", "totalKeyWords")) {
$q->QUERY_SQL("ALTER TABLE `tables_day` ADD `totalKeyWords` BIGINT( 255 ) NOT NULL NOT NULL,ADD INDEX ( `totalKeyWords`)");
if (!$q->ok) {
squid_admin_mysql(0, $q->mysql_error, null, __FILE__, __LINE__);
echo $q->mysql_error;
return;
}
}
if (!$q->FIELD_EXISTS("tables_day", "DangerousCatz")) {
$q->QUERY_SQL("ALTER TABLE `tables_day` ADD `DangerousCatz` smallint( 1 ) NOT NULL NOT NULL,ADD INDEX ( `DangerousCatz`)");
}
if (!$q->ok) {
echo "{$q->mysql_error}.<hr>{$sql}</hr>";
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$tablename = $ligne["tablename"];
$hourtable = $ligne["tprefix"] . "_hour";
if ($ligne["tprefix"] == date("Ymd")) {
continue;
}
$KeyWordsTable = "searchwordsD_" . $ligne["tprefix"];
$members_table = "{$ligne["tprefix"]}_members";
$youtube_table = "youtubeday_{$ligne["tprefix"]}";
$myXtime = strtotime($ligne["CurDay"] . "00:00:00");
if ($q->TABLE_EXISTS($hourtable)) {
$sql = "SELECT SUM(size) as tsize, SUM(hits) as thits FROM {$hourtable}";
$ligne2 = mysql_fetch_array($q->QUERY_SQL($sql));
$size = $ligne2["tsize"];
$hits = $ligne2["thits"];
$sizeL = FormatBytes($size / 1024);
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename} - {$sizeL} / {$hits} {$hourtable} [ {$sql} ]\n";
}
$sql = "UPDATE tables_day SET totalsize='{$size}',requests='{$hits}' WHERE tablename='{$tablename}'";
$q->QUERY_SQL($sql);
if (!$q->ok) {
if ($GLOBALS["VERBOSE"]) {
echo $q->mysql_error . "\n";
}
}
$sql = "SELECT COUNT(`sitename`) as tcount FROM {$hourtable} WHERE LENGTH(`category`)=0";
//.........这里部分代码省略.........
示例4: xstart
function xstart()
{
$T1 = time();
$curl = new ccurl();
$unix = new unix();
$GLOBALS["MYPID"] = getmypid();
$pidfile = "/etc/artica-postfix/pids/windowupdate.partial.processor.pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
die;
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__), true);
if (count($pids) > 0) {
while (list($i, $line) = each($pids)) {
events("Already executed PID:{$i}... aborting ", __LINE__);
}
die;
}
$TEMPDIR = $unix->TEMP_DIR() . "/WindowsUpdates";
$rm = $unix->find_program("rm");
@file_put_contents($pidfile, $GLOBALS["MYPID"]);
if (is_dir($TEMPDIR)) {
shell_exec("{$rm} -rf {$TEMPDIR}");
@mkdir($TEMPDIR);
}
$GLOBALS["WindowsUpdateMaxToPartialQueue"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateMaxToPartialQueue"));
$GLOBALS["WindowsUpdateCachingDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCachingDir");
if ($GLOBALS["WindowsUpdateCachingDir"] == null) {
$GLOBALS["WindowsUpdateCachingDir"] = "/home/squid/WindowsUpdate";
}
$WindowsUpdateDownTimeout = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateDownTimeout"));
if ($WindowsUpdateDownTimeout == 0) {
$WindowsUpdateDownTimeout = 600;
}
$WindowsUpdateBandwidthMaxFailed = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateBandwidthMaxFailed"));
if ($WindowsUpdateBandwidthMaxFailed == 0) {
$WindowsUpdateBandwidthMaxFailed = 50;
}
$WindowsUpdateMaxPartition = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateMaxPartition"));
if ($WindowsUpdateMaxPartition == 0) {
$WindowsUpdateMaxPartition = 80;
}
$fileSource = "{$GLOBALS["WindowsUpdateCachingDir"]}/Partials/Queue.log";
$LinesCount = $unix->COUNT_LINES_OF_FILE($fileSource);
if (!is_file($fileSource)) {
return;
}
$md5start = md5_file($fileSource);
$CheckPartitionPercentage = CheckPartitionPercentage();
if ($CheckPartitionPercentage > $WindowsUpdateMaxPartition) {
events("Failed: Storage Partition exceed {$WindowsUpdateMaxPartition}% Stopping retreivals", __LINE__);
@touch("/etc/squid3/WindowsUpdatePartitionExceed");
DirectorySize();
return;
}
$WindowsUpdateInProduction = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateInProduction"));
if ($WindowsUpdateInProduction == 0) {
if ($unix->IsProductionTime()) {
$time = $unix->file_time_min("/etc/artica-postfix/pids/WindowsUpdateInProduction");
if ($time > 15) {
@unlink("/etc/artica-postfix/pids/WindowsUpdateInProduction");
@touch("/etc/artica-postfix/pids/WindowsUpdateInProduction");
events("INFO: Aborting, No download during production time", __LINE__);
DirectorySize();
}
return;
}
}
if (is_file("/etc/squid3/WindowsUpdatePartitionExceed")) {
@unlink("/etc/squid3/WindowsUpdatePartitionExceed");
}
$handle = @fopen($fileSource, "r");
if (!$handle) {
events("Fopen failed on {$fileSource}", __LINE__);
return false;
}
$NEWBUFFER = array();
$URLALREADY = array();
$NewBuffer = array();
$FinalSize = 0;
$FF = 0;
$c = 0;
while (!feof($handle)) {
$buffer = trim(fgets($handle));
$c++;
if ($buffer == null) {
continue;
}
$TR = explode("|||", $buffer);
$LocalFile = $TR[0];
$URI = $TR[1];
$ExpectedSize = $TR[2];
if (!isset($TR[3])) {
$TR[3] = 1;
}
if (isset($URLALREADY[$URI])) {
continue;
}
$URLALREADY[$URI] = true;
$BaseNameOfFile = basename($URI);
//.........这里部分代码省略.........
示例5: xstart
function xstart()
{
$unix = new unix();
$TimeFile = "/etc/artica-postfix/pids/exec.squidcache.php.time";
$PidFile = "/etc/artica-postfix/pids/exec.squidcache.php.pid";
$Pid = $unix->get_pid_from_file($PidFile);
if ($unix->process_exists($Pid)) {
$pidtime = $unix->PROCCESS_TIME_MIN($Pid);
if ($pidtime > 29) {
events("Max execution time reached 30Mn for PID {$Pid} Kill it...", 0, 2, __LINE__);
unix_system_kill_force($Pid);
die;
}
events("Already running PID {$Pid} since {$pidtime}Mn", 0, 2, __LINE__);
return;
}
@file_put_contents($PidFile, getmypid());
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__));
if (count($pids) > 3) {
events("Too many instances " . count($pids) . " dying", 0, 1, __LINE__);
$mypid = getmypid();
while (list($pid, $ligne) = each($pids)) {
if ($pid == $mypid) {
continue;
}
events("Killing {$pid}");
unix_system_kill_force($pid);
}
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__));
if (count($pids) > 3) {
events("Too many instances " . count($pids) . " dying", 0, 2, __LINE__);
die;
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
$sock = new sockets();
$GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath");
if ($GLOBALS["HyperCacheStoragePath"] == null) {
$GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
}
@chown("/usr/share/squid3", "squid");
@chgrp("/usr/share/squid3", "squid");
HyperCacheMirror();
if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
events("Storage path: {$GLOBALS["HyperCacheStoragePath"]}", 0, 2, __LINE__);
events("Scanning /usr/share/squid3", 0, 2, __LINE__);
}
$f = $unix->DirFiles("/usr/share/squid3", "HyperCacheQueue-.+?-([0-9]+)\\.db\$");
$GLOBALS["SIZE_DOWNLOADED"] = 0;
$GLOBALS["HITS"] = 0;
while (list($num, $file) = each($f)) {
if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
events("Found database: {$file}", 0, 2, __LINE__);
}
if (!preg_match("#^HyperCacheQueue-.+?-([0-9]+)\\.db\$#", $file, $re)) {
continue;
}
if (preg_match("#HyperCacheQueue-dropbox\\.com#", $file)) {
continue;
}
$ID = $re[1];
HyperCacheScanDBFile("/usr/share/squid3/{$file}", $ID);
}
if ($GLOBALS["SIZE_DOWNLOADED"] > 0) {
$size = FormatBytes($GLOBALS["SIZE_DOWNLOADED"] / 1024);
$hits = $GLOBALS["HITS"];
events("{$size} downloaded - {$hits} requests", $ID, 2, __LINE__);
squid_admin_enforce(2, "{$size} downloaded and store {$hits} requests", null, __FILE__, __LINE__);
}
if ($GLOBALS["VERBOSE"]) {
echo "xstart ---> DeleteRules\n";
}
DeleteRules();
if ($GLOBALS["VERBOSE"]) {
echo "xstart ---> GetRulesSizes\n";
}
GetRulesSizes();
}
示例6: clean_nmap_processes
function clean_nmap_processes()
{
$unix = new unix();
$nmap = $unix->find_program("nmap");
if (!is_file($nmap)) {
return;
}
$pids = $unix->PIDOF_PATTERN_ALL($nmap);
while (list($pid, $ar) = each($pids)) {
$Time = $unix->PROCCESS_TIME_MIN($pid, 60);
}
}
示例7: start_squid
function start_squid($aspid = false)
{
$GLOBALS["LOGS"] = array();
$suffix = null;
if ($GLOBALS["MONIT"]) {
$suffix = " (by system monitor)";
}
if ($GLOBALS["BY_CACHE_LOGS"]) {
$suffix = " (by cache.log monitor)";
}
if ($GLOBALS["BY_STATUS"]) {
$suffix = " (by Artica monitor)";
}
if ($GLOBALS["BY_CLASS_UNIX"]) {
$suffix = " (by Artica class.unix.inc)";
}
if ($GLOBALS["BY_FRAMEWORK"]) {
$suffix = " (by Artica framework)";
}
if ($GLOBALS["BY_OTHER_SCRIPT"]) {
$suffix = " (by other script)";
}
if ($GLOBALS["BY_ARTICA_INSTALL"]) {
$suffix = " (by artica-install)";
}
if ($GLOBALS["BY_FORCE_RECONFIGURE"]) {
$suffix = " (after building settings)";
}
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$sock = new sockets();
$reconfigure = false;
$SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
$NtpdateAD = $sock->GET_INFO("NtpdateAD");
if (!is_numeric($SQUIDEnable)) {
$SQUIDEnable = 1;
}
$kill = $unix->find_program("kill");
if (!is_numeric($NtpdateAD)) {
$NtpdateAD = 0;
}
$su_bin = $unix->find_program("su");
$sysctl = $unix->find_program("sysctl");
$squidbin = $unix->LOCATE_SQUID_BIN();
if (!is_file($squidbin)) {
build_progress_start("Not installed", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Restart......: Squid-cache, not installed\n";
}
return;
}
if ($GLOBALS["MONIT"]) {
if (function_exists("debug_backtrace")) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$file = basename($trace[1]["file"]);
$function = $trace[1]["function"];
$line = $trace[1]["line"];
$called = "Called by {$function}() from line {$line}";
}
}
$pid = SQUID_PID();
if ($unix->process_exists($pid)) {
$ps = $unix->find_program("ps");
$grep = $unix->find_program("grep");
exec("{$ps} aux|{$grep} squid 2>&1", $results);
squid_admin_mysql(2, "Monit ordered to start squid but squid is still in memory PID {$pid} ??", "I cannot accept this order, see details\n" . @implode("\n", $results), __FILE__, __LINE__);
$squidpidfile = $unix->LOCATE_SQUID_PID();
@file_put_contents($squidpidfile, $pid);
return;
}
squid_admin_mysql(1, "Monit ordered to start squid", $called, __FILE__, __LINE__);
}
if ($SQUIDEnable == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Squid is disabled...\n";
}
build_progress_start("Proxy service is disabled", 110);
return;
}
if (is_file("/etc/init.d/iptables-transparent")) {
shell_exec("/etc/init.d/iptables-transparent start");
}
if (is_file("/etc/artica-postfix/squid.lock")) {
$time = $unix->file_time_min("/etc/artica-postfix/squid.lock");
if ($time < 60) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Proxy is locked (since {$time}Mn...\n";
}
build_progress_start(" Proxy is locked (since {$time}Mn", 110);
return;
}
@unlink("/etc/artica-postfix/squid.lock");
}
$pids = $unix->PIDOF_PATTERN_ALL("exec.squid.watchdog.php --start");
if (count($pids) > 2) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Too many instances " . count($pids) . " starting squid, kill them!\n";
}
//.........这里部分代码省略.........
示例8: usersMenus
}
if ($argv[1] == "--progress") {
restart_progress();
exit;
}
$users = new usersMenus();
if ($users->WEBSTATS_APPLIANCE) {
iptables_delete_all();
die;
}
if (!$users->SQUID_INSTALLED) {
iptables_delete_all();
die;
}
$sysctl = $unix->find_program("sysctl");
$pids = $unix->PIDOF_PATTERN_ALL("exec.squid.transparent.php");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " instances:" . count($pids) . "\n";
}
if (count($pids) > 2) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Too many instances " . count($pids) . " starting squid, kill them!\n";
}
$mypid = getmypid();
while (list($pid, $ligne) = each($pids)) {
if ($pid == $mypid) {
continue;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " killing {$pid}\n";
}
示例9: videocache
}
if ($argv[1] == "--videocache") {
$conf[] = videocache();
$conf[] = videocache_scheduler();
$conf[] = videocache_clients();
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;
示例10: status
function status()
{
$unix = new unix();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$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;
}
if (!$GLOBALS["VERBOSE"]) {
$timeExec = $unix->file_time_min($pidtime);
if ($timeExec < 240) {
return;
}
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
@file_put_contents($pidfile, getmypid());
$pid = LIGHTTPD_PID();
$unix = new unix();
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service running {$pid} since {$timepid}Mn...\n";
}
} else {
FrmToSyslog("Framework service stopped");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service stopped...\n";
}
start(true);
return;
}
$MAIN_PID = $pid;
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
$kill = $unix->find_program("kill");
$array = $unix->PIDOF_PATTERN_ALL($phpcgi);
if (count($array) == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: no php-cgi processes...\n";
}
return;
}
while (list($pid, $line) = each($array)) {
$username = $unix->PROCESS_GET_USER($pid);
if ($username == null) {
continue;
}
if ($username != "root") {
continue;
}
$time = $unix->PROCCESS_TIME_MIN($pid);
$arrayPIDS[$pid] = $time;
$ppid = $unix->PPID_OF($pid);
if ($time > 20) {
if ($ppid != $MAIN_PID) {
if ($GLOBALS["VERBOSE"]) {
echo "killing {$pid} {$time}mn ppid:{$ppid}/{$MAIN_PID}\n";
}
unix_system_kill_force($pid);
}
}
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: " . count($arrayPIDS) . " php-cgi processes...\n";
}
}
示例11: restart_ldap
function restart_ldap()
{
$unix = new unix();
$MYPID_FILE = "/etc/artica-postfix/pids/restart_ldap.pid";
$pid = $unix->get_pid_from_file($MYPID_FILE);
if (!is_file("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP")) {
@file_put_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP", 1);
@chmod("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP", 0755);
}
$EnableOpenLDAP = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP"));
if ($unix->process_exists($pid, basename(__FILE__))) {
echo "slapd: [INFO] Artica task already running pid {$pid}\n";
restart_ldap_progress("{failed} [" . __LINE__ . "]", 110);
die;
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?--restart", true);
if (count($pids) > 0) {
while (list($i, $line) = each($pids)) {
echo "slapd: [INFO] Artica task already executed PID:{$i}... aborting\n";
}
restart_ldap_progress("{failed}", 110);
die;
}
if ($GLOBALS["MONIT"]) {
squid_admin_mysql(0, "Monit (Watchdog) Ask to restart OpenLDAP service...", null, __FILE__, __LINE__);
system_admin_mysql(0, "Monit (Watchdog) Ask to restart OpenLDAP service...", null, __FILE__, __LINE__);
}
if (!$GLOBALS["FORCE"]) {
$lastexecution = $unix->file_time_min($MYPID_FILE);
if ($lastexecution == 0) {
$unix->ToSyslog("Restarting the OpenLDAP by `{$GLOBALS["BY_FRAMEWORK"]}` aborted this command must be executed minimal each 1mn", false, basename(__FILE__));
echo "slapd: [INFO] this command must be executed minimal each 1mn\n";
die;
}
}
@unlink($MYPID_FILE);
restart_ldap_progress("{build_init_script}", 5);
$INITD_PATH = $unix->SLAPD_INITD_PATH();
echo "Script: {$INITD_PATH}\n";
buildscript();
if (!is_file($INITD_PATH)) {
restart_ldap_progress("{build_init_script} {failed}", 110);
return;
}
@file_put_contents($MYPID_FILE, getmypid());
$unix->ToSyslog("Restarting the OpenLDAP daemon by `{$GLOBALS["BY_FRAMEWORK"]}`", false, basename(__FILE__));
restart_ldap_progress("{stopping_service}", 10);
stop_ldap(true);
if ($EnableOpenLDAP == 1) {
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("/etc/init.d/monit restart");
restart_ldap_progress("{starting_service}", 40);
start_ldap(true);
}
}
示例12: Paranoid
function Paranoid($nopid = false)
{
$unix = new unix();
if (!$nopid) {
$mypid = getmypid();
if (isset($argv[1])) {
$argv = $argv[1];
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?{$argv}");
if (count($pids) > 1) {
while (list($num, $ligne) = each($pids)) {
$cmdline = @file_get_contents("/proc/{$num}/cmdline");
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Already process PID {$num} {$cmdline} exists..\n";
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Running " . @file_get_contents("/proc/{$num}/cmdline") . "\n";
}
build_progress_paranoid("{already_process_exists_try_later}", 110);
die;
}
}
$ParanoidBlockerEmergency = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/ParanoidBlockerEmergency"));
$UfdbEnableParanoidMode = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbEnableParanoidMode"));
if ($ParanoidBlockerEmergency == 1) {
if (isInSquid()) {
build_progress_paranoid("{reconfigure}", 70);
$php = $unix->LOCATE_PHP5_BIN();
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
}
build_progress_paranoid("{emergency}!!!", 110);
@unlink("/etc/squid3/paranoid.db");
return;
}
if ($UfdbEnableParanoidMode == 0) {
@unlink("/etc/squid3/paranoid.db");
if (isInSquid()) {
build_progress_paranoid("{reconfigure}", 70);
$php = $unix->LOCATE_PHP5_BIN();
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
}
build_progress_paranoid("{disabled}!!!", 110);
return;
}
$sock = new sockets();
if ($sock->EnableUfdbGuard() == 0) {
build_progress_paranoid("{webfiltering} {disabled}!!!", 110);
@unlink("/etc/squid3/paranoid.db");
return;
}
build_progress_paranoid("{webfiltering} {enabled} OK", 25);
$ipClass = new IP();
$SquidFam = new squid_familysite();
$q = new mysql_squid_builder();
$ARRAY = array();
$results = $q->QUERY_SQL("SELECT pattern, object FROM webfilters_paranoid");
while ($ligne = mysql_fetch_assoc($results)) {
$ligne["pattern"] = trim(strtolower($ligne["pattern"]));
if ($ligne["pattern"] == null) {
continue;
}
build_progress_paranoid("{$ligne["pattern"]}", 50);
$ARRAY[$ligne["object"]][$ligne["pattern"]] = true;
}
$src = array();
$dstdomain = array();
if (isset($ARRAY["src"])) {
while (list($pattern, $xtrace) = each($ARRAY["src"])) {
if (!$ipClass->isValid($pattern)) {
continue;
}
$MAIN["IPSRC"][$pattern] = true;
}
}
if (isset($ARRAY["dstdomain"])) {
while (list($pattern, $xtrace) = each($ARRAY["dstdomain"])) {
$MAIN["DOMS"][$pattern] = true;
}
}
if (isset($ARRAY["dstdomainsrc"])) {
while (list($pattern, $xtrace) = each($ARRAY["dstdomainsrc"])) {
$fr = explode("/", $pattern);
if (!$ipClass->isValid($fr[0])) {
continue;
}
if ($fr[1] == null) {
continue;
}
$fr[1] = $SquidFam->GetFamilySites($fr[1]);
$MAIN["IPDOM"][trim($fr[0])][trim(strtolower($fr[1]))] = true;
}
}
if (!isInSquid()) {
build_progress_paranoid("{reconfigure}", 70);
$php = $unix->LOCATE_PHP5_BIN();
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
}
if (!isInSquid()) {
build_progress_paranoid("{failed}", 110);
return;
}
build_progress_paranoid("{enabled} OK", 80);
if ($GLOBALS["RSQUID"]) {
//.........这里部分代码省略.........
示例13: xstart
function xstart()
{
$T1 = time();
$curl = new ccurl();
$unix = new unix();
$GLOBALS["MYPID"] = getmypid();
$pidfile = "/etc/artica-postfix/pids/windowupdate.processor.pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
die;
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__), true);
if (count($pids) > 0) {
while (list($i, $line) = each($pids)) {
events("Already executed PID:{$i}... aborting ", __LINE__);
}
die;
}
$TEMPDIR = $unix->TEMP_DIR() . "/WindowsUpdates";
$rm = $unix->find_program("rm");
@file_put_contents($pidfile, $GLOBALS["MYPID"]);
if (is_dir($TEMPDIR)) {
shell_exec("{$rm} -rf {$TEMPDIR}");
}
@mkdir($TEMPDIR, 0755, true);
$WindowsUpdateMaxPartition = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateMaxPartition"));
if ($WindowsUpdateMaxPartition == 0) {
$WindowsUpdateMaxPartition = 80;
}
$CheckPartitionPercentage = CheckPartitionPercentage();
if ($CheckPartitionPercentage > $WindowsUpdateMaxPartition) {
$time = $unix->file_time_min("/etc/squid3/WindowsUpdatePartitionExceed");
if ($time > 10) {
@unlink("/etc/squid3/WindowsUpdatePartitionExceed");
events("Failed: Storage Partition exceed {$WindowsUpdateMaxPartition}%, Stopping retreivals", __LINE__);
@touch("/etc/squid3/WindowsUpdatePartitionExceed");
DirectorySize();
}
return;
}
$WindowsUpdateInProduction = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateInProduction"));
if ($WindowsUpdateInProduction == 0) {
if ($unix->IsProductionTime()) {
$time = $unix->file_time_min("/etc/artica-postfix/pids/WindowsUpdateInProduction");
if ($time > 15) {
@unlink("/etc/artica-postfix/pids/WindowsUpdateInProduction");
@touch("/etc/artica-postfix/pids/WindowsUpdateInProduction");
events("INFO: Aborting, No download during production time", __LINE__);
DirectorySize();
}
return;
}
}
if (is_file("/etc/squid3/WindowsUpdatePartitionExceed")) {
@unlink("/etc/squid3/WindowsUpdatePartitionExceed");
}
$q = new mysql_squid_builder();
$sql = "CREATE TABLE IF NOT EXISTS `windowsupdate` (\n\t\t\t`filemd5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`zDate` DATETIME NOT NULL ,\n\t\t\t`zUri` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`localpath` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`filesize` BIGINT UNSIGNED DEFAULT '0',\n\t\t\t INDEX ( `filesize` ,`zDate`) ,\n\t\t\t KEY `localpath`(`localpath`),\n\t\t\t KEY `zUri`(`zUri`),\n\t\t\t PRIMARY KEY (`filemd5`)) ENGINE=MYISAM;";
$q->QUERY_SQL($sql);
if (!$q->ok) {
events("MySQL Failed {$q->mysql_error}", __LINE__);
die;
}
$GLOBALS["WindowsUpdateMaxToPartialQueue"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateMaxToPartialQueue"));
if ($GLOBALS["WindowsUpdateMaxToPartialQueue"] == 0) {
$GLOBALS["WindowsUpdateMaxToPartialQueue"] = 350;
}
$GLOBALS["WindowsUpdateCachingDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCachingDir");
if ($GLOBALS["WindowsUpdateCachingDir"] == null) {
$GLOBALS["WindowsUpdateCachingDir"] = "/home/squid/WindowsUpdate";
}
$filepath = "{$GLOBALS["WindowsUpdateCachingDir"]}/Queue.log";
$WindowsUpdateDownTimeout = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateDownTimeout"));
if ($WindowsUpdateDownTimeout == 0) {
$WindowsUpdateDownTimeout = 600;
}
$WindowsUpdateMaxToPartialQueue = $GLOBALS["WindowsUpdateMaxToPartialQueue"] * 1000;
$WindowsUpdateMaxToPartialQueue = $WindowsUpdateMaxToPartialQueue * 1000;
$LinesCount = $unix->COUNT_LINES_OF_FILE($filepath);
if (!is_file($filepath)) {
return;
}
$md5start = md5_file($filepath);
$handle = @fopen($filepath, "r");
if (!$handle) {
events("Fopen failed on {$filepath}", __LINE__);
return false;
}
$NEWBUFFER = array();
$URLALREADY = array();
$FinalSize = 0;
$FF = 0;
$c = 0;
while (!feof($handle)) {
$buffer = trim(fgets($handle));
$c++;
if ($buffer == null) {
continue;
}
$TR = explode("|||", $buffer);
//.........这里部分代码省略.........
示例14: ucarp_all_pid
function ucarp_all_pid($eth = null)
{
$unix = new unix();
$ucarp_bin = $unix->find_program("ucarp");
if ($eth != null) {
$eth = ".*?--interface={$eth}";
}
return $unix->PIDOF_PATTERN_ALL("{$ucarp_bin}{$eth}");
}
示例15: build
function build()
{
build_progress("{reconfigure} (1)", 2);
if ($GLOBALS["VERBOSE"]) {
echo "Running build...\n";
}
$unix = new unix();
$sock = new sockets();
$users = new usersMenus();
$forceCMD = null;
$argv = null;
$PHP = $unix->LOCATE_PHP5_BIN();
$mypid = getmypid();
if (isset($argv[1])) {
$argv = $argv[1];
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?{$argv}");
if (count($pids) > 1) {
build_progress("{already_process_exists_try_later}", 110);
while (list($num, $ligne) = each($pids)) {
$cmdline = @file_get_contents("/proc/{$num}/cmdline");
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Already process PID {$num} {$cmdline} exists..\n";
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Running " . @file_get_contents("/proc/{$num}/cmdline") . "\n";
}
die;
}
$EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
if (!is_numeric($EnableKerbAuth)) {
$EnableKerbAuth = 0;
}
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
$EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
if (!is_numeric($EnableRemoteStatisticsAppliance)) {
$EnableRemoteStatisticsAppliance = 0;
}
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
$UnlockWebStats = $sock->GET_INFO("UnlockWebStats");
if (!is_numeric($UnlockWebStats)) {
$UnlockWebStats = 0;
}
$ServiceFTPEnabled = intval($sock->GET_INFO("ServiceFTPEnabled"));
if ($users->WEBSTATS_APPLIANCE) {
$EnableWebProxyStatsAppliance = 1;
$sock->SET_INFO("{$EnableWebProxyStatsAppliance}", 1);
}
if ($EnableWebProxyStatsAppliance == 1) {
notify_remote_proxys();
}
if ($UnlockWebStats == 1) {
$EnableRemoteStatisticsAppliance = 0;
}
//Vérifie le compte utilisateur.
//------------------------------------------------------------------------------------------------------------------------------------------------------------
$unix->CreateUnixUser("squid", "squid", "Squid Cache Service");
$MustHave[] = "/etc/squid3/artica-meta/whitelist-nets.db";
$MustHave[] = "/var/logs/cache.log";
$MustHave[] = "/etc/squid3/squid-block.acl";
$MustHave[] = "/etc/squid3/allowed-user-agents.acl";
$MustHave[] = "/etc/squid3/GlobalAccessManager_auth.conf";
$MustHave[] = "/etc/squid3/icap.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_url_rewrite.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_deny_cache.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_deny.conf";
$MustHave[] = "/etc/squid3/squid-block.acl";
$MustHave[] = "/etc/squid3/clients_ftp.acl";
$MustHave[] = "/etc/squid3/allowed-user-agents.acl";
$MustHave[] = "/etc/squid3/whitelisted-computers-by-mac.acl";
while (list($none, $path) = each($MustHave)) {
echo "Starting......: " . date("H:i:s") . " [SYS]: checking {$path}\n";
if (!is_file($path)) {
@touch($path);
}
@chown($path, "squid");
@chgrp($path, "squid");
}
if ($GLOBALS["FORCE"]) {
$forceCMD = " --force";
}
$squidbin = $unix->LOCATE_SQUID_BIN();
if (!is_file($squidbin)) {
build_progress("{squid_binary_not_found}", 110);
echo "Starting......: " . date("H:i:s") . " [SERV]: Unable to stat squid binary, aborting..\n";
die;
}
$EXEC_TIME_FILE = "/etc/artica-postfix/" . basename(__FILE__) . ".build.time";
if (!$GLOBALS["FORCE"]) {
$time = $unix->file_time_min($EXEC_TIME_FILE);
if ($time == 0) {
build_progress("Failed! Only one config per minute !!!", 110);
echo "Starting......: " . date("H:i:s") . " [SERV]: Only one config per minute...\n";
die;
}
}
@unlink($EXEC_TIME_FILE);
@file_put_contents($EXEC_TIME_FILE, time());
if ($GLOBALS["EMERGENCY"]) {
squid_admin_mysql(0, "Reconfiguring Proxy service after Emergency enabled", null, __FILE__, __LINE__);
}
//.........这里部分代码省略.........