本文整理汇总了PHP中is_process_running函数的典型用法代码示例。如果您正苦于以下问题:PHP is_process_running函数的具体用法?PHP is_process_running怎么用?PHP is_process_running使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_process_running函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start_process
/**
* Start a process
*
* @param string $filename The PHP file of the process to run
* @param int $type The type (class) of process (so we can run multiple processes at the same time) defaults to 1
* @return bool|int False if we couldnt start a process, else the process id from the process table
*
* @link http://www.djkaty.com/php/fork Cross platform process tutorial (this code adapted from here)
*/
function start_process($filename, $type = 1)
{
//create a record only if no process already running
global $db;
$db->StartTrans();
$process = is_process_running($type);
$args = 0;
if ($process == false) {
$sql = "INSERT INTO `process` (`process_id`,`type`,`start`,`stop`,`kill`)\r\n\t\t\tVALUES (NULL,'{$type}',NOW(),NULL,0)";
$rs = $db->Execute($sql);
$args = $db->Insert_ID();
//execute the process in the background - pass the process_id as the first argument
if (substr(PHP_OS, 0, 3) == 'WIN') {
$proc = popen(WINDOWS_PHP_EXEC . ' ' . $filename . ' ' . $args, 'r');
} else {
$proc = popen(PHP_EXEC . ' ' . $filename . ' ' . $args . ' &', 'r');
}
pclose($proc);
} else {
$db->FailTrans();
}
$db->CompleteTrans();
if ($args != 0) {
return $args;
}
return false;
}
示例2: is_process_running
<i class="icon-play icon-white"></i>
</span>
<?php
} else {
?>
<span title="Durduruldu" class="label service red">
<i class="icon-stop icon-white"></i>
</span>
<?php
}
?>
</td>
</tr>
<tr>
<?php
$ntpdrunning = is_process_running("ntpd");
?>
<td class="cell">
ntpd
</td>
<td class="cell description sv">
NTP zaman eşitleme servisi
</td>
<td class="cell status">
<?php
if ($ntpdrunning) {
?>
<span title="Çalışıyor" class="label service blue">
<i class="icon-play icon-white"></i>
</span>
<?php
示例3: implode
}
}
}
}
}
if ($changed == true) {
@file_put_contents($file, implode("\n", $splitcontents));
}
}
}
}
if ($snortdownload == 'on' || $emergingthreats == 'on') {
/* You are Not Up to date, always stop snort when updating rules for low end machines */
/* Start the proccess for every interface rule */
if (is_array($config['installedpackages']['snortglobal']['rule'])) {
foreach ($config['installedpackages']['snortglobal']['rule'] as $id => $value) {
$if_real = snort_get_real_interface($value['interface']);
/* make oinkmaster.conf for each interface rule */
snort_apply_customizations($value, $if_real);
}
}
exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart");
sleep(10);
if (!is_process_running("snort")) {
exec("/bin/sh /usr/local/etc/rc.d/snort.sh start");
}
update_output_window(gettext("Snort has restarted with your new set of rules..."));
log_error("Snort has restarted with your new set of rules...");
}
update_status(gettext("The Rules update finished..."));
conf_mount_ro();
示例4: realpath
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
if (php_sapi_name() !== "cli") {
die;
}
/**
* Configuration file
*/
include realpath(dirname(__FILE__) . "/../config.inc.php");
/**
* Database file
*/
include realpath(dirname(__FILE__) . "/../db.inc.php");
/**
* Process
*/
include realpath(dirname(__FILE__) . "/../functions/functions.process.php");
//end any other process
$p = is_process_running(2);
if ($p) {
kill_process($p);
end_process($p);
}
start_process(realpath(dirname(__FILE__) . "/../admin/systemsortprocess.php"), 2);
$p = is_process_running();
if ($p) {
kill_process($p);
end_process($p);
}
start_process(realpath(dirname(__FILE__) . "/../admin/process.php"));
示例5: gettext
$pconfig['name'] = "racoon";
$pconfig['description'] = gettext("IPsec VPN");
$services[] = $pconfig;
unset($pconfig);
}
if ($services) {
foreach ($services as $service) {
if (!$service['name']) {
continue;
}
if (!$service['description']) {
$service['description'] = get_pkg_descr($service['name']);
}
echo '<tr><td class="listlr">' . $service['name'] . '</td>';
echo '<td class="listr">' . $service['description'] . '</td>';
if (is_service_running($service['name'], $ps) or is_process_running($service['name'])) {
echo '<td class="listr"><center>';
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\"> Running</td>";
$running = true;
} else {
echo '<td class="listbg"><center>';
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> <font color=\"white\">Stopped</td>";
$running = false;
}
echo '<td valign="middle" class="list" nowrap>';
if ($running) {
echo "<a href='status_services.php?mode=restartservice&service={$service['name']}'>";
echo "<img title='Restart Service' border='0' src='./themes/" . $g['theme'] . "/images/icons/icon_service_restart.gif'></a> ";
echo "<a href='status_services.php?mode=stopservice&service={$service['name']}'>";
echo "<img title='Stop Service' border='0' src='./themes/" . $g['theme'] . "/images/icons/icon_service_stop.gif'> ";
echo "</a>";
示例6: sprintf
$f5_web_client_port = $f5_credentials["f5_web_client_port"];
$f5_partition = $f5_credentials["f5_partition"];
$f5_user = $f5_credentials["f5_user"];
$f5_pass = $f5_credentials["f5_pass"];
$f5_pool = $f5_credentials["f5_pool"];
$f5_ip1 = $f5_credentials["f5_ip1"];
$f5_ip2 = $f5_credentials["f5_ip2"];
$fast_rollback_target = sprintf($server_cfg['config_directory'], $game_name);
$fast_rollback_target = $fast_rollback_target . $pool_name . ".sh";
foreach ($ip_list as $key => $ip) {
$rollback_command = "";
$pid[$ip] = register_node($ip, $f5_web_client_port, $f5_partition, $f5_user, $f5_pass, $f5_pool, $f5_ip1, $f5_ip2);
}
// Waiting for the registrarion process to complete
foreach ($ip_list as $key => $ip) {
while (is_process_running($pid[$ip])) {
sleep(1);
}
$ip_log_target = sprintf($server_cfg['log_file'], $ip);
$log_contents[$ip] = file_get_contents($ip_log_target);
}
$failed = false;
foreach ($log_contents as $ip => $log) {
if (stripos($log, "Terminating with exit code 0") !== false) {
echo "Registered node {$ip} with F5... \n";
} else {
$game_log = sprintf($server_cfg['log_file'], $game_name);
echo "Registration of node {$ip} failed. Check the game log. \n";
error_log('[' . date("F j, Y, g:i:s a e") . "]\n" . $log . "\n", 3, $game_log);
$failed = true;
}
示例7: array
$config['captiveportal'] = array();
$config['captiveportal']['page'] = array();
$config['captiveportal']['timeout'] = 300;
}
$pconfig['cinterface'] = $config['captiveportal']['interface'];
$pconfig['timeout'] = $config['captiveportal']['timeout'];
$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
$pconfig['enable'] = isset($config['captiveportal']['enable']);
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
if ($_POST['enable']) {
$reqdfields = explode(' ', 'cinterface');
$reqdfieldsn = array("Arayüz");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if (!is_process_running("mysqld")) {
start_mysql();
}
start_radius();
} else {
stop_radius();
}
if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || $_POST['timeout'] < 1)) {
$input_errors[] = 'Aktif oturum süresi 1 dakikadan az olamaz.';
}
if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || $_POST['idletimeout'] < 1)) {
$input_errors[] = 'Aktif oturum süresi 1 dakikadan az olamaz.';
}
if (!$input_errors) {
if (is_array($_POST['cinterface'])) {
$config['captiveportal']['interface'] = implode(',', $_POST['cinterface']);
示例8: suricata_apply_customizations
}
suricata_apply_customizations($value, $if_real);
$tmp = "\t" . $tmp . "\n";
error_log($tmp, 3, SURICATA_RULES_UPD_LOGFILE);
}
} else {
if ($pkg_interface != "console") {
update_output_window(gettext("Warning: No interfaces configured for Suricata were found..."));
update_output_window(gettext("No interfaces currently have Suricata configured and enabled on them..."));
}
error_log(gettext("\tWarning: No interfaces configured for Suricata were found...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
}
/* Clear the rebuild rules flag. */
$rebuild_rules = false;
/* Restart Suricata if already running and we are not in post-install, so as to pick up the new rules. */
if (is_process_running("suricata") && !$g['suricata_postinstall'] && count($config['installedpackages']['suricata']['rule']) > 0) {
// See if "Live Reload" is configured and signal each Suricata instance
// if enabled, else just do a hard restart of all the instances.
if ($config['installedpackages']['suricata']['config'][0]['live_swap_updates'] == 'on') {
if ($pkg_interface != "console") {
update_status(gettext('Signaling Suricata to live-load the new set of rules...'));
update_output_window(gettext("Please wait ... the process should complete in a few seconds..."));
}
log_error(gettext("[Suricata] Live-Reload of rules from auto-update is enabled..."));
error_log(gettext("\tLive-Reload of updated rules is enabled...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
foreach ($config['installedpackages']['suricata']['rule'] as $value) {
suricata_reload_config($value);
error_log(gettext("\tLive swap of updated rules requested for " . convert_friendly_interface_to_friendly_descr($value['interface']) . ".\n"), 3, SURICATA_RULES_UPD_LOGFILE);
}
log_error(gettext("[Suricata] Live-Reload of updated rules completed..."));
error_log(gettext("\tLive-Reload of the updated rules is complete.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
示例9: log_error
if (download_file("{$et_iqrisk_url}iprepdata.txt.gz", "{$iqRisk_tmppath}iprepdata.txt.gz") != true) {
log_error(gettext("[Suricata] An error occurred downloading the 'iprepdata.txt.gz' file for IQRisk."));
} else {
// If the files downloaded successfully, unpack them and store
// the list files in the SURICATA_IPREP_PATH directory.
if (file_exists("{$iqRisk_tmppath}iprepdata.txt.gz") && file_exists("{$iqRisk_tmppath}iprepdata.txt.gz.md5")) {
$new_md5 = trim(file_get_contents("{$iqRisk_tmppath}iprepdata.txt.gz.md5"));
if ($new_md5 == md5_file("{$iqRisk_tmppath}iprepdata.txt.gz")) {
mwexec("/usr/bin/gunzip -f {$iqRisk_tmppath}iprepdata.txt.gz");
@rename("{$iqRisk_tmppath}iprepdata.txt", "{$iprep_path}iprepdata.txt");
@rename("{$iqRisk_tmppath}iprepdata.txt.gz.md5", "{$iprep_path}iprepdata.txt.gz.md5");
$success = TRUE;
log_error(gettext("[Suricata] Successfully updated IPREP file 'iprepdata.txt'."));
} else {
log_error(gettext("[Suricata] MD5 integrity check of downloaded 'iprepdata.txt.gz' file failed! Skipping update of this IPREP file."));
}
}
}
}
// Cleanup the tmp directory path
rmdir_recursive("{$iqRisk_tmppath}");
log_error(gettext("[Suricata] Emerging Threats IQRisk IP List update finished."));
// If successful, signal any running Suricata process to live reload the rules and IP lists
if ($success == TRUE && is_process_running("suricata")) {
foreach ($config['installedpackages']['suricata']['rule'] as $value) {
if ($value['enable_iprep'] == "on") {
suricata_reload_config($value);
sleep(2);
}
}
}
示例10: getUPSData
function getUPSData()
{
global $config;
$data = "";
$cmd = "";
$nut_config = $config['installedpackages']['nut']['config'][0];
if ($nut_config['monitor'] == "local") {
// "Monitoring" field - upsdata_array[0]
$data = gettext("Local UPS");
$cmd = "upsc {$nut_config['name']}@localhost";
} elseif ($nut_config['monitor'] == "remote") {
// "Monitoring" field - upsdata_array[0]
$data = gettext("Remote UPS");
$cmd = "upsc {$nut_config['remotename']}@{$nut_config['remoteaddr']}";
} elseif ($nut_config['monitor'] == "snmp") {
// "Monitoring" field - upsdata_array[0]
$data = gettext("SNMP UPS");
$cmd = "upsc {$nut_config['snmpname']}@localhost";
}
if (is_process_running('upsmon')) {
$handle = popen($cmd, 'r');
if ($handle) {
$read = fread($handle, 4096);
pclose($handle);
$lines = explode("\n", $read);
if (count($lines) == 1) {
$condition = gettext("Data stale!");
} else {
$ups = array();
foreach ($lines as $line) {
$line = explode(':', $line);
$ups[$line[0]] = trim($line[1]);
}
}
}
} else {
$condition = gettext("NUT enabled, but service not running!");
if ($nut_config['monitor'] == "snmp") {
$condition .= gettext("\nSNMP UPS may be unreachable.");
}
}
if (isset($condition)) {
// Return error description
return $condition;
}
// "Model" field - upsdata_array[1]
$data .= ":" . ($ups['ups.model'] != "" ? $ups['ups.model'] : gettext("n/a"));
// "Status" field - upsdata_array[2]
$status = explode(" ", $ups['ups.status']);
foreach ($status as $condition) {
if ($disp_status) {
$disp_status .= ", ";
}
switch ($condition) {
case "WAIT":
$disp_status .= gettext("Waiting");
break;
case "OFF":
$disp_status .= gettext("Off Line");
break;
case "OL":
$disp_status .= gettext("On Line");
break;
case "OB":
$disp_status .= gettext("On Battery");
break;
case "TRIM":
$disp_status .= gettext("SmartTrim");
break;
case "BOOST":
$disp_status .= gettext("SmartBoost");
break;
case "OVER":
$disp_status .= gettext("Overload");
break;
case "LB":
$disp_status .= gettext("Battery Low");
break;
case "RB":
$disp_status .= gettext("Replace Battery");
break;
case "CAL":
$disp_status .= gettext("Calibration");
break;
case "CHRG":
$disp_status .= gettext("Charging");
break;
default:
$disp_status .= $condition;
break;
}
}
$data .= ":" . $disp_status;
// "Battery Charge" bars and field - upsdata_array[3]
$data .= ":" . $ups['battery.charge'] . "%";
// "Time Remaning" field - upsdata_array[4]
$secs = $ups['battery.runtime'];
if ($secs < 0 || $secs == "") {
$data .= ":" . gettext("n/a");
} else {
//.........这里部分代码省略.........
示例11: DAMAGES
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require "guiconfig.inc";
// Define basedir constant for unbound according to FreeBSD version (PBI support or no PBI)
if (floatval(php_uname("r")) >= 8.300000000000001) {
define("UNBOUND_BASE", "/usr/pbi/unbound-" . php_uname("m"));
} else {
define("UNBOUND_BASE", "/usr/local");
}
if (!is_process_running("unbound")) {
Header("Location: /pkg_edit.php?xml=unbound.xml&id=0");
exit;
}
$pgtitle = "Services: Unbound DNS Forwarder: Status";
include "head.inc";
function doCmdT($title, $command, $rows)
{
echo "<p>\n";
echo "<a name=\"" . $title . "\">\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
echo "<tr><td class=\"listlr\"><textarea style=\"font-family:courier\"cols=\"101\" rows=\"{$rows}\">";
/* no newline after pre */
if ($command == "dumpconfigxml") {
$fd = @fopen("/conf/config.xml", "r");
示例12: suricata_apply_customizations
}
suricata_apply_customizations($value, $if_real);
$tmp = "\t" . $tmp . "\n";
error_log($tmp, 3, $suricata_rules_upd_log);
}
} else {
if ($pkg_interface != "console") {
update_output_window(gettext("Warning: No interfaces configured for Suricata were found..."));
update_output_window(gettext("No interfaces currently have Suricata configured and enabled on them..."));
}
error_log(gettext("\tWarning: No interfaces configured for Suricata were found...\n"), 3, $suricata_rules_upd_log);
}
/* Clear the rebuild rules flag. */
$rebuild_rules = false;
/* Restart Suricata if already running and we are not rebooting to pick up the new rules. */
if (is_process_running("suricata") && !$g['booting'] && !empty($config['installedpackages']['suricata']['rule'])) {
// See if "Live Reload" is configured and signal each Suricata instance
// if enabled, else just do a hard restart of all the instances.
if ($config['installedpackages']['suricata']['config'][0]['live_swap_updates'] == 'on') {
if ($pkg_interface != "console") {
update_status(gettext('Signalling Suricata to live-load the new set of rules...'));
update_output_window(gettext("Please wait ... the process should complete in a few seconds..."));
}
log_error(gettext("[Suricata] Live-Reload of rules from auto-update is enabled..."));
error_log(gettext("\tLive-Reload of updated rules is enabled...\n"), 3, $suricata_rules_upd_log);
foreach ($config['installedpackages']['suricata']['rule'] as $value) {
$if_real = get_real_interface($value['interface']);
suricata_reload_config($value);
error_log(gettext("\tLive swap of updated rules requested for " . convert_friendly_interface_to_friendly_descr($value['interface']) . ".\n"), 3, $suricata_rules_upd_log);
}
log_error(gettext("[Suricata] Live-Reload of updated rules completed..."));
示例13: file_get_contents
if ($service_running) {
echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
} else {
echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=start' alt='start'>" . $text['label-start'] . "</a>";
}
}
} else {
echo "<strong>UNSUPPORT</strong>";
echo "</td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
echo "<strong>UNSUPPORT</strong>";
}
} else {
if ($row[service_type] == "pid" || $row[service_type] == "pid_file") {
$pid = file_get_contents($row[service_data]);
$service_running = is_process_running($pid);
}
if ($row[service_type] == "file") {
$service_data = $row[service_data];
$service_running = file_exists($service_data);
}
if ($service_running) {
echo "<strong>" . $text['label-running'] . "</strong>";
} else {
echo "<strong>" . $text['label-stopped'] . "</strong>";
}
echo "</td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
if ($service_running) {
echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
} else {
示例14: get_pdt_per_page
function get_pdt_per_page($pool_ip, $instance_count, $prev_pdt = NULL)
{
$dir = "/tmp/pdts/";
// Delete the previous pdts
del_dir_create($dir);
$relative_path = realpath(dirname(__FILE__));
$pdt_count = -1;
$loop = 0;
$parallel = 20;
if ($instance_count < 20) {
$parallel = $instance_count;
}
$instance_count_parallel = $instance_count / $parallel;
$required_pdt = (int) (0.66 * $instance_count);
// 2/3 rd of instance_count
$cmd = "php {$relative_path}/get_pdt.php -p " . $pool_ip . " -c " . $instance_count_parallel;
$pid_array = array();
//Maximum number of hits = 2*instance_count
while ($pdt_count < $required_pdt && $loop < 3) {
for ($i = 0; $i < $parallel; $i++) {
$pid_array[] = run_in_background($cmd);
}
// Wait for the process to complete
foreach ($pid_array as $pid) {
while (is_process_running($pid)) {
sleep(1);
}
}
$pdt_count = count(glob($dir . "*"));
$loop++;
}
if ($pdt_count < $required_pdt) {
die("ERROR: Required number ( {$required_pdt} ) of pdt.json not fetched. Fetched {$pdt_count} pdt.json from 3*instance_count fetches.\n");
}
exec("/usr/local/zperfmon/bin/pdt.py " . $dir . "*", $pdt_aggr);
$file_count = array_shift($pdt_aggr);
$file_count = explode(" ", $file_count);
$file_count = intval($file_count[1]);
$page_pdt = array();
foreach ($pdt_aggr as $pdt_list) {
$pdt_list_array = explode(",", $pdt_list);
$page_name = $pdt_list_array[0];
$pdt = "";
$count_per_file = intval($pdt_list_array[1] / $file_count);
$time_per_file = intval($pdt_list_array[2] / $file_count);
if ($prev_pdt != NULL) {
$prev_count = $prev_pdt[$page_name][0];
$prev_time = $prev_pdt[$page_name][1];
if ($prev_count < $count_per_file) {
$count_diff = $count_per_file - $prev_count;
$time_diff = $time_per_file - $prev_time;
$pdt = intval($time_diff / $count_diff);
} else {
$pdt = $pdt_list_array[3];
}
} else {
$pdt = $pdt_list_array[3];
}
$page_pdt[$page_name] = array($count_per_file, $time_per_file, $pdt);
}
return $page_pdt;
}
示例15: gettext
$tmp .= gettext("\tPreprocessor text rules flagged as protected and not updated for ");
$tmp .= convert_friendly_interface_to_friendly_descr($value['interface']) . "...\n";
}
error_log($tmp, 3, $snort_rules_upd_log);
}
} else {
if ($pkg_interface != "console") {
update_output_window(gettext("Warning: No interfaces configured for Snort were found..."));
update_output_window(gettext("No interfaces currently have Snort configured and enabled on them..."));
}
error_log(gettext("\tWarning: No interfaces configured for Snort were found...\n"), 3, $snort_rules_upd_log);
}
/* Clear the rebuild rules flag. */
$rebuild_rules = false;
/* Restart snort if already running and we are not rebooting to pick up the new rules. */
if (is_process_running("snort") && !$g['booting']) {
if ($pkg_interface != "console") {
update_status(gettext('Restarting Snort to activate the new set of rules...'));
update_output_window(gettext("Please wait ... restarting Snort will take some time..."));
}
error_log(gettext("\tRestarting Snort to activate the new set of rules...\n"), 3, $snort_rules_upd_log);
restart_service("snort");
if ($pkg_interface != "console") {
update_output_window(gettext("Snort has restarted with your new set of rules..."));
}
log_error(gettext("[Snort] Snort has restarted with your new set of rules..."));
error_log(gettext("\tSnort has restarted with your new set of rules.\n"), 3, $snort_rules_upd_log);
} else {
if ($pkg_interface != "console") {
update_output_window(gettext("The rules update task is complete..."));
}