2018年11月

安装好zabbix客户端之后,开启自定义监控

vim /usr/local/zabbix/etc/zabbix_agentd.conf
UnsafeUserParameters=1
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf

创建监控脚本

mkdir /usr/local/zabbix/etc/shell
vim /usr/local/zabbix/etc/shell/redis.sh #脚本内容参考文章结尾
chmod +x /usr/local/zabbix/etc/shell/redis.sh

配置监控

cd /usr/local/zabbix/etc/zabbix_agentd.conf.d/
vim zbx_redis.conf

UserParameter=redis.status,/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 7000 -a 密码 ping |grep -c PONG
UserParameter=redis_info[*],/usr/local/zabbix/etc/shell/redis.sh $1

脚本测试

/usr/local/zabbix/etc/shell/redis.sh uptime_in_seconds
563114
/usr/local/zabbix/etc/shell/redis.sh used_memory
596751408

- 阅读剩余部分 -

环境:python2.7,pip 1.5.4

pip install aliyun-python-sdk-core==2.3.5 aliyun-python-sdk-rds datetime
#报错
The 'pip==7.1.0' distribution was not found and is required by the application

https://files.pythonhosted.org/packages/07/9d/2af576b8b199c69d839a8dfd6025b6721a18a0b771a051b2b62b3c866d0f/distribute-0.6.10.tar.gz
tar -zxvf distribute-0.6.10.tar.gz
cd  distribute-0.6.10
python setup.py install

easy_install pip==7.1.0

pip install aliyun-python-sdk-core==2.3.5 aliyun-python-sdk-rds datetime

pip install selenium
脚本

#!/usr/bin/python
from selenium import webdriver
browser = webdriver.PhantomJS()
browser.get("http://www.site-digger.com/html/articles/20110516/proxieslist.html")
trs = browser.find_elements_by_tag_name('tr')
for tr in trs[1:]:
        print(tr.text.split(' ')[0])

报 selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar -xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 
cp -R phantomjs-2.1.1-linux-x86_64 /usr/local/share/ 
ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/

- 阅读剩余部分 -

场景:几十个站点迁移过来,懒得一一配置,索性来个遍历目录下的二级文件夹自动创建成nginx站点配置文件完成站点部署。
业务中除了获取目录名,还有排除已有,使用一个已有的标准配置来生成N多其它配置。
cd到nginx/conf下,创建脚本addsite.sh

florder='/disk2/ftp'
dir=$(ls -l $florder |awk '/^d/ {print $NF}')
for i in $dir
do
    if [ "$i" != 'p7zip_16.02' -a "$i" != 'img.isres.com' -a "$i" != 'img57.isres.com' ];then
        cp -f vhost/img.isres.com.conf vhost/$i.conf 
        sed -i 's/img.isres.com/'$i'/g' vhost/$i.conf 
        
        echo vhost/$i.conf 
    fi
done