假设由于某种原因,你需要嗅探HTTP站点的流量(如HTTP请求与响应)。举个例子,你可能在测试一个web服务器的实验性功能,或者你在为某个web应用或RESTful服务排错,又或者你正在为PAC(proxy auto config)排错或寻找某个站点下载的恶意软件。不论什么原因,在这些情况下,进行HTTP流量嗅探对于系统管理、开发者、甚至最终用户来说都是很有帮助的。
set mailserver smtp.monit.ro port 587
set mail-format {
from: monit@monit.ro
subject: $SERVICE $EVENT at $DATE on $HOST
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
Yours sincerely,
Monit
}
set alert guletz@monit.ro
set idfile /var/monit/id
set eventqueue
basedir /var/monit
测试全局配置
现在“Global”部分就完成了。Monit配置文件看起来像这样:
# Global Section
# status webpage and acl's
set httpd port 1966 and
SSL ENABLE
PEMFILE /var/certs/monit.pem
allow monituser:romania
allow localhost
allow 192.168.0.0/16
allow myhost.mydomain.ro
# mail-server
set mailserver smtp.monit.ro port 587
# email-format
set mail-format {
from: monit@monit.ro
subject: $SERVICE $EVENT at $DATE on $HOST
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
Yours sincerely,
Monit
}
set alert guletz@monit.ro
# delay checks
set daemon 120
with start delay 240
set logfile syslog facility log_daemon
# idfile and mail queue path
set idfile /var/monit/id
set eventqueue
basedir /var/monit
monit: Cannot stat the SSL server PEM file '/var/certs/monit.pem' -- No such file or directory
/etc/monit/monitrc:10: Warning: hostname did not resolve 'smtp.monit.ro'
FROM node:slim
MAINTAINER Jianying Li
# instal basic tool
RUN apt-get update && apt-get install -y git ssh-client ca-certificates --no-install-recommends && rm -r /var/lib/apt/lists/*
# set time zone
RUN echo "Asia/Shanghai" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
# install hexo
RUN npm install hexo@3.0.0 -g
# set base dir
RUN mkdir /hexo
# set home dir
WORKDIR /hexo
EXPOSE 4000
CMD ["/bin/bash"]
定制自己的image请注意,现在最简洁的三个包内容为:
git,部署的时候用(如果不用git部署请去掉)。
ssh-client(ssh方式的git部署依赖)。
ca-certificates(https方式的git部署依赖)。
TIP: 在shell中或者lib中调用https方式通讯的时候如果报错
Problem with the SSL CA cert (path? access rights?)
可以通过安装包:ca-certificates 来解决问题,yum apt中都是如此。
构建时间大概十几分钟完成。
准备把实体机(host)上的文件挂载到docker中
安装Guest Additions, 因为要使用Shared Floader。
使用命令 sudo mount -t vboxsf [sharename] [dist]来挂载共享目录。
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
zenity --info --title "Information Box" --text "This should be information" --width=300 --height=200
创建 Yes/No 询问对话框
zenity --question --text "Do you want this?" --ok-label "Yeah" --cancel-label="Nope"
创建输入框并将输入值保存到变量中
a=$(zenity --entry --title "Entry box" --text "Please enter the value" --width=300 --height=200)
echo $a
输入后,值会保存在变量 $a 中。
这是一个获取用户姓名并显示的实际事例。
#!/bin/bash
#
# This script will ask for couple of parameters
# and then continue to work depending on entered values
#
# Giving the option to user
zenity --question --text "Do you want to continue?"
# Checking if user wants to proceed
[ $? -eq 0 ] || exit 1
# Letting user input some values
FIRSTNAME=$(zenity --entry --title "Entry box" --text "Please, enter your first name." --width=300 --height=150)
LASTNAME=$(zenity --entry --title "Entry box" --text "Please, enter your last name." --width=300 --height=150)
AGE=$(zenity --entry --title "Entry box" --text "Please, enter your age." --width=300 --height=150)
# Displaying entered values in information box
zenity --info --title "Information" --text "You are ${FIRSTNAME} ${LASTNAME} and you are ${AGE}(s) old." --width=300 --height=100
whiptail --menu "This is a menu. Choose an option:" 20 50 10 1 "first" 2 "second" 3 "third"
这是一个请求用户输入一个文件夹的路径并输出它的大小的 shell 脚本。
#!/bin/bash
#
#
# Since whiptail has to use stdout to display dialog, entered value will
# be stored in stderr. To switch them and get the value to stdout you must
# use 3>&1 1>&2 2>&3
FOLDER_PATH=$(whiptail --title "Get the size of folder"
--inputbox "Enter folder path:"
10 30
"/home"
3>&1 1>&2 2>&3)
if [ -d $FOLDER_PATH ]
then
size=$(du -hs "$FOLDER_PATH" | awk '{print $1}')
whiptail --title "Information"
--msgbox "Size of ${FOLDER_PATH} is ${size}"
10 40
elif [ -f $FOLDER_PATH ]
then
whiptail --title "Warning!!!"
--msgbox "The path you entered is a path to a file not a folder!"
10 40
else
whiptail --title "Error!!!"
--msgbox "Path you entered is not recognized. Please try again"
10 40
fi
大家好,今天我们来了解一下 Windows 操作系统中的 Docker 以及在其中安装 Docker Windows 客户端的知识。Docker 引擎使用 Linux 特有的内核特性,因此不能通过 Windows 内核运行,所以,(在 Windows 上)Docker 引擎创建了一个小的虚拟系统运行 Linux 并利用它的资源和内核。这样,Windows Docker 客户端就可以用这个虚拟的 Docker 引擎来构建、运行以及管理 Docker 容器。有个叫 Boot2Docker 的团队开发了一个同名的应用程序,它创建了一个虚拟机来运行基于Tiny Core Linux特制的小型 Linux,来在 Windows 上运行 Docker 容器。它完全运行在内存中,需要大约 27M 内存并能在 5秒 (因人而异) 内启动。因此,在用于 Windows 的 Docker 引擎被开发出来之前,我们在 Windows 机器里只能运行 Linux 容器。
Ip:
1092065 total packets received
0 forwarded
0 incoming packets discarded
1091681 incoming packets delivered
798913 requests sent out
895 dropped because of missing route
759 reassemblies required
375 packets reassembled ok
Icmp:
17 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
timeout in transit: 8
echo replies: 9
1747 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 1730
echo request: 17
IcmpMsg:
InType0: 9
InType11: 8
OutType3: 1730
OutType8: 17
Tcp:
4822 active connections openings
1129 passive connection openings
457 failed connection attempts
165 connection resets received
7 connections established
1062519 segments received
771394 segments send out
7158 segments retransmited
6 bad segments received.
2578 resets sent
Udp:
20846 packets received
1730 packets to unknown port received.
0 packet receive errors
19242 packets sent
UdpLite:
TcpExt:
71 invalid SYN cookies received
8 resets received for embryonic SYN_RECV sockets
142 packets pruned from receive queue because of socket buffer overrun
2109 TCP sockets finished time wait in fast timer
84 packets rejects in established connections because of timestamp
19454 delayed acks sent
6 delayed acks further delayed because of locked socket
Quick ack mode was activated 7306 times
1 packets directly queued to recvmsg prequeue.
1 bytes directly received in process context from prequeue
823921 packet headers predicted
24412 acknowledgments not containing data payload received
10150 predicted acknowledgments
242 times recovered from packet loss by selective acknowledgements
33 congestion windows recovered without slow start by DSACK
335 congestion windows recovered without slow start after partial ack
336 TCP data loss events
TCPLostRetransmit: 35
1 timeouts after reno fast retransmit
156 timeouts after SACK recovery
116 timeouts in loss state
461 fast retransmits
5 forward retransmits
608 retransmits in slow start
2073 other TCP timeouts
62 SACK retransmits failed
43074 packets collapsed in receive queue due to low socket buffer
8499 DSACKs sent for old packets
101 DSACKs sent for out of order packets
308 DSACKs received
9 DSACKs for out of order packets received
427 connections reset due to unexpected data
122 connections reset due to early user close
28 connections aborted due to timeout
TCPDSACKIgnoredOld: 3
TCPDSACKIgnoredNoUndo: 60
TCPSpuriousRTOs: 4
TCPSackShifted: 282
TCPSackMerged: 740
TCPSackShiftFallback: 1017
IpExt:
InMcastPkts: 47
OutMcastPkts: 51
InBcastPkts: 1
InOctets: 1341508973
OutOctets: 72525352
InMcastOctets: 8649
OutMcastOctets: 7519
InBcastOctets: 328
[root@localhost ~]# cat text_file.txt
This line does not contain H e l l o word
This lilne contains Hello
This also containd Hello
This one no due to HELLO all capital
Hello bash world!
而我们需要找到其中某些带有“Hello”的行,Linux中有个grep命令可以完成该工作:
[root@localhost ~]# grep Hello text_file.txt
This lilne contains Hello
This also containd Hello
Hello bash world!
[root@localhost ~]#
[root@localhost ~]# cat note.sh
#!/bin/bash
echo "Phone number ?"
read phone
echo "You have entered $phone as a phone number"
[root@localhost ~]# ./note.sh
Phone number ?
123456
You have entered 123456 as a phone number
[root@localhost ~]#
[root@localhost ~]# cat note.sh
#!/bin/bash
while true
do
read -p "Phone number: " phone
now=`date "+%Y.%m.%d %H:%M:%S"`
read -p "Name: " name
read -p "Issue: " issue
echo "$now/$phone/$name/$issue">>data.txt
done
我已经交换了read phone和now=date行的位置。这是因为我想要在输入电话号码后再获得时间。如果我把它放在循环的首行,那么循环一次后,变量 now 就会在数据存储到文件中后马上获得时间。而这并不好,因为下一次呼叫可能在20分钟后,甚至更晚。
[root@localhost ~]# ./note.sh
Phone number: 123
Name: Jim
Issue: Script still not works.
Phone number: 777
Name: Daniel
Issue: I broke my monitor
Phone number: ^C
[root@localhost ~]# cat data.txt
2015.04.23 21:38:56/123/Jim/Script hanging.
2015.04.23 21:43:50/321/Susane/Mouse was stolen
2015.04.23 21:47:55/123/Jim/Script still not works.
2015.04.23 21:48:16/777/Daniel/I broke my monitor
[root@localhost ~]#
[root@localhost ~]# cat data.txt
2015.04.23 21:38:56/123/Jim/Script hanging.
2015.04.23 21:43:50/321/Susane/Mouse was stolen
2015.04.23 21:47:55/123/Jim/Script still not works.
2015.04.23 21:48:16/777/Daniel/I broke my monitor
2015.04.23 22:02:14/123/Jimmy/New script also not working!!!
[root@localhost ~]#