本文整理汇总了PHP中unix::PIDOF_PATTERN方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::PIDOF_PATTERN方法的具体用法?PHP unix::PIDOF_PATTERN怎么用?PHP unix::PIDOF_PATTERN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::PIDOF_PATTERN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
function restore($filename)
{
$unix = new unix();
$sock = new sockets();
$TMP = $unix->FILE_TEMP();
$filenameBase = basename($filename);
if (!is_file($filename)) {
echo "{$filename} no such file\n";
build_progress("{failed}", 110);
}
$tmpf = $unix->FILE_TEMP();
build_progress("{uncompress} {$filenameBase}", 10);
if (!$unix->uncompress($filename, $tmpf)) {
@unlink($filename);
build_progress("{uncompress} {$filenameBase} {failed}", 110);
return;
}
@unlink($filename);
build_progress("{importing} {$tmpf}", 50);
$q = new mysql_squid_builder();
$nice = $unix->EXEC_NICE();
$mysql = $unix->find_program("mysql");
$gzip = $unix->find_program("gzip");
$nohup = $unix->find_program("nohup");
$echo = $unix->find_program("echo");
$rm = $unix->find_program("rm");
$php = $unix->LOCATE_PHP5_BIN();
$sh[] = "#!/bin/sh";
$sh[] = "{$echo} \"{$mysql} -> {$filenameBase}\"";
$sh[] = "{$nice} {$mysql} {$q->MYSQL_CMDLINES} -f squidlogs < {$tmpf}";
$sh[] = "{$rm} {$TMP}.sh";
$sh[] = "\n";
@file_put_contents("{$TMP}.sh", @implode("\n", $sh));
@chmod("{$TMP}.sh", 0755);
build_progress(10, "Starting restore {$filenameBase} - " . basename("{$TMP}.sh") . " ");
system("{$nohup} {$TMP}.sh >{$TMP}.txt 2>&1 &");
sleep(1);
$PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
echo "Running PID {$PID}\n";
while ($unix->process_exists($PID)) {
build_progress(50, "Starting restoring {$filenameBase}");
sleep(3);
$PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
echo "Running PID {$PID}\n";
}
echo @file_get_contents("{$TMP}.txt") . "\n";
@unlink("{$TMP}.sh");
@unlink("{$TMP}.txt");
build_progress(50, "{restore} {done} {$filenameBase}");
build_progress(50, "{restore} Analyze Hourly tables");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --force --verbose");
build_progress(60, "{restore} Repair Hourly tables");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --repair --force --verbose");
build_progress(70, "{restore} Repair Table days");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.repair.php --tables-day --repair --force --verbose");
build_progress(80, "{restore} Repair sums");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.totals.php --repair --force --verbose");
build_progress(100, "{restore} Done");
}
示例2: checkProcess1
function checkProcess1(){
$unix=new unix();
$pid=$unix->PIDOF_PATTERN("bin/process1");
if($pid<5){return null;}
$process1=$unix->PROCCESS_TIME_MIN($pid);
$mem=$unix->PROCESS_MEMORY($pid);
Myevents("process1: $pid ($process1 mn) memory:$mem Mb",__FUNCTION__);
if($mem>30){
@copy("/var/log/artica-postfix/process1.debug","/var/log/artica-postfix/process1.killed".time().".debug");
system("/bin/kill -9 $pid");
$unix->send_email_events(
"artica process1 (process1) Killed",
"Process1 use too much memory $mem MB","watchdog");
}
if($process1>2){
@copy("/var/log/artica-postfix/process1.debug","/var/log/artica-postfix/process1.killed".time().".debug");
system("/bin/kill -9 $pid");
$unix->send_email_events(
"artica process1 (process1) Killed",
"Process1 run since $process1 Pid: $pid and exceed 2 minutes live","watchdog");
}
}
示例3: InMemQUestion
function InMemQUestion()
{
$unix = new unix();
$pid = $unix->PIDOF_PATTERN("philesight --db");
if ($unix->process_exists($pid)) {
return true;
}
return false;
}
示例4: XZARAFA_SERVER_PID
function XZARAFA_SERVER_PID()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/zarafa-server.pid");
if ($unix->process_exists($pid)) {
return $pid;
}
return $unix->PIDOF_PATTERN("zarafa-server -c /etc/zarafa/server.cfg");
}
示例5: PID_NUM
function PID_NUM()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/openvpn/openvpn-server.pid");
if ($unix->process_exists($pid)) {
return $pid;
}
$Masterbin = $unix->find_program("openvpn");
return $unix->PIDOF_PATTERN("{$Masterbin} --port.+?--dev");
}
示例6: PID_NUM
function PID_NUM()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/zarafa-web/httpd.pid");
if ($unix->process_exists($pid)) {
return $pid;
}
$apachebin = $unix->LOCATE_APACHE_BIN_PATH();
return $unix->PIDOF_PATTERN("{$apachebin}.*?/etc/zarafa/httpd.conf");
}
示例7: ZARAFADB_PID
function ZARAFADB_PID()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/zarafa-db.pid");
if ($unix->process_exists($pid)) {
return $pid;
}
$mysqld = $unix->find_program("mysqld");
$pid = $unix->PIDOF_PATTERN("{$mysqld}.*?--pid-file=/var/run/zarafa-db.pid");
return $pid;
}
示例8: GETPID
function GETPID()
{
$unix = new unix();
if (is_file("/var/run/suricata-tail.pid")) {
$pid = @file_get_contents("/var/run/suricata-tail.pid");
}
if ($unix->process_exists($pid)) {
return $pid;
}
$pid = $unix->PIDOF_PATTERN("/usr/share/artica-postfix/bin/suricata-tail.py");
if ($unix->process_exists($pid)) {
return $pid;
}
}
示例9: GETPID
function GETPID()
{
$unix = new unix();
if (is_file('/etc/artica-postfix/exec.hotspot-tail.php.pid')) {
$pid = @file_get_contents("'/etc/artica-postfix/exec.hotspot-tail.php.pid'");
}
if ($unix->process_exists($pid)) {
return $pid;
}
$pid = $unix->PIDOF("/bin/hotspot-tail");
if ($unix->process_exists($pid)) {
return $pid;
}
return $unix->PIDOF_PATTERN("exec.hotspot-tail.php");
}
示例10: PID_NUM
function PID_NUM()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/urlfilterdb/ufdbguardd.pid");
if ($unix->process_exists($pid)) {
$cmdline = trim(@file_get_contents("/proc/{$pid}/cmdline"));
if (!preg_match("#ufdbcatdd#", $cmdline)) {
return $pid;
}
}
$Masterbin = $unix->find_program("ufdbguardd");
$pid = $unix->PIDOF_PATTERN("ufdbguardd.*?-c.*?conf");
if ($unix->process_exists($pid)) {
return $pid;
}
}
示例11: PID_NUM
function PID_NUM()
{
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/ufdbcat/ufdbguardd.pid");
if ($unix->process_exists($pid)) {
return $pid;
}
$pid = $unix->PIDOF_PATTERN("ufdbcatdd.*?-c.*?conf");
if ($unix->process_exists($pid)) {
return $pid;
}
}
示例12: Scan
function Scan($filepath, $md5file = null)
{
$unix = new unix();
if ($filepath == null) {
echo "No path defined\n";
return;
}
$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";
die;
}
}
}
$nextFile = null;
if (!is_file($filepath)) {
if ($md5file != null) {
mysql_progress($md5file, 100, 3, "{$filepath} no such file");
}
echo "{$filepath} no such file";
}
@mkdir("/home/artica/import-temp", 0755, true);
$basename = basename($filepath);
if (preg_match("#\\.gz\$#", $basename)) {
if ($md5file != null) {
mysql_progress($md5file, 5, 0, "Uncompress {$filepath}");
}
echo "Uncompress {$basename}";
$nextFile = dirname($filepath) . "/" . str_replace(".gz", "", $basename);
echo "Uncompress {$basename} to {$nextFile}\n";
if (is_file($nextFile)) {
@unlink($nextFile);
}
if (!$unix->uncompress($filepath, $nextFile)) {
if ($md5file != null) {
mysql_progress($md5file, 100, 3, "Uncompress {$basename} failed");
}
echo "Uncompress {$basename} failed\n";
return false;
}
$filepath = $nextFile;
}
if (!ExplodeFile($filepath, $md5file)) {
return false;
}
if ($nextFile != null) {
@unlink($nextFile);
}
return true;
}
示例13: start
function start($aspid = false)
{
$GLOBALS["LOGS"] = array();
$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;
}
$SquidPerformance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidPerformance"));
$HyperCacheStoreID = intval($sock->GET_INFO("HyperCacheStoreID"));
$kill = $unix->find_program("kill");
if ($SQUIDEnable == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Proxy service is disabled...\n";
}
return;
}
if ($HyperCacheStoreID == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: HyperCache is disabled...\n";
}
return;
}
if ($SquidPerformance > 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Statistics are disabled...\n";
}
return;
}
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") . " [INIT]: Proxy service is locked (since {$time}Mn...\n";
}
return;
}
@unlink("/etc/artica-postfix/squid.lock");
}
if (!$aspid) {
$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["DAEMON_NAME"]}, Already task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = GETPID();
if (!is_file($GLOBALS["log_path"])) {
@file_put_contents($GLOBALS["log_path"], "");
}
@chmod($GLOBALS["log_path"], 0755);
@chown($GLOBALS["log_path"], "squid");
if ($unix->process_exists($pid)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["DAEMON_NAME"]}, already running since {$time}Mn\n";
}
return;
}
$tail = $unix->find_program("tail");
if (!is_file("/bin/hypercache-tail")) {
@copy($tail, "/bin/hypercache-tail");
}
@chmod("/bin/hypercache-tail", 0755);
$pid = $unix->PIDOF_PATTERN("/bin/hypercache-tail -F -n 0 {$GLOBALS["log_path"]}");
if ($unix->process_exists($pid)) {
for ($i = 0; $i < 20; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: killing old process pid {$pid}\n";
}
unix_system_kill_force($pid);
usleep(800);
$pid = $unix->PIDOF_PATTERN("/bin/hypercache-tail -F -n 0 {$GLOBALS["log_path"]}");
if (!$unix->process_exists($pid)) {
break;
}
unix_system_kill_force($pid);
}
}
$cmd = "/bin/hypercache-tail --follow=name --retry --max-unchanged-stats=50 -n 0 {$GLOBALS["log_path"]}|{$GLOBALS["TAIL_STARTUP"]} >>/var/log/artica-postfix/squid-logger-start.log 2>&1 &";
shell_exec($cmd);
for ($i = 0; $i < 6; $i++) {
$pid = GETPID();
if ($unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["DAEMON_NAME"]}, waiting {$i}/5\n";
}
sleep(1);
//.........这里部分代码省略.........
示例14: 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__);
//.........这里部分代码省略.........
示例15: redis_pid
function redis_pid()
{
$unix = new unix();
$masterbin = $unix->find_program("redis-server");
$pid = $unix->get_pid_from_file('/var/run/redis/redis-server.pid');
if ($unix->process_exists($pid)) {
return $pid;
}
return $unix->PIDOF_PATTERN($masterbin . " -f /etc/redis/redis.conf");
}