本文整理汇总了Python中Products.ZenUtils.ZenScriptBase.ZenScriptBase.getDataRoot方法的典型用法代码示例。如果您正苦于以下问题:Python ZenScriptBase.getDataRoot方法的具体用法?Python ZenScriptBase.getDataRoot怎么用?Python ZenScriptBase.getDataRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.ZenUtils.ZenScriptBase.ZenScriptBase
的用法示例。
在下文中一共展示了ZenScriptBase.getDataRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getmysqlcreds
# 需要导入模块: from Products.ZenUtils.ZenScriptBase import ZenScriptBase [as 别名]
# 或者: from Products.ZenUtils.ZenScriptBase.ZenScriptBase import getDataRoot [as 别名]
def getmysqlcreds():
"""Fetch the mysql creds from the object database and store them
in the global file for use in later commands.
returns True on success, False on failure
"""
pids = os.popen('pgrep -f zeo.py').read().split('\n')
pids = [int(p) for p in pids if p]
if len(pids) < 1:
log.warning('zeo is not running')
return False
log.debug("Fetching mysql credentials")
mysqlpass = 'zenoss'
mysqluser = 'zenoss'
mysqlport = '3306'
mysqlhost = 'localhost'
sys.path.insert(0, os.path.join(zenhome, 'lib/python'))
try:
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
zsb = ZenScriptBase(noopts=True, connect=True)
zsb.getDataRoot()
dmd = zsb.dmd
mysqlpass = dmd.ZenEventManager.password
mysqluser = dmd.ZenEventManager.username
mysqlport = dmd.ZenEventManager.port
mysqlhost = dmd.ZenEventManager.host
except Exception, ex:
log.exception("Unable to open the object database for "
"mysql credentials")
示例2: eventStats
# 需要导入模块: from Products.ZenUtils.ZenScriptBase import ZenScriptBase [as 别名]
# 或者: from Products.ZenUtils.ZenScriptBase.ZenScriptBase import getDataRoot [as 别名]
def eventStats():
try:
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from Products.Zuul import getFacade
zsb = ZenScriptBase(noopts=True, connect=True)
zsb.getDataRoot()
zepfacade = getFacade('zep')
statsList = zepfacade.getStats()
return '\n\n'.join([str(item) for item in statsList])
except Exception, ex:
log = logging.getLogger('zendiag')
log.exception(ex)
示例3: zenossInfo
# 需要导入模块: from Products.ZenUtils.ZenScriptBase import ZenScriptBase [as 别名]
# 或者: from Products.ZenUtils.ZenScriptBase.ZenScriptBase import getDataRoot [as 别名]
def zenossInfo():
"get the About:Versions page data"
try:
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
zsb = ZenScriptBase(noopts=True, connect=True)
zsb.getDataRoot()
result = []
for record in zsb.dmd.About.getAllVersions():
result.append('%10s: %s' % (record['header'], record['data']))
result.append('%10s: %s' % ('uuid', zsb.dmd.uuid))
return '\n'.join(result)
except Exception, ex:
log.exception(ex)
示例4: zenossInfo
# 需要导入模块: from Products.ZenUtils.ZenScriptBase import ZenScriptBase [as 别名]
# 或者: from Products.ZenUtils.ZenScriptBase.ZenScriptBase import getDataRoot [as 别名]
def zenossInfo():
"get the About:Versions page data"
def format_data(fmt, data):
return [fmt % datum for datum in data] + ['']
try:
print "Gathering info from zodb..."
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from Products.Zuul import getFacade
zsb = ZenScriptBase(noopts=True, connect=True)
zsb.getDataRoot()
header_data = [
('Report Data', datetime.datetime.now()),
('Server Key', zsb.dmd.uuid),
('Google Key', zsb.dmd.geomapapikey)]
counter = {}
decomm = 0
for d in zsb.dmd.Devices.getSubDevices():
if d.productionState < 0:
decomm += 1
else:
index = '%s %s' % \
(d.getDeviceClassPath(), d.getProductionStateString())
count = counter.get(index, 0)
counter[index] = count + 1
totaldev = zsb.dmd.Devices.countDevices()
device_summary_header_data = [
('Total Devices', totaldev),
('Total Decommissioned Devices', decomm),
('Total Monitored Devices', totaldev - decomm),
]
device_summary_header = ['Device Breakdown by Class and State:']
counter_keylist = counter.keys()
counter_keylist.sort()
device_summary_data = [(k, counter[k]) for k in counter_keylist]
zenpacks_header = ['ZenPacks:']
zenpack_ids = zsb.dmd.ZenPackManager.packs.objectIds()
zenoss_versions_data = [
(record['header'], record['data']) for
record in zsb.dmd.About.getAllVersions()]
uuid_data = [('uuid', zsb.dmd.uuid)]
event_start = time.time() - 24 * 60 * 60
product_count=0
for name in zsb.dmd.Manufacturers.getManufacturerNames():
for product_name in zsb.dmd.Manufacturers.getProductNames(name):
product_count = product_count + 1
# Hub collector Data
collector_header = ['Hub and Collector Information']
hub_data = []
remote_count = 0
local_count = 0
for hub in zsb.dmd.Monitors.Hub.getHubs():
hub_data.append("Hub: %s" % hub.id)
for collector in hub.collectors():
hub_data.append("\tCollector: %s IsLocal(): %s" % (collector.id,collector.isLocalHost()))
if not collector.isLocalHost():
hub_data.append("\tCollector(Remote): %s" % collector.id)
remote_count = remote_count + 1
else:
hub_data.append("\tCollector(Local): %s " % collector.id)
local_count = local_count + 1
zep = getFacade('zep')
tail_data = [
('Evt Rules', zsb.dmd.Events.countInstances()),
('Evt Count (Last 24 Hours)', zep.countEventsSince(event_start)),
('Reports', zsb.dmd.Reports.countReports()),
('Templates', zsb.dmd.Devices.rrdTemplates.countObjects()),
('Systems', zsb.dmd.Systems.countChildren()),
('Groups', zsb.dmd.Groups.countChildren()),
('Locations', zsb.dmd.Locations.countChildren()),
('Users', len(zsb.dmd.ZenUsers.getUsers())),
('Product Count', product_count),
('Local Collector Count', local_count),
('Remote Collector Count', remote_count)]
detail_prefix = ' '
std_key_data_fmt = '%s: %s'
detail_std_key_data_fmt = detail_prefix + std_key_data_fmt
detail_data_fmt = detail_prefix + '%s'
center_justify_fmt = '%10s: %s'
return_data = (
format_data(std_key_data_fmt, header_data) +
format_data(std_key_data_fmt, device_summary_header_data) +
device_summary_header +
#.........这里部分代码省略.........