2014年9月30日
有时候不知道前路在何方,有时候不知道是否坚持错了方向,到现在我认为不论别人觉得是对还是错,只要自己觉得没有问题,那就勇敢的去做去拼,要无畏、无惧!不论成败,它都是你的一个经验,你失去的成本还可以从其他地方赚回来,但你失去的机会也许永远无法再得到。风险越大,回报越大!
有时候不知道前路在何方,有时候不知道是否坚持错了方向,到现在我认为不论别人觉得是对还是错,只要自己觉得没有问题,那就勇敢的去做去拼,要无畏、无惧!不论成败,它都是你的一个经验,你失去的成本还可以从其他地方赚回来,但你失去的机会也许永远无法再得到。风险越大,回报越大!
DirectAdmin组件ZendGuardLoader,明明安装了探针却显示红叉叉,是因为一般是根据zend_loader.enable判断的,DA没加这些在php.ini,我们手动加上就好了
编辑php.ini,搜索:zend_extension,在底下加上
zend_loader.enable=1 zend_loader.disable_licensing=0 zend_loader.obfuscation_level_support=3 zend_loader.license_path=
然后 service httpd restart 重启下apache使修改生效
至于DirectAdmin PHP.INI的位置可以参考:http://www.cnweed.com/2743.html
[Sun Sep 21 17:37:10 2014] [emerg] (28)No space left on device: Couldn't create accept lock (/var/log/httpd/accept.lock.8411) (5)
下午收到监控邮件有台DirectAdmin服务器Apache服务无法启动,检查错误日记后,发现如上错误。首先df -h检查硬盘是否饱和,然后ipcs -s检查ipc,发现是ipc不足。如下所示
# ipcs -s ------ Semaphore Arrays -------- key semid owner perms nsems 0x00000000 19234816 apache 600 1 0x00000000 19267585 apache 600 1 0x00000000 19300354 apache 600 1 0x00000000 19398659 apache 600 1 0x00000000 19431428 apache 600 1 0x00000000 19464197 apache 600 1 0x00000000 19562502 apache 600 1 ………………
执行如下命令清除然后重启Apache即可
ipcs -s | grep apache | perl -lane 'print `ipcrm sem $F[1]`' service httpd restart
引起这个问题的原因可能是apache没有被正确的关闭。写了个简单的shell可以加入crontab定期执行
#!/bin/bash rm -rf /var/log/weed/ipcs.log ipcs -s >> /var/log/weed/ipcs.log ipcslist=`grep -c "" /var/log/weed/ipcs.log` if [ "$ipcslist" -ge "20" ]; then ipcs -s | perl -ane '/^0x00000000/ && `ipcrm -s $F[1]`' echo $(date) "Ipc crowded, clean up" >> /var/log/weed/ipcs_clean.log fi
#! /bin/bash #==================================================================== # sys-mon.sh # # Copyright (c) 2011, WangYan <webmaster@wangyan.org> # All rights reserved. # Distributed under the GNU General Public License, version 3.0. # # Monitor system mem and load, if too high, restart some service. # # See: https://wangyan.org/blog/sys-mon-shell-script.html # # V 0.5, Date: 2011-12-08 #==================================================================== # Need to monitor the service name # Must be in /etc/init.d folder exists NAME_LIST="httpd nginx mysql" # Single process to allow the maximum CPU (%) PID_CPU_MAX="25" # The maximum allowed memory (%) PID_MEM_SUM_MAX="95" # The maximum allowed system load SYS_LOAD_MAX="6" # Log path settings LOG_PATH="/var/log/sys-mon.log" # Date time format setting DATA_TIME=$(date +"%y-%m-%d %H:%M:%S") # Your email address EMAIL="webmaster@example.com" # Your website url MY_URL="http://106.187.38.210/p.php" #==================================================================== for NAME in $NAME_LIST do PID_CPU_SUM="0";PID_MEM_SUM="0" PID_LIST=`ps aux | grep $NAME | grep -v root` IFS_TMP="$IFS";IFS=$'\n' for PID in $PID_LIST do PID_NUM=`echo $PID | awk '{print $2}'` PID_CPU=`echo $PID | awk '{print $3}'` PID_MEM=`echo $PID | awk '{print $4}'` # echo "$NAME: PID_NUM($PID_NUM) PID_CPU($PID_CPU) PID_MEM($PID_MEM)" PID_CPU_SUM=`echo "$PID_CPU_SUM + $PID_CPU" | bc` PID_MEM_SUM=`echo "$PID_MEM_SUM + $PID_MEM" | bc` if [ `echo "$PID_CPU >= $PID_CPU_MAX" | bc` -eq 1 ];then if [[ "$NAME" = "php-fpm" || "$NAME" = "httpd" ]];then sleep 5 if [ `echo "$PID_CPU >= $PID_CPU_MAX" | bc` -eq 1 ];then echo "${DATA_TIME}: kill ${NAME}($PID_NUM) successful (CPU:$PID_CPU)" | tee -a $LOG_PATH kill $PID_NUM fi else echo "${DATA_TIME}: [WARNING!] ${NAME}($PID_NUM) cpu usage is too high! (CPU:$PID_CPU)" | tee -a $LOG_PATH fi fi done IFS="$IFS_TMP" SYS_LOAD=`uptime | awk '{print $(NF-2)}' | sed 's/,//'` SYS_MON="CPU:$PID_CPU_SUM MEM:$PID_MEM_SUM LOAD:$SYS_LOAD" # echo -e "$NAME: $SYS_MON\n" SYS_LOAD_TOO_HIGH=`awk 'BEGIN{print('$SYS_LOAD'>'$SYS_LOAD_MAX')}'` PID_MEM_SUM_TOO_HIGH=`awk 'BEGIN{print('$PID_MEM_SUM'>'$PID_MEM_SUM_MAX')}'` if [[ "$SYS_LOAD_TOO_HIGH" = "1" || "$PID_MEM_SUM_TOO_HIGH" = "1" ]];then /etc/init.d/$NAME stop sleep 5 for ((i=1;i<4;i++)) do if [ `pgrep $NAME | wc -l` = "0" ];then echo "$DATA_TIME: Stop $NAME successful! ($SYS_MON)" | tee -a $LOG_PATH break else echo "${DATA_TIME}: [WARNING!] Stop $NAME failed[$i]! ($SYS_MON)" | tee -a $LOG_PATH pkill $NAME && killall $NAME fi done /etc/init.d/$NAME start sleep 5 for ((ii=1;ii<4;ii++)) do if [ `pgrep $NAME | wc -l` != "0" ];then echo "$DATA_TIME: Start $NAME successful!" | tee -a $LOG_PATH break else echo "${DATA_TIME}: [WARNING!] Start $NAME failed[$ii]! ($SYS_MON)" | tee -a $LOG_PATH /etc/init.d/$NAME start sleep 5 fi done if [ `pgrep $NAME | wc -l` != "0" ];then echo "${DATA_TIME}: [ERROR!] Start $NAME failed! ($SYS_MON)" | mail -s "Start $NAME failed" $EMAIL fi fi done STATUS_CODE=`curl -o /dev/null -s -w %{http_code} $MY_URL` #echo -e "STATUS CODE: $STATUS_CODE\n" if [ "$STATUS_CODE" != "200" ];then sleep 3 STATUS_CODE=`curl -o /dev/null -s -w %{http_code} $MY_URL` if [ "$STATUS_CODE" != "200" ];then echo "${DATA_TIME}: [WARNING!] Website Downtime! ($SYS_MON)" | tee -a $LOG_PATH echo "${DATA_TIME}: [WARNING!] Website Downtime! ($SYS_MON)" | mail -s "Start $NAME failed" $EMAIL fi fi
Named is not reloading correctly when I add a domain
On some systems, the named boot script provided with the bind rpms don't seem to reliably reload the named program. You can obtain a new named boot script by running the following:
RedHat:
cd /etc/init.d mv named named.backup wget -O named http://www.directadmin.com/named chmod 755 named /sbin/chkconfig named reset
This boot script uses a more direct method of reloading named.
其他操作系统请访问来源:http://help.directadmin.com/item.php?id=40
一、登入 DirectAdmin 管理员,查找域知否已经存在
二、查看/etc/named.conf文件是否已经存在该域名
来源:http://help.directadmin.com/item.php?id=28
#!/usr/bin/env python #-*- coding: utf-8 -*- #============================================================================= # FileName: # Desc: # Author: 苦咖啡 # Email: voilet@qq.com # HomePage: http://blog.kukafei520.net # Version: 0.0.1 # History: #============================================================================= import os import sys import re import smtplib #设定邮件 fromaddr = "smtp.qq.com" toaddrs = ["voilet@qq.com"] username = "voilet" password = "xxxxxx" #设置白名单 pass_file = ["api_ucenter.php"] #定义发送邮件函数 def sendmail(toaddrs,sub,content): '发送邮件模块' # Add the From: and To: headers at the start! msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, ", ".join(toaddrs), sub)) msg += content server = smtplib.SMTP('mail.funshion.com', 25,) server.login(username, password) server.sendmail(fromaddr, toaddrs, msg) server.quit() #设置搜索特征码 rulelist = [ '(\$_(GET|POST|REQUEST)\[.{0,15}\]\(\$_(GET|POST|REQUEST)\[.{0,15}\]\))', '(base64_decode\([\'"][\w\+/=]{200,}[\'"]\))', 'eval\(base64_decode\(', '(eval\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))', '(assert\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))', '(\$[\w_]{0,15}\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))', '(wscript\.shell)', '(gethostbyname\()', '(cmd\.exe)', '(shell\.application)', '(documents\s+and\s+settings)', '(system32)', '(serv-u)', '(提权)', '(phpspy)', '(后门)', '(webshell)', '(Program\s+Files)', 'www.phpdp.com', 'phpdp', 'PHP神盾', 'decryption', 'Ca3tie1', 'GIF89a', 'IKFBILUvM0VCJD\/APDolOjtW0tgeKAwA', '\'e\'\.\'v\'\.\'a\'\.\'l\'', ] def Scan(path): for root,dirs,files in os.walk(path): for filespath in files: isover = False if '.' in filespath: ext = filespath[(filespath.rindex('.')+1):] if ext=='php' and filespath not in pass_file: file= open(os.path.join(root,filespath)) filestr = file.read() file.close() for rule in rulelist: result = re.compile(rule).findall(filestr) if result: print '文件:'+os.path.join(root,filespath) print '恶意代码:'+str(result[0]) print '\n\n' sendmail(toaddrs,"增值发现恶意代码",'文件:'+os.path.join(root,filespath)+"\n" + '恶意代码:'+str(result[0])) break try: if os.path.lexists("/home/web_root/"): print('\n\n开始扫描:'+ "/home/web_root/") print(' 可疑文件 ') print('########################################') Scan("/home/web_root/") print('提示:扫描完成--~') else: print '提示:指定的扫描目录不存在--- ' except IndexError: print "请指定扫描文件目录"
来自:http://blog.kukafei520.net/html/2013/811.html
一个简单的系统监控脚本,有需要的朋友可以参考下。
#!/bin/bash time=`date +"%Y-%m-%d %H:%M:%S"` d=`date +%m%d` N=`ps -ef | grep httpd | grep -v grep | wc -l` Q=`ps -ef | grep java | grep -v grep | wc -l` [ -d /root/check_log/ ] || mkdir /root/check_log IP=`ifconfig eth0 | sed -n '2'p | awk '{print $2}' | awk -F':' '{print $2}'` M=`uptime | awk '{print $8,$9,$10,$11,$12}'` O=`ifconfig eth0 | sed -n '8'p | awk '{print $3,$4}'` P=`ifconfig eth0 | sed -n '8'p | awk '{print $7,$8}'` R=`ifconfig eth1 | sed -n '8'p | awk '{print $3,$4}'` S=`ifconfig eth1 | sed -n '8'p | awk '{print $7,$8}'` A=`top -bn1 | sed -n '2'p | awk '{print $2}'` B=`top -bn1 | sed -n '2'p | awk '{print $10}'` echo ****************************$IP**************************** >> /root/check_log/$d.log echo "系统当前时间:" >> /root/check_log/$d.log echo $time >> /root/check_log/$d.log echo "---------------------check system load------------------" >> /root/check_log/$d.log echo "系统当前负载:" >> /root/check_log/$d.log echo $M >> /root/check_log/$d.log echo "---------------------check 总进程数---------------------" >> /root/check_log/$d.log echo "系统当前总进程数:" >> /root/check_log/$d.log echo $A >> /root/check_log/$d.log echo "系统当前僵死进程数:" >> /root/check_log/$d.log echo $B >> /root/check_log/$d.log echo "---------------------check 应用进程数--------------------" >> /root/check_log/$d.log echo "当前apache进程数:" >> /root/check_log/$d.log echo $N >> /root/check_log/$d.log echo "当前java进程数" >> /root/check_log/$d.log echo $Q >> /root/check_log/$d.log echo "---------------------check Tcp连接状态-------------------" >> /root/check_log/$d.log netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a,S[a]}' >> /root/check_log/$d.log echo "---------------------check 网卡流量-----------------------" >> /root/check_log/$d.log echo "当前eth0网卡流量:" >> /root/check_log/$d.log echo "接收总流量:$O" >> /root/check_log/$d.log echo "发送总流量:$P" >> /root/check_log/$d.log echo "当前eth1网卡流量:" >> /root/check_log/$d.log echo "接收总流量:$R" >> /root/check_log/$d.log echo "发送总流量:$S" >> /root/check_log/$d.log echo "-----------------------------check cpu load------------------------------" >> /root/check_log/$d.log echo "系统当前cpu负载:" >> /root/check_log/$d.log sar -u 1 10 | grep -v Linux | grep -v ^$ >> /root/check_log/$d.log echo "-----------------------------check mem load------------------------------" >> /root/check_log/$d.log echo "系统当前内存信息:" >> /root/check_log/$d.log cat /proc/meminfo >> /root/check_log/$d.log echo "-----------------------------check 磁盘空间------------------------------" >> /root/check_log/$d.log echo "系统当前磁盘容量:" >> /root/check_log/$d.log df -h >> /root/check_log/$d.log echo "-----------------------------check io load-------------------------------" >> /root/check_log/$d.log echo "系统当前io磁盘负载:" >> /root/check_log/$d.log iostat 1 10 | grep -v ^$ | grep -v Linux | grep -v dm | grep -v hdc >> /root/check_log/$d.log find /root/check_log/ -mtime +6 |xargs rm -f
来自:http://www.jbxue.com/article/4472.html
最近发现有台DA机器的Apache总是自动重启,每次大概1-3分钟,检查apache日记、tcp和80端口连接后发现是挂QQ的程序导致的,接下来扫描用户php文件就好了
screen -S scan find /home/* -type f -name "*.php" |xargs grep "pt.3g.qq.com" > scan.txt
现在挂QQ程序一般是用手机网页QQ,关键词是 pt.3g.qq.com ,扫描完成后会保存在 scan.txt 文件中