<?php require_once 'auth.php'; try { $file_db = new PDO('sqlite:../www_data/db.sqlite3'); //Parse the input thing to authenticate the request if (!auth_it($file_db, "STATUS")) { exit; } //Create table my_ips if need be $proc_exist = null; foreach ($file_db->query('SELECT name FROM sqlite_master WHERE type="table" AND name="process"') as $row) { $proc_exist = $row['name']; } if ($proc_exist == null) { $file_db->exec('CREATE TABLE main.process(pid INT, cmd TEXT, subdir TEXT, updated INT)'); } echo '{'; $total_mem = shell_exec("grep MemTotal /proc/meminfo | awk '{print \$2}'"); $free_mem = shell_exec("grep MemFree /proc/meminfo | awk '{print \$2}'"); echo '"FREE_MEM": "' . round(floatval($free_mem) / floatval($total_mem) * 100, 2) . '%",'; $arch = shell_exec("lscpu | grep Architecture | awk '{print \$2}'"); echo '"ARCH": "' . $arch . '",'; $cpu_cnt = shell_exec("lscpu | grep 'CPU(s):' | awk '{print \$2}'"); echo '"CPU_COUNT": "' . $cpu_cnt . '",'; $cpu_usage = shell_exec("mpstat 2 1 | grep 'Average' | awk '{print (100 - \$11)}'"); echo '"CPU_USAGE": "' . floatval($cpu_usage) . '%",'; //Get list of proces running on this machineOB $process = []; foreach ($file_db->query('SELECT pid, cmd FROM process') as $row) { $pid = $row['pid'];
<?php require_once 'auth.php'; try { $file_db = new PDO('sqlite:../www_data/db.sqlite3'); //Parse the input thing to authenticate the request if (!auth_it($file_db, "REMOVE")) { exit; } if (isset($_GET['PROCID'])) { $PROC_ID = $_GET['PROCID']; #$result=shell_exec('kill ' . $PROC_ID); #echo $result; $file_db->exec('DELETE FROM process WHERE pid=' . $PROC_ID); echo '{"error":null}'; } else { echo '{"error":"PID $_GET parameter was not set"}'; } $file_db = null; } catch (Exception $err) { echo '{"error":"' . err . '"}'; } ?>
<?php require_once 'auth.php'; try { $file_db = new PDO('sqlite:../www_data/db.sqlite3'); //Parse the input thing to authenticate the request if (!auth_it($file_db, "CREATE")) { exit; } if (isset($_GET['ENV']) && isset($_GET['SCRIPT']) && isset($_GET['PID'])) { $the_env = $_GET['ENV']; $the_script = $_GET['SCRIPT']; $the_pid = $_GET['PID']; if (strcmp($the_env, 'devel') != 0 && strcmp($the_env, 'prod') != 0) { echo '{"error":"ENV(' . $the_env . ' is not a valid value [devel|prod]"}'; exit; } if (strcmp($the_script, 'pdf_upload_api') != 0 && strcmp($the_script, 'pdf_decide') != 0 && strcmp($the_script, 'pdf_decide_priority') != 0) { echo '{"error":"SCRIPT(' . $the_script . ' is not a valid value [pdf_upload"}'; exit; } } else { echo '{"error":"ENV and/or SCRIPT are not set in the $_GET parameter"}'; exit; } $final_script = null; $pid = $the_pid; $subdir = null; if (strcmp($the_script, 'pdf_upload_api') == 0) { $final_script = 'rabbitmq_pdf_upload_api.py -e ' . $the_env; $subdir = "upload_pdf";