Skip to main content

Posts

Showing posts from 2021

Linux/Process fork monitoring

ps_moniter.sh  #!/bin/bash . /etc/profile let LIMIT_PROCESS=400 let LIMIT_BIG_PROCESS=40 ALL_PROCESS_NUM=`ps x |wc -l` if [ ${ALL_PROCESS_NUM} -gt ${LIMIT_PROCESS} ]; then   echo ${ALL_PROCESS_NUM} fi BIG_PROCESS=`ps x -o cmd |sort  |uniq -c |sort -n |tail -n 10` BIG_PROC_SUM=`echo "${BIG_PROCESS}" |awk ' { SUM=SUM+$1 } END { print SUM } '` if [ ${BIG_PROC_SUM} -gt ${LIMIT_BIG_PROCESS} ]; then   MESSAGE="Process Report [Big Process Larger than ${LIMIT_BIG_PROCESS}] ${BIG_PROCESS}"   echo "$MESSAGE" fi crontab */5 * * * * cd /root/bin && ./ps_moniter.sh &>/dev/null

uri modificatin on http response

In haproxy : cannot. In nginx : possible. Backend Host: 1.2.3.4 Frontend Host: 2.2.2.2         location ^~ /its/         {             proxy_buffering   off;             rewrite           /its/(.*) /$1 break;             proxy_pass        http://1.2.3.4/;             proxy_redirect    default;             sub_filter_once off;             sub_filter ' href="/' ' href="/its/';             sub_filter ' src="/' ' src="/its/';             sub_filter ' src="http://1.2.3.4/' ' src="/its/';             sub_filter ' action="/' ' action="/its/';         } ex1. 2.2.2.2/its --> (2.2.2.2 connect to 1.2.3.4 ) 1.2.3.4/ 2.2.2.2/its/xxx <-- (2.2.2.2 response by 1.2.3.4 ) 1.2.3.4/xxx ex2. 2.2.2.2/its/aaa --> (2.2.2.2 connect to 1.2.3.4 ) 1.2.3.4/aaa 2.2.2.2/its/xxx <-- (2.2.2.2 response by 1.2.3.4 ) 1.2.3.4/xxx

rsyslog file log to remote syslog

 1. rsyslog    [file-A]     <--->    [remote rsyslog] 1) Edit conf file (The filename is your choice.)   @: udp   @@: tcp /etc/rsyslog.d/01-testlog.conf $ModLoad imfile # Default Apache Access Log $InputFileName /var/log/haproxy.log #$InputFileName /var/log/httpd/access_log #$InputFileTag httpd-access-default: #$InputFileStateFile stat-httpd-access #$InputFileSeverity info $InputFileFacility local4 $InputRunFileMonitor $InputFilePollInterval 10 local4.* @127.0.0.1:514 2) ignore local4 from /var/log/message and /var/log/syslog   edit /etc/rsyslog.conf Before: *.*;auth,authpriv.none    -/var/log/syslog After: *.*;!(local4.*);auth,authpriv.none    -/var/log/syslog Before: *.=debug;\   auth,authpriv.none;\   news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\   auth,authpriv.none;\   cron,daemon.none;\   mail,news.none    -/var/log/messages  After: *.=debug;\   auth,authpriv.none;\   news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\   auth,authpriv.none;\