自用。仅供参考!
1. 拷贝*.sh, *.py至目标主机,并设定执行权限
[root@localhost smbios_zabbix_template]# ansible all -m copy -a 'src=./ dest=/usr/local/bin/ mode=0777'2. 复制zabbix agent配置文件并重启zabbix-agent
ansible all -m copy -a 'src=userparameter_smbios.conf dest=/usr/local/etc/zabbix_agentd.conf.d/userparameter_smbios.conf'
ansible all -m shell -a '/etc/init.d/zabbix_agentd restart'
3. 在所有目标主机添加cronjob
ansible all -m cron -a "name='SMBIOS' minute=* hour=*/1 day=* month=* weekday=* job='/usr/local/bin/cron_smbios.sh'"
4.手动执行/usr/local/bin/cron_smbios.sh'
[root@localhost smbios_zabbix]# ansible all -m shell -a '/usr/local/bin/cron_smbios.sh'
5. 在zabbix web导入模板
注意: 因所有监控项每个月采集一次, 所以导入前需要修改zbx_export_templates.xml 中所有灵活调度的时间
md2h11m14 代表每个月的2日11时14分