一、批量安裝zabbix客戶端1.拷貝sh指令碼和.conf到遠端伺服器(也可以全量拷貝客戶端)
ansible all -m copy -a "
src=/usr/local/zabbix_agents_3.2.0/scripts/php_status_code.sh dest=/usr/local/zabbix_agents_3.2.0/scripts/ mode=0755
"ansible all -m copy -a "
src=/usr/local/zabbix_agents_3.2.0/scripts/start_php.sh dest=/usr/local/zabbix_agents_3.2.0/scripts/ mode=0755
"ansible all -m copy -a "
src=/usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/php-fpm_status.conf dest='/usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/'
"# 在ansible伺服器上新增/data/www/.machine_no,然後新增批量賦權
ansible all -m copy -a "
src=/data/www/.machine_no dest=/data/www/ mode=0644 owner=apache group=users
"# 拷貝整個目錄到目標伺服器
ansible all -m copy -a "
src=/usr/local/zabbix_agents_3.2.0/ dest=/usr/local/zabbix_agents_3.2.0/ mode=0755"2
.開啟遠端命令
ansible cmsnew -m shell -a "
sed -i 's|# enableremotecommands=0|enableremotecommands=1|g' /etc/zabbix/zabbix_agentd.conf
"# apache 新增配置
'# 重啟apache
/etc/init.d/apache -t
/etc/init.d/apache restart
# 新增sudo許可權
ansible all -m blockinfile -a '
path=/etc/sudoers block="defaults:zabbix !requiretty\nzabbix all=nopasswd: all\nzabbix all=nopasswd: /bin/bash /usr/local/rsync/bin/rsync\nzabbix all=nopasswd: /bin/bash /usr/local/nginx/sbin/nginx\nzabbix all=nopasswd: /bin/bash /usr/local/php/sbin/php-fpm\n" insertbefore=eof
'# 修改主機名
ansible all -m shell -a '
sed -i "s/hostname\=zabbixclient/hostname\=`hostname`/g" /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd.conf
'ansible all -m shell -a "
cd /usr/local/zabbix_agents_3.2.0 && sh agent.sh
"ansible all -m shell -a "
executable=/bin/bash /etc/init.d/zabbix_agentd restart
"# 批量新增計畫任務,批量新增時間同步任務
ansible all -m cron -a "
minute=1 hour=* day=* month=* weekday=* name='ntpdate' job='/usr/sbin/ntpdate time.windows.com > /dev/null 2>&1'
"ansible europe_tunesgo_web1 -m cron -a "
minute=1 hour=* day=* month=* weekday=* name='ntpdate' job='/usr/sbin/ntpdate time.windows.com > /dev/null 2>&1'
"# agent.
sh#!/bin/bash
#清理歷史資訊
rm -rf /usr/local/etc/zabbix_agent*
rm -f /etc/init.d/zabbix_agentd
rm -f /usr/bin/zabbix_*
rm -f /usr/sbin/zabbix_*
rm -f /usr/local/zabbix_agents_2.0.10.tar
.gzrm -rf /usr/local/zabbix_agents_2.0.10
/usr/sbin/groupadd zabbix
/usr/sbin/useradd -g zabbix zabbix
mkdir /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix
cp init.d/zabbix_agentd /etc/init.d/
chmod
755 /etc/init.d/zabbix_agentd
zabbix_dir=/usr/local/zabbix_agents_3.2.0
#sed -i "
s#basedir=/usr/local#basedir=$zabbix_dir#g
" /etc/init.d/zabbix_agentd
sed -i "
s#tmp/zabbix_agentd.log#var/log/zabbix/zabbix_agentd.log#g
" $zabbix_dir/conf/zabbix_agentd.conf
sed -i "
s/# unsafeuserparameters\=0/unsafeuserparameters\=1/g
" $zabbix_dir/conf/zabbix_agentd.conf
ln -s $zabbix_dir/conf/zabbix_agentd.conf /usr/local/etc
ln -s $zabbix_dir/conf/zabbix_agentd /usr/local/etc
ln -s $zabbix_dir/bin/*
/usr/bin/
ln -s $zabbix_dir/sbin/* /usr/sbin/
chkconfig zabbix_agentd on
#service zabbix_agentd start
ansible 常用方法
測試 用shell執行乙個指令碼很麻煩的,用script執行 1 推送指令碼過去,並授權 ansible george m copy a src tmp test.sh dest tmp mode x 2 執行指令碼 ansible george m shell a tmp test.sh 6.sc...
常用方法小結
color gray size large 1.在某個sheet的某列前面插入新的行 size color 在某個sheet的某列前面插入新的行 sheetname sheet名稱 rowkey 行標誌,eg a b c sub insertnewrow sheetname as string,ro...
QString的常用方法 小結
簡介 qstring 字串被每個gui程式所使用,不僅是使用者介面,還有資料結構。c 原生提供兩種字串 傳統的c風格以 0 結尾的字元陣列和std string類。與這些不同,qstring使用16 bit unicode值 當使用qstring時,我們不必操心如此隱秘的細節,像分配足夠的記憶體或者...