function XZARAFA_GATEWAY_PID() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/zarafa-gateway.pid"); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($unix->find_program("zarafa-gateway")); }
function PID_NUM() { $filename = PID_PATH(); $pid = trim(@file_get_contents($filename)); $unix = new unix(); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($unix->find_program("memcached")); }
function SQUID_PID() { $unix = new unix(); $squidbin = $unix->LOCATE_SQUID_BIN(); $pid = $unix->get_pid_from_file($unix->LOCATE_SQUID_PID()); if (!$unix->process_exists($pid)) { $pid = $unix->PIDOF($squidbin); } return $pid; }
function GET_PID() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/rsyslogd.pid"); if ($unix->process_exists($pid)) { return $pid; } $rsyslogd = $unix->find_program("rsyslogd"); return $unix->PIDOF($rsyslogd); }
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"); }
function PID_NUM() { $filename = PID_PATH(); $pid = trim(@file_get_contents($filename)); $unix = new unix(); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($unix->LOCATE_STUNNEL()); }
function PID_NUM() { $unix = new unix(); $Masterbin = $unix->find_program("conntrackd"); if (!is_file($Masterbin)) { return 0; } return $unix->PIDOF($Masterbin); }
function SingleInstance_pid() { $unix = new unix(); $pidpath = "/var/run/milter-greylist/milter-greylist.pid"; $pid = $unix->get_pid_from_file($pidpath); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($unix->find_program("milter-greylist")); }
function zipproxy_pid() { $unix = new unix(); $masterbin = $unix->find_program("ziproxy"); $pid = $unix->get_pid_from_file('/var/run/squid/ziproxy.pid'); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($masterbin); }
function Kav4ProxyUpdate() { $unix = new unix(); $cmd = "/opt/kaspersky/kav4proxy/bin/kav4proxy-keepup2date"; $type = $_GET["type"]; if ($type == "milter") { if (is_file("/opt/kav/5.6/kavmilter/bin/keepup2date")) { $cmd = "/opt/kav/5.6/kavmilter/bin/keepup2date"; } if (is_file("/opt/kaspersky/kav4lms/bin/kav4lms-keepup2date")) { shell_exec("/usr/share/artica-postfix/bin/artica-install --kavm4mls-info"); $cmd = "/opt/kaspersky/kav4lms/bin/kav4lms-keepup2date"; } } if ($type == "kas") { $cmd = "/usr/local/ap-mailfilter3/bin/keepup2date -c /usr/local/ap-mailfilter3/etc/keepup2date.conf"; } $pid = $unix->PIDOF(basename($cmd)); if (strlen($pid) > 0) { return; } @file_put_contents("/usr/share/artica-postfix/ressources/logs/Kav4ProxyUpdate", "{waiting}...\nSelected {$type}: " . basename($cmd) . "\n\n"); @chmod("/usr/share/artica-postfix/ressources/logs/Kav4ProxyUpdate", 0775); sys_THREAD_COMMAND_SET("{$cmd} >>/usr/share/artica-postfix/ressources/logs/Kav4ProxyUpdate"); }
function PID_NUM() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/clamav/clamd.pid"); if ($unix->process_exists($pid)) { return $pid; } $Masterbin = $unix->find_program("clamd"); return $unix->PIDOF($Masterbin); }
function PID_NUM() { $unix = new unix(); $pid = $unix->get_pid_from_file("/home/ArticaStatsDB/postmaster.pid"); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF("/usr/local/ArticaStats/bin/postgres"); }
function ParseRetranslatorLogs() { $unix = new unix(); if ($unix->PIDOF("/usr/share/artica-postfix/bin/retranslator.bin") > 0) { return; } $dir = "/var/log/kretranslator"; if (!is_dir($dir)) { return null; } $unix = new unix(); $files = $unix->DirFiles($dir); while (list($num, $file) = each($files)) { if (!preg_match("#retranslator-([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+).debug#", $file, $re)) { continue; } $date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}"; $NumberofFilesUpdated = NumberofRestransFilesUpdated("{$dir}/{$file}"); if ($NumberofFilesUpdated[0] > 0) { $subject = "Kaspersky Retranslator: {$NumberofFilesUpdated[0]} files updated ({$NumberofFilesUpdated[1]})"; send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date); @unlink("{$dir}/{$file}"); continue; } @unlink("{$dir}/{$file}"); } }
function DEFAULT_PID() { $unix = new unix(); $pid = $unix->get_pid_from_file('/var/run/fetchmail.pid'); if ($unix->process_exists($pid)) { return $pid; } $fetchmail = $unix->find_program("fetchmail"); return $unix->PIDOF($fetchmail); }
function ntopng_pid() { $unix = new unix(); $masterbin = $unix->find_program("ntopng"); $pid = $unix->get_pid_from_file('/var/run/ntopng/ntopng.pid'); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($masterbin); }
function WINBIND_PID() { $pidfile = "/var/run/samba/winbindd.pid"; $unix = new unix(); $pid = $unix->get_pid_from_file($pidfile); if (!$unix->process_exists($pid)) { $winbindbin = $unix->find_program("winbindd"); $pid = $unix->PIDOF($winbindbin); } return $pid; }
function DEFAULT_PID() { $unix = new unix(); $pid = $unix->get_pid_from_file('/var/run/spawn-fcgi.pid'); if ($unix->process_exists($pid)) { return $pid; } $spawn_fcgi = $unix->find_program("spawn-fcgi"); return $unix->PIDOF($spawn_fcgi); }
function OverloadedCheckBadProcesses() { $unix = new unix(); $kill = $unix->find_program("kill"); if (is_file("/opt/kaspersky/kav4proxy/bin/kav4proxy-keepup2date")) { $pid = $unix->PIDOF("/opt/kaspersky/kav4proxy/bin/kav4proxy-keepup2date"); if ($pid > 0) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($time > 90) { $unix->send_email_events("kav4proxy-keepup2date pid: {$pid} killed", "It was running since {$time}Mn, and reach the maximal 90mn TTL", "proxy"); unix_system_kill_force($pid); } } } }
function ufdbguard_start() { $unix = new unix(); $sock = new sockets(); $nohup = $unix->find_program("nohup"); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { build_progress("Already task executed", 110); echo "Starting......: " . date("H:i:s") . " Webfiltering service Starting service aborted, task pid already running {$pid}\n"; writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__); return; } @file_put_contents($pidfile, getmypid()); $pid_path = "/var/tmp/ufdbguardd.pid"; if (!is_dir("/var/tmp")) { @mkdir("/var/tmp", 0775, true); } $ufdbguardd_path = $unix->find_program("ufdbguardd"); $master_pid = ufdbguard_pid(); if (!$unix->process_exists($master_pid)) { if (function_exists("WriteToSyslogMail")) { WriteToSyslogMail("UfdGuard master Daemon seems to not running, trying with pidof", basename(__FILE__)); } $master_pid = $unix->PIDOF($ufdbguardd_path); if ($unix->process_exists($master_pid)) { echo "Starting......: " . date("H:i:s") . " UfdGuard master is running, updating PID file with {$master_pid}\n"; if (function_exists("WriteToSyslogMail")) { WriteToSyslogMail("UfdGuard master is running, updating PID file with {$master_pid}", basename(__FILE__)); } @file_put_contents($pid_path, $master_pid); build_progress("Already running...", 76); return true; } } $EnableUfdbGuard = intval($sock->EnableUfdbGuard()); $SQUIDEnable = $sock->GET_INFO("SQUIDEnable"); $UseRemoteUfdbguardService = $sock->GET_INFO('UseRemoteUfdbguardService'); if (!is_numeric($UseRemoteUfdbguardService)) { $UseRemoteUfdbguardService = 0; } if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; } if ($UseRemoteUfdbguardService == 1) { $EnableUfdbGuard = 0; } if ($SQUIDEnable == 0) { $EnableUfdbGuard = 0; } if ($EnableUfdbGuard == 0) { echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master service Aborting, service is disabled\n"; return; } $trace = debug_backtrace(); if (isset($trace[1])) { $called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}"; } squid_admin_mysql(2, "{starting_web_filtering} engine service", "{$trace}\n{$GLOBALS["CMDLINEXEC"]}"); ufdbguard_admin_events("Asking to start ufdbguard {$trace}", __FUNCTION__, __FILE__, __LINE__, "ufdbguard-service"); echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master service...\n"; if (function_exists("WriteToSyslogMail")) { WriteToSyslogMail("Starting UfdGuard master service...", basename(__FILE__)); } @mkdir("/var/log/ufdbguard", 0755, true); @file_put_contents("/var/log/ufdbguard/ufdbguardd.log", "#"); @chown("/var/log/ufdbguard/ufdbguardd.log", "squid"); @chgrp("/var/log/ufdbguard/ufdbguardd.log", "squid"); shell_exec("{$nohup} /etc/init.d/ufdb start >/dev/null 2>&1 &"); for ($i = 1; $i < 5; $i++) { build_progress("Starting {webfiltering} waiting {$i}/5", 76); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " Starting UfdGuard waiting {$i}/5\n"; } sleep(1); $pid = ufdbguard_pid(); if ($unix->process_exists($pid)) { break; } } echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master init.d ufdb done...\n"; $master_pid = ufdbguard_pid(); if (!$unix->process_exists($master_pid)) { echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master service failed...\n"; squid_admin_mysql(0, "{starting_web_filtering} engine service failed", "{$trace}\n{$GLOBALS["CMDLINEXEC"]}\n"); return false; } echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master success pid {$master_pid}...\n"; squid_admin_mysql(2, "{starting_web_filtering} engine service success", "{$trace}\n{$GLOBALS["CMDLINEXEC"]}\n"); echo "Starting......: " . date("H:i:s") . " Starting UfdGuard master ufdbguard_start() function done\n"; return true; }
function dhcpd_pid() { $unix = new unix(); $filename = "/var/run/dhcpd.pid"; $pid = $unix->get_pid_from_file($filename); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF($unix->DHCPD_BIN_PATH()); }
function CROSSROADS_EVENTS() { $unix = new unix(); $master_pid = trim($unix->PIDOF($unix->find_program("xr"))); shell_exec($unix->find_program("kill -1 ") . " {$master_pid}"); exec($unix->find_program("tail") . " -n 500 /var/log/crossroads.log 2>&1", $results); echo "<articadatascgi>" . base64_encode(serialize($results)) . "</articadatascgi>"; }
function SafeProcesses() { $users = new usersMenus(); if ($users->CPU_NUMBER > 1) { return; } $sock = new sockets(); $DisableSafeProcesses = $sock->GET_INFO("DisableSafeProcesses"); if (!is_numeric($DisableSafeProcesses)) { $DisableSafeProcesses = 0; } if ($DisableSafeProcesses == 1) { return null; } $q = new mysql(); $unix = new unix(); $restartStatus = false; $arraySTOP = array(); $kill = $unix->find_program("kill"); if ($q->COUNT_ROWS("freeweb", "artica_backup") == 0) { $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb"); $PureFtpdEnabled = $sock->GET_INFO("PureFtpdEnabled"); if (!is_numeric($EnableFreeWeb)) { $EnableFreeWeb = 1; } if (!is_numeric($PureFtpdEnabled)) { $PureFtpdEnabled = 1; } if ($EnableFreeWeb == 1) { $sock->SET_INFO("EnableFreeWeb", 0); $restartStatus = true; $arraySTOP[] = "FreeWebs is now disabled (you did not have any websites set)"; shell_exec("/etc/init.d/artica-postfix stop apachesrc"); } if ($PureFtpdEnabled == 1) { $restartStatus = true; $sock->SET_INFO("PureFtpdEnabled", 0); $arraySTOP[] = "PureTFPD is now disabled (you did not have any websites set)"; shell_exec("/etc/init.d/artica-postfix stop ftp"); } } $vnstatd = $unix->find_program("vnstatd"); if (is_file($vnstatd)) { $EnableVnStat = $sock->GET_INFO("EnableVnStat"); if (!is_numeric($EnableVnStat)) { $EnableVnStat = 0; } if ($EnableVnStat == 1) { $arraySTOP[] = "vnStat Daemon (Network Card interfaces) is now disabled"; $sock->SET_INFO("EnableVnStat", 0); $restartStatus = true; shell_exec("/etc/init.d/artica-postfix stop vnstat"); } } $FreshClam = $unix->find_program("freshclam"); if (is_file($FreshClam)) { $EnableFreshClam = $sock->GET_INFO("EnableFreshClam"); if (!is_numeric($EnableFreshClam)) { $EnableFreshClam = 1; } if ($EnableFreshClam == 1) { $arraySTOP[] = "FreshClam Clamav Daemon updater is now disabled"; $sock->SET_INFO("EnableFreshClam", 0); $restartStatus = true; shell_exec("/etc/init.d/artica-postfix stop freshclam"); } } if ($restartStatus) { shell_exec("/etc/init.d/artica-status reload"); } $preload = $unix->find_program("preload"); if (is_file($preload)) { $pid = $unix->PIDOF($preload); if ($pid > 5) { $arraySTOP[] = $preload . ":[{$pid}]"; shell_exec("kill -9 {$pid}"); } } $named = $unix->find_program("named"); if (is_file($named)) { $pid = $unix->PIDOF($named); if ($pid > 5) { $arraySTOP[] = $named . ":[{$pid}]"; shell_exec("kill -9 {$pid}"); } } $firefox = "/usr/lib/iceweasel/firefox-bin"; if (is_file($firefox)) { $pid = $unix->PIDOF($firefox); if ($pid > 5) { $arraySTOP[] = $firefox . ":[{$pid}]"; shell_exec("kill -9 {$pid}"); } } $xfce4 = "/usr/bin/xfce4-session"; if (is_file($xfce4)) { $pid = $unix->PIDOF($xfce4); if ($pid > 5) { $arraySTOP[] = $xfce4 . ":[{$pid}]"; shell_exec("kill -9 {$pid}"); } } $xfdesktop = "/usr/bin/xfdesktop"; if (is_file($xfdesktop)) { $pid = $unix->PIDOF($xfdesktop); if ($pid > 5) { $arraySTOP[] = $xfdesktop . ":[{$pid}]"; shell_exec("kill -9 {$pid}"); } } $intro = "Artica has detected that you have only {$users->CPU_NUMBER} CPU, so the Safe Process has been automatically enabled.\n"; if (count($arraySTOP) > 0) { return "{$intro}\nSafe Process: the following services/processes has been killed or removed\nin order to safe performances:\n" . @implode("\n", $arraySTOP) . "\nIf you want to disable the SafeProcess Features do the following command :\n# echo 1 >/etc/artica-postfix/settings/Daemons/DisableSafeProcesses\n---------------------------------------------\n"; } }
function PID_NUM() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/bandwidthd.pid"); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF("/usr/bandwidthd/bandwidthd"); }
function SQUID_PID() { $unix = new unix(); $squidbin = $unix->LOCATE_SQUID_BIN(); $pidfile = $unix->LOCATE_SQUID_PID(); $pid = $unix->get_pid_from_file($pidfile); if ($GLOBALS["VERBOSE"]) { echo "PID FILE: {$pidfile} - > {$pid}\n"; } if (!$unix->process_exists($pid)) { if ($GLOBALS["VERBOSE"]) { echo "PID: {$pid} - > NOT RUNNING !! -> PIDOF {$squidbin}\n"; } $pid = $unix->PIDOF($squidbin); if ($GLOBALS["VERBOSE"]) { echo "PIDOF: {$pid}\n"; } } else { return $pid; } if ($GLOBALS["VERBOSE"]) { if (!$unix->process_exists($pid)) { echo " **** ***** ***** ***** {$pid}] NOT RUNNING !! \n"; } } return $pid; }
function PID_NUM() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/pdns/pdns.pid"); if ($unix->process_exists($pid)) { return $pid; } $bin = $unix->find_program("pdns_server"); return $unix->PIDOF($bin); }
function kav4Proxy_status(){ if(!$GLOBALS["CLASS_USERS"]->KASPERSKY_WEB_APPLIANCE){ if(!$GLOBALS["CLASS_USERS"]->SQUID_INSTALLED){return null;} if(!$GLOBALS["CLASS_USERS"]->KAV4PROXY_INSTALLED){return null;} $SQUIDEnable=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("SQUIDEnable"); if($SQUIDEnable==null){$SQUIDEnable=1;} $enabled=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("kavicapserverEnabled"); if($SQUIDEnable==0){$enabled=0;} }else{ $enabled=1; } $master_pid=trim(@file_get_contents("/var/run/kav4proxy/kavicapserver.pid")); $l[]="[KAV4PROXY]"; $l[]="service_name=APP_KAV4PROXY"; $l[]="master_version=".GetVersionOf("kav4proxy"); $l[]="service_cmd=kav4proxy"; $l[]="service_disabled=$enabled"; $l[]="remove_cmd=--kav4Proxy-remove"; $l[]="explain=enable_kavproxy_text"; $l[]="family=squid"; $unix=new unix(); $licenseManager=$unix->PIDOF("/opt/kaspersky/kav4proxy/bin/kav4proxy-licensemanager"); if($unix->process_exists($licenseManager)){ if($unix->PROCCESS_TIME_MIN($licenseManager)>1){ events("Killing /opt/kaspersky/kav4proxy/bin/kav4proxy-licensemanager $licenseManager",__FUNCTION__,__LINE__); shell_exec("/bin/kill -9 $licenseManager >/dev/null 2>&1"); } } if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){$l[]="running=0\ninstalled=1";$l[]="";return implode("\n",$l);return;} $l[]="running=1"; $l[]=GetMemoriesOf($master_pid); $l[]=""; return implode("\n",$l);return; }
function PID_NUM() { $unix = new unix(); if (is_file('/etc/artica-postfix/exec.maillog.php.pid')) { $pid = $unix->get_pid_from_file('/etc/artica-postfix/exec.maillog.php.pid'); if ($unix->process_exists($pid)) { return $pid; } } $pid = $unix->PIDOF("/usr/sbin/postfix-logger"); if ($unix->process_exists($pid)) { return $pid; } return $unix->PIDOF_PATTERN("/usr/share/artica-postfix/exec.maillog.php"); }
function PID_NUM() { $unix = new unix(); return $unix->PIDOF($unix->find_program("bwm-ng"), true); }
function stop($aspid = false) { $unix = new unix(); $kill = $unix->find_program("kill"); 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 "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, Already task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); } $pid = GETPID(); if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, already stopped\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, stopping pid: {$pid}\n"; } unix_system_kill_force($pid); for ($i = 0; $i < 6; $i++) { $pid = GETPID(); if (!$unix->process_exists($pid)) { break; } if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, waiting pid: {$pid} {$i}/5\n"; } unix_system_kill_force($pid); sleep(1); } $tail = $unix->find_program("tail"); $pid = $unix->PIDOF("/bin/nginx-tail"); if ($unix->process_exists($pid)) { for ($i = 0; $i < 20; $i++) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: killing old process pid {$pid}\n"; } unix_system_kill_force($pid); usleep(800); $pid = $unix->PIDOF("/bin/access-tail"); if (!$unix->process_exists($pid)) { break; } unix_system_kill_force($pid); } } $pid = GETPID(); if (!$unix->process_exists($pid)) { events("exec.init-tail-nginx.phpp success to stop daemon..."); if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, success\n"; } } else { events("exec.init-tail-nginx.php failed to stop daemon..."); if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, failed\n"; } } }
function PID_NUM() { $unix = new unix(); $pid = $unix->get_pid_from_file("/var/run/influxdb.pid"); $Masterbin = "/opt/influxdb/influxd"; return $unix->PIDOF($Masterbin); }