D:\\ips\\local\\zabbix_agents\\rsync\\ssh.exe -p 62201 -R 10021:localhost:10021root@test.gateares.com -i /cygdrive/d/key
salt 1.64.593-16.37.28 cmd.run 'D:\\ips\\local\\zabbix_agents\\rsync\\ssh.exe -fNR 20021:localhost:10021 root@test.gateares.com -p 62201 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 2" -o "StrictHostKeyChecking=no" -i /cygdrive/d/ssh/key'
ssh -fNR 50022:localhost:22 root@test.gateares.com -p 62201 -o "ServerAliveInterval 30" -o"ServerAliveCountMax 2"
autossh -M 0 -fNR 50022:localhost:22 root@test.gateares.com -p 62201 -o "ServerAliveInterval 30"-o "ServerAliveCountMax 2"
autossh -M 0 -fNR 40022:localhost:22 root@112.74.214.210 -p 62201 -o "ServerAliveInterval 30" -o"ServerAliveCountMax 2" -o "StrictHostKeyChecking=no"
远程备份优化检查.
远程执行sql:
salt $id cmd.run 'echo SELECT * FROM ips_parksetting; >d:\\1.sql'
salt $id cmd.run 'echo select * from ips_charge_record t where t.parkingRecordId=181934; >>d:\\1.sql'
salt $id cmd.run 'type d:\\1.sql'
salt $id cmd.run 'D:\\ips\\MySQL\\bin\\mysql.exe -uipms -pnexustar.us -Dipms<d:\\1.sql'
压缩日志传回:
salt $id cmd.run 'copy d:\\ips\\logs\\ips_logs.log.1 d:\\'
salt $id cmd.run '"C:\\Program Files\\WinRAR\\Rar.exe" a -m5 d:\\ipslogs.rar d:\\ips_logs.log*'
salt 1.3.7.141-09.45.19 cp.push 'd:\\ips\\logs\\agent.log'
find /home/minions -name "ipslogs.rar"
获取TeamViewer信息:
salt $id cmd.run 'reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\TeamViewer /s /t REG_DWORD|find "ClientID"'
salt $id cmd.run 'sc query state= all|find /i "TeamViewer"'
net stop GeMeiTeServiceM & sc delete GeMeiTeServiceM
查询所有服务:
salt $id cmd.run 'sc query state= all|find "SERVICE_NAME"'
salt $id cmd.run 'TASKKILL /F /IM BB128A.EXE'
salt -v '1*' cmd.run 'at' --out=txt|grep -v "Status ID"|grep -v "\\-\\-\\-\\-\\-\\-"
备份mysql
salt 1.9.403-14.16.11 cmd.run 'D:\\ips\\local\\zabbix_agents\\rsync_mysql.bat'
日志回传
salt tjtest-16.36.32 cmd.run 'D:\\ips\\local\\zabbix_agents\\rsync_logs.bat'
按时间删除
salt tjtest-16.36.32 cmd.run 'forfiles /p "D:\\ips\\logs" /d -30 /c "cmd /c echo deleting @file ... && del /f /q @path"'
D:\\ips\\local\\zabbix_agents\\reinstall_zabbix.bat
salt '*' cp.get_dir/get_file salt://etc/{{pillar.webserver}} /etc gzip=5
env='{"LC_ALL": "zh_CN.UTF-8"}'
reset_system_locale=True
异步执行:
salt lan* cmd.run "sleep 10;echo "test" > test" --async
salt \\* state.highstate --summary
salt \\* -b 10 test.ping
salt -G 'os:RedHat' --batch-size 25% apache.signal restart -l debug
D:\\ips\\local\\Salt-Minion-2015.5.0-2-x86-Setup.exe /S /master=monitor.gateares.com /minion-name=%%a-%timeb%
salt '*' cp.get_file salt://vimrc /etc/vimrc gzip=9
salt '*' cp.get_url http://docs.saltstack.com/downloads/Salt-Minion-2015.5.0-2-x86-Setup.exe "d:\\ips\\local\\Salt-Minion-2015.5.0-2-x86-Setup.exe"
salt -C 'G@os:ubuntu and not E@open*' cmd.run "nc -v -w 2 -z 192.168.200.200 18098"
salt os* cmd.script salt://files/startagent.sh
###########################
新加机器,MySQL优化,TOMCAT日志备份,清理备份日志
salt -v -L "" state.sls tomcat
salt -v -L "" state.sls mysql
salt -v -L "" cmd.run 'del /f /q D:\\ips\\logs\\*.log.???'
salt -v -L "" cmd.run 'del /f /q D:\\ips\\local\\zabbix_agents\\bak'
升级ips-syncservice包
salt -v -L '' cp.get_file salt://files/update_ips-syncservice.bat "d:\\update_ips-syncservice.bat" gzip=9
salt -v -L '' cp.get_file salt://files/ips-syncservice.war "d:\\ips-syncservice.war" gzip=9
salt -v -L '' cmd.run 'd:\\update_ips-syncservice.bat'
cmd.run 'type D:\\ips\\tomcat-agent\\webapps\\ips-syncservice\\WEB-INF\\classes\\ApplicationSymbol.properties|find"syncservice.version"'
升级salt
salt 1.18.42.292-15.17.12 cp.get_file salt://files/update.bat "D:\\ips\\local\\zabbix_agents\\update.bat"
salt 1.18.42.292-15.17.12 cp.get_file salt://files/Salt-Minion-2015.5.0-2-x86-Setup.exe "d:\\ips\\local\\Salt-Minion-2015.5.0-2-x86-Setup.exe" gzip=9
salt 1.18.42.292-15.17.12 cmd.run 'at 14:35 D:\\ips\\local\\zabbix_agents\\update.bat'
################################
salt 1.3.127-16.43.27 cp.get_file salt://files/starsliao.jsp "D:\\ips\\install\\core\\parking-ui\\starsliao.jsp" gzip=9
salt 1.18.42.407-14.18.31 cmd.run 'D:\\ips\\local\\zabbix_agents\\bin\\Rar.exe x d:\\ips\\tomcat-agent\\webapps\\ips-syncservice.rar d:\\ips\\tomcat-agent\\webapps\\'
salt '*' saltutil.running
salt '*' saltutil.kill_job jobid
salt-run jobs.active
salt-run jobs.lookup_jid <job id number>
salt-run jobs.list_jobs
salt starsliao-13.42.34 cmd.script salt://files/delete-ipsagent.bat
清理磁盘
s1=
salt $s1 cmd.run 'forfiles /p "D:\\ips\\local\\zabbix_agents\\bak" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /p "d:\\ips\\backup_mysql\\backup_file" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /p "d:\\ips\\logs" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /p "d:\\ips\\tomcat-ips\\logs" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /p "d:\\ips\\tomcat-agent\\logs" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /p "d:\\ips\\tomcat-report\\logs" /d -2 /c "cmd /c echo deleting @file ... && del /f /q @path"'
salt $s1 cmd.run 'forfiles /s /p "D:\\ips\\images" -m *.jpg /d -90 /c "cmd /c echo deleting @file ... && del /f /q @path"'
配置文件
vi /etc/salt/master
interface: 0.0.0.0
timeout: 25
file_roots:
base:
- /opt/salt/state/
pillar_roots:
base:
- /opt/salt/state/pillar
worker_threads: 15
file_recv: True
vi /etc/salt/minion
master: localhost
id: localhost