Skip to content

Commit 1e845d4

Browse files
committed
Merge pull request #1 from Mattikin/master
VMwareESXiMonitor 2.0.1
2 parents 9981d1a + 50f9839 commit 1e845d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+12308
-1816
lines changed

COPYRIGHT.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
All files in this directory and below are:
3+
4+
Copyright (c) 2008, 2009, 2010 Zenoss, Inc. All rights reserved.
5+
6+
This program is free software; you can redistribute it and/or modify it
7+
under the terms of the GNU General Public License version 2 as published
8+
by the Free Software Foundation.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

INSTALL.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
# This graft causes all files located under the ZenPacks/ subdirectory to be
2+
# included in the built ZenPack .egg. Files located in the top-level directory
3+
# of the ZenPack will not be explicitly included.
4+
#
5+
# You can read more about the format and available options available in this
6+
# MANIFEST.in file at the following URL.
7+
# http://docs.python.org/distutils/sourcedist.html
18
graft ZenPacks

README.txt

Lines changed: 164 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,164 @@
1-
This directory is a template for the creation of new ZenPacks. When a user creates a new ZenPack via the Zenoss gui this directory is copied, modified and installed in $ZENHOME/ZenPacks.
1+
# ZenPack Template
2+
This README describes the structure of the ZenPack template that gets
3+
automatically created by Zenoss when you add a ZenPack through the web
4+
interface.
5+
6+
## Files
7+
At the top-level a ZenPack must have a setup.py. Almost always a MANIFEST.in
8+
file should exist, and in cases where external dependencies must be built for
9+
inclusion in the ZenPack, a GNUmakefile. Examples of these files with inline
10+
comments are included in this template.
11+
12+
Also included in the ZenPackTemplate is a configure.zcml. As more of Zenoss'
13+
extensibility moves to using ZCA (Zope Component Architecture) this file
14+
becomes crucial to hooking into various aspects of Zenoss.
15+
16+
## Files and Subdirectories
17+
The following sections describe the purpose and use for each of the default
18+
subdirectories. Note that if the described functionality is not of use in your
19+
ZenPack it is safe to remove any of the default directories.
20+
21+
### src/
22+
The src/ top-level directory in ZenPacks is the conventional place to add
23+
third-party dependencies to your ZenPack. It should only be used as a staging
24+
area to do any build work necessary for the dependency.
25+
26+
See GNUmakefile (or GNUmakefile.example) for examples of how to have
27+
your third-party dependencies automatically compiled and installed at the right
28+
time and into the right location.
29+
30+
### ZenPacks/NAMESPACE/PACKNAME/
31+
The following sections describe the directories contained within the
32+
namespaced ZenPacks/NAMESPACE/PACKNAME/ subdirectories.
33+
34+
#### bin/
35+
Any general tools delivered by your ZenPack that would be used by the Zenoss
36+
administrator at the command line should go into this directory by convention.
37+
When the ZenPack is installed all files in this directory will be made
38+
executable.
39+
40+
#### browser/
41+
The browser subdirectory should contain all code and configuration that's
42+
specific to the Zenoss web interface. The provided configure.zcml will
43+
automatically load the example browser/configure.zcml and register the
44+
browser/resources/ subdirectory to serve static web content.
45+
46+
#### daemons/
47+
All files in the daemons/ subdirectory get special handling. Upon installing
48+
the ZenPack, the following actions will occur.
49+
50+
1. The file will be made executable (chmod 0755)
51+
2. A symlink to the file will be created in $ZENHOME/bin/
52+
3. An configuration file will be generated at $ZENHOME/etc/DAEMON_NAME.conf
53+
54+
Assuming that you don't have a $ZENHOME/etc/DAEMONS_TXT_ONLY file this daemon
55+
will also become part of the normal zenoss start and stop processes.
56+
57+
You can find an example daemon control script in daemons/zenexample. For most
58+
purposes this file can be renamed to the name of the daemon you want to create
59+
and modified to change the DAEMON_NAME. No other modifications are typically
60+
needed. Note that this example control script does expect to launch the real
61+
daemon code which should be located at ../DAEMON_NAME.py.
62+
63+
#### datasources/
64+
Any new datasource types you want to add must be added as classes into the
65+
datasources/ subdirectory. When Zenoss is building the list of available
66+
datasources it will scan the datasources/ subdirectory for all installed
67+
ZenPacks.
68+
69+
An example datasource at datasources/ExampleDataSource.py.example.
70+
71+
#### lib/
72+
The lib/ directory should be the installation target for any third-party
73+
libraries that are built by the GNUmakefile. It can also be used as the
74+
conventional location to drop Python-only libraries that don't require
75+
any compilation or special installation.
76+
77+
#### libexec/
78+
Any scripts executed by COMMAND datasources in your ZenPack go in this
79+
directory by convention. When the ZenPack is installed all files in this
80+
directory will be made executable.
81+
82+
#### migrate/
83+
ZenPacks can include migrate scripts that allow you to run custom code to
84+
handle any tasks that are needed to upgrade your ZenPack from one version to
85+
another. All .py files in this migrate/ subdirectory will be evaluated when the
86+
ZenPack is installed.
87+
88+
You can find an example migrate script at migrate/ExampleMigration.py.
89+
90+
#### modeler/
91+
Any modeler plugins distributed with your ZenPack must be located under the
92+
plugins/ subdirectory. The directory structure and filenames under plugins/
93+
map directly to the plugins' name in the user interface. For example, if you
94+
wanted to create a modeler plugin called "community.snmp.ExampleMap" you would
95+
create the following directory structure.
96+
97+
It is recommended that the first portion of the namespace be a short lowercase
98+
form of your name, or organization's name. Alternatively you can choose to use
99+
"community" if you plan to publish the ZenPack and are open to outside
100+
contributions. Zenoss, Inc. will always use "zenoss." The second portion of the
101+
namespace can be the protocol that is used to collect the data. If you are not
102+
using a common protocol it is acceptable to skip the second portion of the
103+
namespace and have something like "community.MongoDB" instead.
104+
105+
plugins/
106+
__init__.py
107+
community/
108+
__init__.py
109+
snmp/
110+
__init__.py
111+
ExampleMap.py
112+
113+
Note that the __init__.py files must exist and should be empty files. Otherwise
114+
your modeler plugins won't be imported and usable within Zenoss.
115+
116+
#### objects/
117+
All .xml files in this objects/ directory will be loaded into the object
118+
database when the ZenPack installs. All of the objects defined in the XML files
119+
will be automatically associated with the ZenPack.
120+
121+
When you export the ZenPack from the user interface all objects associated with
122+
the ZenPack will be exported into a file called "objects.xml" specifically. For
123+
this reason it is recommended to let Zenoss manage the objects.xml file and to
124+
never manually create or modify any .xml files in this directory unless you
125+
know what you're doing.
126+
127+
When a ZenPack is removed, any objects associated with the ZenPack will be
128+
recursively removed from Zenoss. For example, if you associated the /Server
129+
device class with your ZenPack and removed the ZenPack, the /Server device
130+
class, and all devices within it would also be deleted.
131+
132+
When a ZenPack is upgraded, or re-installed on top of itself, all objects in
133+
the XML files are overlaid on the existing object database. This results in a
134+
merge of the existing objects and what are defined in the XML files with the
135+
XML file properties and relationships winning any conflicts.
136+
137+
#### reports/
138+
Custom reports will be loaded from this directory when the ZenPack is
139+
installed. Subdirectories (with the exception of plugins/) will be mapped
140+
directly to the report folders in the web interface. So if you add a .rpt file
141+
into a subdirectory named "Performance Reports" you will find your report in
142+
the Performance Reports folder in the web interface after installing the
143+
ZenPack.
144+
145+
The plugins/ subdirectory should include any Python plugins your custom reports
146+
call. So if your .rpt file contains a line such as the following..
147+
148+
objects python:here.ReportServer.plugin('myplugin', tableState);
149+
150+
There should be a corresponding myplugin.py file in the plugins/ subdirectory.
151+
152+
You can find an example report at Example Reports/Example Report.rpt.example
153+
that uses a plugin which can be found at plugins/example_plugin.py.
154+
155+
#### services/
156+
ZenHub services will be loaded from the services/ directory. These services
157+
run inside the zenhub daemon and are responsible from all interaction with
158+
collector daemons.
159+
160+
You can find an example service at services/ExampleConfigService.py.
161+
162+
#### tests/
163+
All unit tests for your ZenPack should live in this directory. You can find an
164+
example test suite at tests/testExample.py.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
################################################################################
2+
#
3+
# This program is part of the VMwareESXiMonitor Zenpack for Zenoss.
4+
# Copyright (C) 2014 Eric Enns, Matthias Kittl.
5+
#
6+
# This program can be used under the GNU General Public License version 2
7+
# You can find full information here: http://www.zenoss.com/oss
8+
#
9+
################################################################################
10+
11+
from Globals import InitializeClass
12+
from math import isnan
13+
from Products.ZenModel.DeviceComponent import DeviceComponent
14+
from Products.ZenModel.ManagedEntity import ManagedEntity
15+
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
16+
17+
class ESXiDatastore(DeviceComponent, ManagedEntity):
18+
meta_type = portal_type = 'ESXiDatastore'
19+
20+
type = None
21+
capacity = None
22+
23+
_properties = ManagedEntity._properties + (
24+
{'id': 'type', 'type': 'string'},
25+
{'id': 'capacity', 'type': 'long'},
26+
)
27+
28+
_relations = ManagedEntity._relations + (
29+
('esxiHost', ToOne(ToManyCont,
30+
'ZenPacks.community.VMwareESXiMonitor.ESXiHost',
31+
'esxiDatastore',
32+
),
33+
),
34+
)
35+
36+
def device(self):
37+
return self.esxiHost()
38+
39+
def usedSpace(self):
40+
capacity = self.capacity
41+
free = self.freeSpace()
42+
if capacity is not None and free is not None:
43+
return capacity - free
44+
return None
45+
46+
def freeSpace(self):
47+
free = self.cacheRRDValue('diskFreeSpace')
48+
if free is not None and not isnan(free):
49+
return long(free)
50+
return None
51+
52+
def usedPercent(self):
53+
capacity = self.capacity
54+
used = self.usedSpace()
55+
if capacity is not None and used is not None:
56+
return round(100.0 * used / capacity)
57+
return 'Unknown'
58+
59+
InitializeClass(ESXiDatastore)
60+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
################################################################################
2+
#
3+
# This program is part of the VMwareESXiMonitor Zenpack for Zenoss.
4+
# Copyright (C) 2014 Eric Enns, Matthias Kittl.
5+
#
6+
# This program can be used under the GNU General Public License version 2
7+
# You can find full information here: http://www.zenoss.com/oss
8+
#
9+
################################################################################
10+
11+
from Globals import InitializeClass
12+
from Products.ZenModel.Device import Device
13+
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
14+
from Products.ZenModel.ZenossSecurity import ZEN_VIEW
15+
16+
class ESXiHost(Device):
17+
meta_type = portal_type = 'ESXiHost'
18+
19+
cpuMhz = None
20+
cpuModel = None
21+
numCpuCores = None
22+
numCpuPkgs = None
23+
numCpuCoresPerPkgs = None
24+
numCpuThreads = None
25+
numNics = None
26+
esxiHostName = None
27+
vmotionState = False
28+
29+
_properties = Device._properties + (
30+
{'id': 'cpuMhz', 'type': 'long'},
31+
{'id': 'cpuModel', 'type': 'string'},
32+
{'id': 'numCpuCores', 'type': 'int'},
33+
{'id': 'numCpuPkgs', 'type': 'int'},
34+
{'id': 'numCpuCoresPerPkgs', 'type': 'int'},
35+
{'id': 'numCpuThreads', 'type': 'int'},
36+
{'id': 'numNics', 'type': 'int'},
37+
{'id': 'esxiHostName', 'type': 'string'},
38+
{'id': 'vmotionState', 'type': 'boolean'},
39+
)
40+
41+
_relations = Device._relations + (
42+
('esxiVm', ToManyCont(ToOne,
43+
'ZenPacks.community.VMwareESXiMonitor.ESXiVM',
44+
'esxiHost',
45+
),
46+
),
47+
('esxiDatastore', ToManyCont(ToOne,
48+
'ZenPacks.community.VMwareESXiMonitor.ESXiDatastore',
49+
'esxiHost',
50+
),
51+
),
52+
)
53+
54+
InitializeClass(ESXiHost)
55+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
################################################################################
2+
#
3+
# This program is part of the VMwareESXiMonitor Zenpack for Zenoss.
4+
# Copyright (C) 2014 Eric Enns, Matthias Kittl.
5+
#
6+
# This program can be used under the GNU General Public License version 2
7+
# You can find full information here: http://www.zenoss.com/oss
8+
#
9+
################################################################################
10+
11+
from Globals import InitializeClass
12+
from math import isnan
13+
from Products.ZenModel.DeviceComponent import DeviceComponent
14+
from Products.ZenModel.ManagedEntity import ManagedEntity
15+
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
16+
from Products.ZenModel.ZenossSecurity import ZEN_VIEW, ZEN_CHANGE_SETTINGS
17+
from Products.ZenUtils.Utils import convToUnits
18+
19+
class ESXiVM(DeviceComponent, ManagedEntity):
20+
meta_type = portal_type = 'ESXiVM'
21+
22+
osType = None
23+
memory = 0
24+
25+
_properties = ManagedEntity._properties + (
26+
{'id': 'osType', 'type': 'string'},
27+
{'id': 'memory', 'type': 'int'},
28+
)
29+
30+
_relations = ManagedEntity._relations + (
31+
('esxiHost', ToOne(ToManyCont,
32+
'ZenPacks.community.VMwareESXiMonitor.ESXiHost',
33+
'esxiVm',
34+
),
35+
),
36+
)
37+
38+
def device(self):
39+
return self.esxiHost()
40+
41+
def adminStatus(self):
42+
status = self.cacheRRDValue('adminStatus')
43+
if status is not None and not isnan(status):
44+
return int(status)
45+
return None
46+
47+
def operStatus(self):
48+
status = self.cacheRRDValue('operStatus')
49+
if status is not None and not isnan(status):
50+
return int(status)
51+
return None
52+
53+
InitializeClass(ESXiVM)
54+

0 commit comments

Comments
 (0)