-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessManager.php
More file actions
37 lines (31 loc) · 1001 Bytes
/
ProcessManager.php
File metadata and controls
37 lines (31 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include_once("config.php");
include_once("./DBConfig.php");
include_once("./Executer.php");
class ProcessManager {
private $con;
function getProcInDb() {
$results = array();
$db = new DBConfig(MYSQL_HOST, MYSQL_USER_NAME, MYSQL_PASSWORD);
$this->con = $db->connect();
$sql = "SELECT site,pid from " . DB_SITEDEMO_NAME . ".processrunning";
$result = $this->con->query($sql);
while ($row = $result->fetch_array()) {
$results[$row['pid']] = $row['site'];
}
return $results;
}
function getProceRunning($name) {
$results = array();
$exec = new Executer();
$cmd = "ps aux | grep " . $name . "|grep -v grep | awk '{ print $2 }'";
$exec->execute($cmd);
$pids = $exec->getStdOut();
if ($pids != null && is_array($pids)) {
foreach ($pids as $pid) {
$results[] = trim($pid);
}
}
return $results;
}
}