Chinaunix首页 | 论坛 | 博客
  • 博客访问: 500340
  • 博文数量: 31
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 1622
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-09 10:07
文章分类

全部博文(31)

文章存档

2013年(1)

2012年(19)

2011年(2)

2010年(2)

2009年(3)

2008年(4)

分类: LINUX

2011-06-22 11:20:51

这两天研究了一下zenoss批量添加。虽然官方有说明(http://community.zenoss.org/blogs/zenossblog/2010/06/29/tip-of-the-month-bulk-loading-devices-with-zenbatchload),并且有中文说明,但实际研究过程中发现存在一些问题。逐写下此博,一方面给自己留个烂笔头,一方面Share给大家。

首先,在后台运行zenbatchload --sample_configs,查看批量添加的详细说明。这里用#mura:做一个逐行介绍

[zenoss@localhost root]$ zenbatchload --sample_configs
#
# Example zenbatchloader device file
#mrua:使用方法,运行zenbatchload 添加设备清单文件(可以是文本文件)
# This file is formatted with one entry per line, like this:
#
#  /Devices/device_class_name Python-expression
#  hostname Python-expression
#mura:格式定义部分。第一行定义批量的设备分类,也可以理解为同类型同属性的配置,后面跟随Python表达式,第二行定义需添加适合该类属性的设备清单,同样可以跟随Python表达式。

# For organizers (ie the /Devices path), the Python-expression
# is used to define defaults to be used for devices listed
# after the organizer. The defaults that can be specified are:
#mura:注意设备分类的根结构应该是/Devices然后再跟随后面的结构路径。

#   * loader arguments (use the --show_options flag to show these)
#   * zPropertie (from a device, use the More -> zProperties
#      menu option to see the available ones.)
#mura:这是一段关于Python表达式的说明,可通过--show_options查看默认的添加参数应用。对于单台添加设备而言,在Python表达式中,可利用zPropertie的变量。zPropertie可参看设备管理中的zProperties。
#      NOTE: new zProperties *cannot* be created through this file
#mura:注意,这里只能应用已有的zProperite,并不能够在这里新添zProperties。
#  The Python-expression is used to create a dictionary of settings.
#  device_settings = eval( 'dict(' + python-expression + ')' )
#mura:但Python表达式可以用于创建新的字典。


# If no organizer is specified at the beginning of the file,
# defaults to the /Devices/Discovered device class.
#mura:如果在第一行中,不指定设备分类的话,哪么设备将默认添加到Discovered结构中。
device0 comments="A simple device"
# All settings must be seperated by a comma.
#mura:在Python表达式中,多个参数必需要通过“,”分隔
device1 comments="A simple device", zSnmpCommunity='blue', zSnmpVer='v1'

# Notes for this file:
#  * Oraganizer names *must* start with '/'
#mura:另外,组织结构名称必需以“/”开始
/Devices/Server/Linux zSnmpPort=1543
# Python strings can use either ' or " -- there's no difference.
#mura:Python字符串可以使用引号锁定。
# As a special case, it is also possible to specify the IP address
#mura:特殊情况下,也可以指定设备的管理IP(监控访问IP),在这里mura建议大家写好setManagerIp。否则,设备将根据域名记录找寻设备。
linux_device1 setManageIp='10.10.10.77', zSnmpCommunity='blue', zSnmpVer="v2c"
# A '' at the end of the line allows you to place more
# expressions on a new line. Don't forget the comma...
#mura:如果一条Python表达式过长,允许回车记录,表达式的结尾时不可使用逗号。
linux_device2 zLinks="Support site",  zTelnetEnable=True, zTelnetPromptTimeout=15.3

# A new organizer drops all previous settings, and allows
# for new ones to be used.  Settings do not span files.
#mura:之前已经提及,在设备分类行中,可以将同属性的Python表达式一并写入。
/Devices/Server/Windows zWinUser="administrator", zWinPassword='fred'
# Bind templates
#mura:绑定模板的方法。
windows_device1 zDeviceTemplates=[ 'Device', 'myTemplate' ]
# Override the default from the organizer setting.
#mura:定义远程访问帐号方法。
windows_device2 zWinUser="administrator", zWinPassword='thomas'

# Apply other settings to the device
#mura:下面是一条设备添加设置的用法。
settingsDevice setManageIp='10.10.10.77', setLocation="123 Elm Street",   setSystems='/mySystems', setPerformanceMonitor='remoteCollector1',   setHWSerialNumber="abc123456789", setGroups='/myGroup',   setHWProduct=('myproductName','manufacturer'), setOSProduct=('OS Name','manufacturer')

# If the device or device class contains a space, then it must be quoted (either ' or ")
#mura:如果设备分类中包含空格,必需使用引号锁定。
"/Server/Windows/WMI/Active Directory/2008"

# Now, what if we have a device that isn't really a device, and requires
# a special loader?
# The 'loader' setting requires a registered utility, and 'loader_arg_keys' is
# a list from which any other settings will be passed into the loader callable.
#
# Here is a commmented-out example of how a VMware endpoint might be added:
#mrua:如果是一台虚拟设备,并且要求指定宿主机的话,可以通过loader_arg_keys的方式传递参数。
#/Devices/VMware loader='vmware', loader_arg_keys=['host', 'username', 'password', 'useSsl', 'id']
#esxwin2 id='esxwin2', host='esxwin2.zenoss.loc', username='testuser', password='password', useSsl=True

#mura:最后,如果您的系统已经实现了中文化,并且支持中文结构的话,可在配置参数中写入中文,但需要使用utf-8码存储配置文件。

下面,我们就来一次真的测试:
1.创建一个导入配置文件,utf-8字集进行保存。
 more devicelist.txt 
/Devices/Server/windows setSystems='邮件',zSnmpCommunity='zenoss',setPerformanceMonitor='localhost',
IDC-D-test setManageIp='172.20.88.10',setLocation='/北京'
2. 通过zenbatchload添加设备:
$ zenbatchload devicelist.txt
3. 查看添加结果:

效果比较满意,大家还一起来批量添加吧~
阅读(5102) | 评论(10) | 转发(1) |
给主人留下些什么吧!~~

jiannma2012-09-18 18:57:51

zenoss批量删除 是咋弄的哇