以下為演示代碼,請根據實際情況修改代碼
function checkPhpScript($cronFiles){
@exec ( "ps aux|grep .php", $scripts );
if($cronFiles && $scripts){
checkRepeatScript($scripts);
foreach ($cronFiles as $key => $value) {
foreach ($scripts as $k => $v) {
if(strstr($v,$value)){
unset($cronFiles[$key]);
}
}
}
if(is_array($cronFiles) && count($cronFiles)>0){
return $cronFiles;
}
}
return false;
}
function checkRepeatScript($scripts){
$checkScripts = array();
$repeatScripts = array();
foreach ($scripts as $k => $v) {
if(strstr($v,'cron.php')){
continue;
}
else{
$b = strstr($v,'/usr/local/php5.5/bin/php');
if($b){
$key = md5($b);
if(isset($checkScripts[$key])){
$repeatScripts[] = $v;
}
else{
$checkScripts[$key] = 1;
}
}
}
}
if(count($repeatScripts)>0){
$insertAlert = true;
$aObj = new \model\alert;
$alert = $aObj->find(array(
'condition'=>array('status'=>array('$exists'=>true)),
'field'=>array(),
'sort'=>array('created'=>-1),
));
if(isset($alert[0])){
if(time()-$alert[0]['created']->sec<600){//如果10分鐘內剛報過警,就不查了
$insertAlert = false;
}
}
if($insertAlert){
$ip = localIPCore();
$aObj->create(array(
'description'=>'服務器:'. $ip .' 有重復進程',
'debug'=>$repeatScripts,
'created'=>new \MongoDate(),
'status'=>0
));
}
}
}
- 前言
- 阿里圖標庫使用
- LAMP環境安裝
- 數據庫
- MYSQL
- 安裝
- Mysql導出導入
- 修改最大連接數
- Mysql慢查尋
- 查看MYSQL占用空間
- 嚴格模式
- 數據庫模式
- mysql權限
- MongoDB
- Redis
- 服務器
- PHP5.4安裝
- svnmanager
- linux修改端口22
- 打包忽略文件
- 遠程復制文件
- 查看目錄大小
- zendloader
- Apache負載
- Memcache
- svn遠程同步
- 服務器參數調整
- 內存占滿
- PHP調用Java
- Apache重寫
- 禁用selinux
- SFTP 子系統申請已拒絕
- Gitlab
- 硬盤掛載
- gitlab修改密碼
- oneapm
- SVN安裝
- .gitlab-ci.yml
- Nginx重寫 html to php
- 添加到環境變量
- supervisor常駐任務
- .gitlab-ci.yml
- crontab.sh
- PEAR
- java jenkins
- Mongo
- 解決unix:///tmp/supervisor.sock no such file的問題
- 登錄日志
- tail -f
- git remote
- 開發需知
- Sublime開發工具
- 文檔生成工具
- PHP代碼注釋標準
- http網站自動跳轉到https
- PHP只保留錯誤提示。
- window刷新DNS
- 網站慢
- Centos安全
- 臨時代碼
- SVNHOOK
- mariadb
- git
- gitlab-runner
- Sublime3設置注釋
- Vue開發
- 安裝
- v-cloak
- 錯誤處理
- failed to connect 443
- JavaScriptURL請求亂碼
- 內容管理系統
- WordPress
- 支付相關
- 銀聯
- Angularjs
- 安裝環境
- 報錯處理
- centos7在upgrade的時候顯示:Delta RPMs disabled....詳見內容?
- yum-complete-transaction command not find
- hadowsocks
- vpn
- Laravel
- 安裝
- ngnix-config
- 使用私有git的composer
- Crontab防止多次執行
- JS
- mui storage
- RTMP