IT 經歷備忘錄
code-test
2016年9月7日 星期三
2015年10月2日 星期五
使用命令方式新增 node 伺服器
使用命令方式新增 node 伺服器
Adding too much f5 nodes to ltm with one liner
#netscaler.txt
G01 10.1.1.1
P01 10.1.1.2
P02 10.1.1.3
P03 10.1.1.4
F01 10.1.1.5
F02 10.1.1.6
F03 10.1.1.7
F04 10.1.1.8
F05 10.1.1.9
F06 10.1.1.10
F07 10.1.1.11
F08 10.1.1.12
F09 10.1.1.13
etc 2000 lines.
cat netscaler.txt | while read line; do INF=(echo $line); tmsh create /ltm node ${INF[1]} address ${INF[2]} monitor icmp ; done
取自國外網友
Adding too much f5 nodes to ltm with one liner
#netscaler.txt
G01 10.1.1.1
P01 10.1.1.2
P02 10.1.1.3
P03 10.1.1.4
F01 10.1.1.5
F02 10.1.1.6
F03 10.1.1.7
F04 10.1.1.8
F05 10.1.1.9
F06 10.1.1.10
F07 10.1.1.11
F08 10.1.1.12
F09 10.1.1.13
etc 2000 lines.
cat netscaler.txt | while read line; do INF=(echo $line); tmsh create /ltm node ${INF[1]} address ${INF[2]} monitor icmp ; done
取自國外網友
2015年8月29日 星期六
編輯Trunkey Server tomcat
修改index.jsp
vi /var/lib/tomcat6/webapps/ROOT/
<body bgcolor="pink" >
<body bgcolor="#cccccc">
<body bgcolor="orange">
修改背景顏色
<body bgcolor="pink" >
<h1>TurnKey Server 1 Tomcat</h1>
字體加大
<body bgcolor="pink" >
<h1><font size="7">TurnKey Server-01 Tomcat</font></h1>
<input type="button" style="background-color:#FFF0D4" value="這是背景顏色為 #FFF0D4 的按鈕"><br>
<input type="button" style="background-color:#FFFF78" value="這是背景顏色為 #FFFF78 的按鈕"><br>
<input type="button" style="background-color:#FFD4D4" value="這是背景顏色為 #FFD4D4 的按鈕"><br>
<input type="button" style="background-color:#C9FFC9" value="這是背景顏色為 #C9FFC9 的按鈕"><br>
<input type="button" style="background-color:#C2C2FF" value="這是背景顏色為 #C2C2FF 的按鈕">
<input type="button" style="background-color:#FFFF78" value="這是背景顏色為 #FFFF78 的按鈕"><br>
<input type="button" style="background-color:#FFD4D4" value="這是背景顏色為 #FFD4D4 的按鈕"><br>
<input type="button" style="background-color:#C9FFC9" value="這是背景顏色為 #C9FFC9 的按鈕"><br>
<input type="button" style="background-color:#C2C2FF" value="這是背景顏色為 #C2C2FF 的按鈕">
範例效果
#!/bin/bash
# author oscarwu
# date 2015-08-30
# description 備份設定 檢查
# != 不等於
echo "check crontab job "
if [[ `grep "backup_config.sh" /etc/crontab` = "" ]];then
echo "00 5 * * * /sbin/backup_config.sh" >> /etc/crontab
echo -e "\n\e[1;36m check add script ... OK! \e[0m"
else
echo -e "\n\e[1;36m no add crontab backup_config.sh root ... OK! \e[0m"
fi
2015年8月25日 星期二
shell script 檢查目錄,沒有目錄並建立
#!/bin/sh
#shell判斷檔,目錄是否存在或者具有許可權
Path="/var/log/httpd/"
File="/var/log/httpd/access.log"
#這裡的-x 參數判斷$Path是否存在並且是否具有可執行許可權
if [ ! -x "$Path"]; then
mkdir "$Path"
fi
#這裡的-d 參數判斷$Path是否存在
if [ ! -d "$Path"]; then
mkdir "$Path"
fi
#這裡的-f參數判斷$File是否存在
if [ ! -f "$File" ]; then
touch "$File"
echo "檢查資料檔案不存在已建立"
fi
#其他參數還有-n,-n是判斷一個變數是否是否有值
if [ ! -n "$Var" ]; then
echo "$Var is empty"
exit 0
fi
#兩個變數判斷是否相等
if [ "$var1" = "$var2" ]; then
echo '$var1 eq $var2'
else
echo '$var1 not eq $var2'
fi
echo "程式繼續...."
#shell判斷檔,目錄是否存在或者具有許可權
Path="/var/log/httpd/"
File="/var/log/httpd/access.log"
#這裡的-x 參數判斷$Path是否存在並且是否具有可執行許可權
if [ ! -x "$Path"]; then
mkdir "$Path"
fi
#這裡的-d 參數判斷$Path是否存在
if [ ! -d "$Path"]; then
mkdir "$Path"
fi
#這裡的-f參數判斷$File是否存在
if [ ! -f "$File" ]; then
touch "$File"
echo "檢查資料檔案不存在已建立"
fi
#其他參數還有-n,-n是判斷一個變數是否是否有值
if [ ! -n "$Var" ]; then
echo "$Var is empty"
exit 0
fi
#兩個變數判斷是否相等
if [ "$var1" = "$var2" ]; then
echo '$var1 eq $var2'
else
echo '$var1 not eq $var2'
fi
echo "程式繼續...."
/etc/crontab 內容
10 0 * * * root /usr/sbin/ntpdate time.stdtime.gov.tw; /usr/sbin/hwclock -w
40 5 * * * root yum -y update && yum clean packages
2015年5月3日 星期日
Juniper SRX reinstall or update
使用Juniper junos 作業系統要更新版本有幾種方試
1.將Juniper SRX 開機當看到下列文字時按Space
loading /boot/defaults/loader.conf
2014年12月1日 星期一
big-ip F5 irule
怕健忘 紀錄irule
LC 常用
when CLIENT_ACCEPTED {
if { [class match [IP::client_addr] equals "Server1"]} {
snatpool snat_proxy1
pool GW_ISP1_Pool
} elseif {[class match [IP::client_addr] equals "Server2"]} {
snatpool snat_proxy2
pool GW_ISP2_Pool
}else {
snatpool Default
pool gateway_pool
}
}
when CLIENT_ACCEPTED {
switch [IP::client_addr] {
"10.10.10.10" { snat 192.169.42.10 }
"10.10.10.11" { snat 192.168.42.11 }
"10.10.10.12" { snat 192.168.42.12 }
"10.10.10.13" { snat 192.168.42.13 }
default { snat automap }
}
}
when SERVER_CONNECTED {
log local0. "client [IP::client_addr]:[TCP::client_port] snat [IP::local_addr]:[TCP::local_port] server [IP::server_addr]:[TCP::server_port]"
}
}
when CLIENTED_ACCEPTED {
switch [IP::client_addr] {
"10.10.10.10" {
log local0. "Snatting 10.10.10.10 to 192.168.42.10"
snat 192.169.42.10
}
"10.10.10.11" {
log local0. "Snatting 10.10.10.11 to 192.168.42.11"
snat 192.168.42.11
}
"10.10.10.12" {
log local0. "Snatting 10.10.10.12 to 192.168.42.12"
snat 192.168.42.12
}
"10.10.10.13" {
log local0. "Snatting 10.10.10.13 to 192.168.42.13"
snat 192.168.42.13
}
default {
log local0. "Snatting [IP::client_addr] to automap"
snat automap
}
}
}
session persistence in irule
when HTTP_REQUEST {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist uie [HTTP::cookie "JSESSIONID"] 1800
} else {
set jsess [findstr [HTTP::uri] "JSESSIONID" 11 ";"]
if { $jsess != "" } {
persist uie $jsess 1800
}
}
}
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist add uie [HTTP::cookie "JSESSIONID"] 1800
}
}
when HTTP_REQUEST {
# Check if there is a JSESSIONID cookie
if {[HTTP::cookie "JSESSIONID"] ne ""}{
# Persist off of the cookie value with a timeout of 2 hours (7200 seconds)
persist uie [string tolower [HTTP::cookie "JSESSIONID"]] 7200
# Log that we're using the cookie value for persistence and the persistence key if it exists.
log local0. "[IP::client_addr]:[TCP::client_port]: Request to [HTTP::uri] on server [LB::server] with cookie: [HTTP::cookie value JSESSIONID]"
} else {
# Parse the jsessionid from the path
set jsess [findstr [string tolower [HTTP::path]] "jsessionid=" 11]
# Use the jsessionid from the path for persisting with a timeout of 2 hours (7200 seconds)
if { $jsess != "" } {
persist uie $jsess 7200
# Log that we're using the path jessionid for persistence and the persistence key if it exists.
log local0. "[IP::client_addr]:[TCP::client_port]: Request to [HTTP::uri] on server [LB::server] used persistence record from path: [persist lookup uie $jsess]"
}
}
}
when HTTP_RESPONSE {
# Check if there is a jsessionid cookie in the response
if {[HTTP::cookie "JSESSIONID"] ne ""} {
# Persist off of the cookie value with a timeout of 2 hours (7200 seconds)
persist add uie [string tolower [HTTP::cookie "JSESSIONID"]] 7200
# Log Response
log local0. "[IP::client_addr]:[TCP::client_port]: Request to server [LB::server] with cookie: [HTTP::cookie value JSESSIONID]. Added persistence record from cookie: [persist lookup uie [string tolower [HTTP::cookie "JSESSIONID"]]]"
}
}
when LB_SELECTED {
log "From [IP::client_addr] to physical server [LB::server] the cookie JSESSIONID is [HTTP::cookie "JSESSIONID"] URI JESSIONID is [findstr [string tolower [HTTP::path]] "jsessionid=" 11] "
}
訂閱:
文章 (Atom)