Shell 中的花括号的特殊用法

四种模式匹配替换结构:

${var%pattern},${var%%pattern},${var#pattern},${var##pattern}

第一种模式:${variable%pattern},这种模式时,shell在variable中查找,看它是否一给的模式pattern结尾,如果是,就从命令行把variable中的内容去掉右边最短的匹配模式
第二种模式: ${variable%%pattern},这种模式时,shell在variable中查找,看它是否一给的模式pattern结尾,如果是,就从命令行把variable中的内容去掉右边最长的匹配模式
第三种模式:${variable#pattern} 这种模式时,shell在variable中查找,看它是否一给的模式pattern开始,如果是,就从命令行把variable中的内容去掉左边最短的匹配模式
第四种模式: ${variable##pattern} 这种模式时,shell在variable中查找,看它是否一给的模式pattern结尾,如果是,就从命令行把variable中的内容去掉右边最长的匹配模式
这四种模式中都不会改变variable的值,其中,只有在pattern中使用了*匹配符号时,%和%%,#和##才有区别。结构中的pattern支持通配符,*表示零个或多个任意字符,?表示零个或一个任意字符,[…]表示匹配中括号里面的字符,[!…]表示不匹配中括号里面的字符

bogon:/home/bash # var=testcase
bogon:/home/bash # echo $var
testcase
bogon:/home/bash # echo ${var%s*e}
testca
bogon:/home/bash # echo $var
testcase
bogon:/home/bash # echo ${var%%s*e}
te
bogon:/home/bash # echo ${var#?e}
stcase
bogon:/home/bash # echo ${var##?e}
stcase
bogon:/home/bash # echo ${var##*e}

bogon:/home/bash # echo ${var##*s}
e
bogon:/home/bash # echo ${var##test}
case

 

Smokeping 常用操作

在centos上安装了smokeping 以后,我们可能会经常遇到各种问题

  1. 对target进行修改,修改完以后,我们需要重启smokeping service ,一般情况下是不需要重启httpd,因为smokeping 的主程序会查看config 的timestamp,如果有变化就会重新读取config 配置文件,但是如果你把target 通过include 的方式包含在config当中,那么即使你修改了target文件,但是config 文件的timestamp 仍然不变。经过测试,解决办法有两个: 要么稍微修改一下config 文件,添加或者删除一些无关紧要的文字,要不然就在重启完smokeping以后再重启一下httpd服务
  2. 还有一个经常见的问题就是slave 的图没有数据,这个一般是权限的问题。因为slave 端的数据,是slave 端通过http call,写入master 端的,而master 端完成此项任务的是httpd,因此httpd 要对 data 文件夹下面的target 的文件夹要有写入权限。实现这个目标,可以有多种实现的办法,一种办法是利用getfacl 和 setfacl 来设置apache 对这些目录单独的权限,另外一种办法是把这些文件的group 设置为apache,并且给apache 写入的权限 chmod g+w *
  3. 查看rrd文件里面的是否用数据,例如可以用rrdtool fetch Akamai1~10.10.16.111.rrd AVERAGE 命令查看master端slave提交的rrd文件

查看linux configure arguments

We can use nginx as an example:

[[email protected]:~]nginx -V
nginx version: nginx/1.4.1
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
TLS SNI support enabled
configure arguments: –prefix=/etc/nginx/ –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
–http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-http_ssl_module
–with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module
–with-http_flv_module –with-http_mp4_module –with-http_gzip_static_module –with-http_random_index_module
–with-http_secure_link_module –with-http_stub_status_module –with-mail –with-mail_ssl_module
–with-file-aio –with-ipv6 –with-cc-opt=’-O2 -g’ –add-module=/usr/src/headers-more-nginx-module-0.20

 

If we compile nginx from source, we can use

./configure –with-http_flv_module –with-http_mp4_module –with-other-modules