Skip to content
This repository has been archived by the owner on Jul 23, 2018. It is now read-only.

Commit

Permalink
Add package files
Browse files Browse the repository at this point in the history
- Added setup.py and manifest
- Code moved into module to allow packaging
- Added version info (required by packaging)
  • Loading branch information
Andrew McIntosh committed Oct 9, 2017
1 parent ca71988 commit a1d23ed
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
include requirements.txt
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Get VMWare VCenter information:

## Usage

- install with `$ python setup.py install` or `$ pip install vmware_exporter`
- Create a `config.yml` file based on the `config.yml.sample` with at least a `default` section.
- Run `$ python vmware_exporter.py`
- Run `$ vmware_exporter -c /path/to/your/config`
- Go to http://localhost:9272/metrics?target=vcenter.company.com to see metrics

Alternatively, if you don't wish to install the package, run using `$ vmware_exporter/vmware_exporter.py`

### Prometheus configuration

You can use the following parameters in prometheus configuration file. The `params` section is used to manage multiple login/passwords.
Expand Down
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from setuptools import setup, find_packages
import vmware_exporter

setup(
name='vmware_exporter',
version=vmware_exporter.__version__,
author=vmware_exporter.__author__,
description='VMWare VCenter Exporter for Prometheus',
long_description=open('README.md').read(),
url='https://github.com/rverchere/vmware_exporter',
download_url=("https://github.com/rverchere/vmware_exporter/tarball/%s" %
vmware_exporter.__version__),
keywords=['VMWare', 'VCenter', 'Prometheus'],
license=vmware_exporter.__license__,
packages=find_packages(exclude=['*.test', '*.test.*']),
include_package_data=True,
install_requires=open('requirements.txt').readlines(),
entry_points={
'console_scripts': [
'vmware_exporter=vmware_exporter.vmware_exporter:main'
]
}
)
3 changes: 3 additions & 0 deletions vmware_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__ = "0.1.0"
__author__ = "Remi Verchere"
__license__ = "BSD 3-Clause License"
20 changes: 11 additions & 9 deletions vmware_exporter.py → vmware_exporter/vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys
import time

from argparse import ArgumentParser
from datetime import datetime
from yamlconfig import YamlConfig

Expand All @@ -36,7 +35,7 @@ class VMWareMetricsResource(Resource):
"""
isLeaf = True

def __init__(self):
def __init__(self, args):
try:
self.config = YamlConfig(args.config_file)
if 'default' not in self.config.keys():
Expand Down Expand Up @@ -419,21 +418,24 @@ def _vmware_get_hosts(self, content, host_metrics):
float(summary.hardware.memorySize) / 1024 / 1024)



if __name__ == '__main__':
parser = ArgumentParser(description='VMWare metrics exporter for Prometheus')
def main():
parser = argparse.ArgumentParser(description='VMWare metrics exporter for Prometheus')
parser.add_argument('-c', '--config', dest='config_file',
default='config.yml', help="configuration file")
parser.add_argument('-p', '--port', dest='port', type=int,
default=9272, help="HTTP port to expose metrics")

args = parser.parse_args(sys.argv[1:])
args = parser.parse_args()

# Start up the server to expose the metrics.
root = Resource()
root.putChild(b'metrics', VMWareMetricsResource())
root.putChild(b'metrics', VMWareMetricsResource(args))

factory = Site(root)
print("Starting web server on port {}".format(args.port))
reactor.listenTCP(args.port, factory)
reactor.run()
#reactor.listenTCP(args.port, factory)
#reactor.run()


if __name__ == '__main__':
main()

0 comments on commit a1d23ed

Please sign in to comment.