批量生成zabbix screen xml file

zabbix批量导入screen脚本

用法,先生成xml文件,选择import导入

其中文中的opt目录,可以换成其他的,大家可以举一反三

当然,这种方法速度不快,但适用于不想用api进行操作的童鞋。

最佳的方法还是通过api对screen进行添加

  
  
  
  
  1. #!/bin/bash
  2. #function:import zabbix opt partion screen
  3. #author:itnihao
  4. #mail:[email protected]
  5. #转载请注明作者itnihao,谢谢合作
  6. #date:2013-03-22
  7. cat >disk.xml << EOF  
  8. <?xml version="1.0" encoding="UTF-8"?> 
  9. <zabbix_export> 
  10.     <version>2.0</version> 
  11.     <date>2013-03-22T02:34:22Z</date> 
  12.     <screens> 
  13.         <screen> 
  14.             <name>opt</name> 
  15.             <hsize>3</hsize> 
  16.             <vsize>30</vsize> 
  17.             <screen_items> 
  18. EOF 
  19. IPARGV=($(for i in $(seq 28 210);do echo 10.10.10.$i;done)) 
  20. for num in $(seq 0 $(((${#IPARGV[@]}+1)/3-1))) 
  21. do 
  22.          cat >>disk.xml << EOF 
  23.                 <screen_item> 
  24.                     <resourcetype>0</resourcetype> 
  25.                     <width>400</width> 
  26.                     <height>100</height> 
  27.                     <x>0</x> 
  28.                     <y>$num</y> 
  29.                     <colspan>1</colspan> 
  30.                     <rowspan>1</rowspan> 
  31.                     <elements>0</elements> 
  32.                     <valign>0</valign> 
  33.                     <halign>1</halign> 
  34.                     <style>0</style> 
  35.                     <url/> 
  36.                     <dynamic>0</dynamic> 
  37.                     <sort_triggers>0</sort_triggers> 
  38.                     <resource> 
  39.                         <name>Disk space usage /opt</name> 
  40.                         <host>$(echo ${IPARGV[$(echo $(($num*3+0)))]})</host> 
  41.                     </resource> 
  42.                 </screen_item> 
  43.                 <screen_item> 
  44.                     <resourcetype>0</resourcetype> 
  45.                     <width>400</width> 
  46.                     <height>100</height> 
  47.                     <x>1</x> 
  48.                     <y>$num</y> 
  49.                     <colspan>1</colspan> 
  50.                     <rowspan>1</rowspan> 
  51.                     <elements>0</elements> 
  52.                     <valign>0</valign> 
  53.                     <halign>1</halign> 
  54.                     <style>0</style> 
  55.                     <url/> 
  56.                     <dynamic>0</dynamic> 
  57.                     <sort_triggers>0</sort_triggers> 
  58.                     <resource> 
  59.                         <name>Disk space usage /opt</name> 
  60.                         <host>$(echo ${IPARGV[$(echo $(($num*3+1)))]})</host> 
  61.                     </resource> 
  62.                 </screen_item> 
  63.                 <screen_item> 
  64.                     <resourcetype>0</resourcetype> 
  65.                     <width>400</width> 
  66.                     <height>100</height> 
  67.                     <x>2</x> 
  68.                     <y>$num</y> 
  69.                     <colspan>1</colspan> 
  70.                     <rowspan>1</rowspan> 
  71.                     <elements>0</elements> 
  72.                     <valign>0</valign> 
  73.                     <halign>1</halign> 
  74.                     <style>0</style> 
  75.                     <url/> 
  76.                     <dynamic>0</dynamic> 
  77.                     <sort_triggers>0</sort_triggers> 
  78.                     <resource> 
  79.                         <name>Disk space usage /opt</name> 
  80.                         <host>$(echo ${IPARGV[$(echo $(($num*3+2)))]})</host> 
  81.                     </resource> 
  82.                 </screen_item> 
  83. EOF 
  84.     done 
  85. cat >>disk.xml <<EOF 
  86.             </screen_items> 
  87.         </screen> 
  88.     </screens> 
  89. </zabbix_export> 
  90. EOF 

 

你可能感兴趣的:(zabbix,screen, )