zabbix批量導入screen腳本api
用法,先生成xml文件,選擇import導入bash
其中文中的opt目錄,能夠換成其餘的,你們能夠觸類旁通ide
固然,這種方法速度不快,但適用於不想用api進行操做的童鞋。url
最佳的方法仍是經過api對screen進行添加spa
- #!/bin/bash
- #function:import zabbix opt partion screen
- #author:itnihao
- #mail:itnihao@qq.com
- #轉載請註明做者itnihao,謝謝合做
- #date:2013-03-22
- cat >disk.xml << EOF
- <?xml version="1.0" encoding="UTF-8"?>
- <zabbix_export>
- <version>2.0</version>
- <date>2013-03-22T02:34:22Z</date>
- <screens>
- <screen>
- <name>opt</name>
- <hsize>3</hsize>
- <vsize>30</vsize>
- <screen_items>
- EOF
- IPARGV=($(for i in $(seq 28 210);do echo 10.10.10.$i;done))
- for num in $(seq 0 $(((${#IPARGV[@]}+1)/3-1)))
- do
- cat >>disk.xml << EOF
- <screen_item>
- <resourcetype>0</resourcetype>
- <width>400</width>
- <height>100</height>
- <x>0</x>
- <y>$num</y>
- <colspan>1</colspan>
- <rowspan>1</rowspan>
- <elements>0</elements>
- <valign>0</valign>
- <halign>1</halign>
- <style>0</style>
- <url/>
- <dynamic>0</dynamic>
- <sort_triggers>0</sort_triggers>
- <resource>
- <name>Disk space usage /opt</name>
- <host>$(echo ${IPARGV[$(echo $(($num*3+0)))]})</host>
- </resource>
- </screen_item>
- <screen_item>
- <resourcetype>0</resourcetype>
- <width>400</width>
- <height>100</height>
- <x>1</x>
- <y>$num</y>
- <colspan>1</colspan>
- <rowspan>1</rowspan>
- <elements>0</elements>
- <valign>0</valign>
- <halign>1</halign>
- <style>0</style>
- <url/>
- <dynamic>0</dynamic>
- <sort_triggers>0</sort_triggers>
- <resource>
- <name>Disk space usage /opt</name>
- <host>$(echo ${IPARGV[$(echo $(($num*3+1)))]})</host>
- </resource>
- </screen_item>
- <screen_item>
- <resourcetype>0</resourcetype>
- <width>400</width>
- <height>100</height>
- <x>2</x>
- <y>$num</y>
- <colspan>1</colspan>
- <rowspan>1</rowspan>
- <elements>0</elements>
- <valign>0</valign>
- <halign>1</halign>
- <style>0</style>
- <url/>
- <dynamic>0</dynamic>
- <sort_triggers>0</sort_triggers>
- <resource>
- <name>Disk space usage /opt</name>
- <host>$(echo ${IPARGV[$(echo $(($num*3+2)))]})</host>
- </resource>
- </screen_item>
- EOF
- done
- cat >>disk.xml <<EOF
- </screen_items>
- </screen>
- </screens>
- </zabbix_export>
- EOF