Skip to content

Commit

Permalink
Let's call it "vPoller" with a "v" as in "vSphere"
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Jan 6, 2014
1 parent 6cf6a58 commit 76e4a12
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 147 deletions.
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from distutils.core import setup

setup(name='vmware-zabbix',
setup(name='py-vpoller',
version='1.0.0',
description='VMware poller module for integration with Zabbix',
description='VMware vSphere Distributed Pollers',
author='Marin Atanasov Nikolov',
author_email='dnaeon@gmail.com',
license='BSD',
packages=['vmpoller'],
packages=['vpoller'],
package_dir={'': 'src'},
scripts=[
'src/vmpoller-client',
'src/vmpoller-proxy',
'src/vmpoller-worker'
'src/vpoller-client',
'src/vpoller-proxy',
'src/vpoller-worker'
],
install_requires=[
'pysphere >= 0.1.8',
'vmconnector >= 1.0.0',
'vconnector >= 0.1.0',
'pyzmq >= 13.1.0',
'docopt >= 0.6.1',
]
Expand Down
12 changes: 6 additions & 6 deletions src/init.d/vmpoller-proxy → src/init.d/vpoller-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# Author: Marin Atanasov Nikolov <dnaeon@gmail.com>
#
### BEGIN INIT INFO
# Provides: vmpoller-proxy
# Provides: vpoller-proxy
# Required-Start:
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: VMPoller Proxy daemon
# Short-Description: vPoller Proxy daemon
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
DESC="vmpoller-proxy daemon"
NAME=vmpoller-proxy
DAEMON=/usr/local/bin/vmpoller-proxy
DESC="vpoller-proxy daemon"
NAME=vpoller-proxy
DAEMON=/usr/local/bin/vpoller-proxy
SCRIPTNAME=/etc/init.d/"$NAME"
MGMT_INTERFACE="tcp://localhost:9999"

set -e

# /etc/init.d/vmpoller-proxy: start and stop the VMPoller Proxy daemon
# /etc/init.d/vpoller-proxy: start and stop the vPoller Proxy daemon

. /lib/lsb/init-functions

Expand Down
12 changes: 6 additions & 6 deletions src/init.d/vmpoller-worker → src/init.d/vpoller-worker
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# Author: Marin Atanasov Nikolov <dnaeon@gmail.com>
#
### BEGIN INIT INFO
# Provides: vmpoller-worker
# Provides: vpoller-worker
# Required-Start:
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: VMPoller Worker daemon
# Short-Description: VPoller Worker daemon
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
DESC="vmpoller-worker daemon"
NAME=vmpoller-worker
DAEMON=/usr/local/bin/vmpoller-worker
DESC="vpoller-worker daemon"
NAME=vpoller-worker
DAEMON=/usr/local/bin/vpoller-worker
SCRIPTNAME=/etc/init.d/"$NAME"
MGMT_INTERFACE="tcp://localhost:10000"

set -e

# /etc/init.d/vmpoller-worker: start and stop the VMPoller Worker daemon
# /etc/init.d/vpoller-worker: start and stop the VPoller Worker daemon

. /lib/lsb/init-functions

Expand Down
4 changes: 2 additions & 2 deletions src/tests/request-simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ TOTAL_REQUESTS=1000

let i=0
while [[ ${i} -lt ${TOTAL_REQUESTS} ]]; do
running=$( ps -ef | grep vmpoller-client | grep -v grep | wc -l )
running=$( ps -ef | grep vpoller-client | grep -v grep | wc -l )

# Fire up another request if needed
if [[ ${running} -lt ${MAX_REQUESTS} ]]; then
echo "I: Firing up request ${i} ..."
./vmpoller-client -D -n esx1-evn1_local0 -p summary.capacity -u ds:///vmfs/volumes/4c68dc48-0db9ca38-f0e0-78e7d1e5782e/ -c poll -V vc1-sof2 > /dev/null 2>&1 &
vpoller-client -D -n esx1-evn1_local0 -p summary.capacity -u ds:///vmfs/volumes/4c68dc48-0db9ca38-f0e0-78e7d1e5782e/ -c poll -V vc1-sof2 > /dev/null 2>&1 &
let i++
fi
done
17 changes: 0 additions & 17 deletions src/vmpoller-cclient/Makefile

This file was deleted.

17 changes: 17 additions & 0 deletions src/vpoller-cclient/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CC = gcc
IDIR = /usr/local/include
LDIR = /usr/local/lib
LIBS = -lzmq
CFLAGS = -I${IDIR} -L${LDIR}

all: vpoller_cclient_clean vpoller_cclient

clean: vpoller_cclient_clean

vpoller_cclient:
$(CC) $(CFLAGS) vpoller-cclient.c -o vpoller-cclient $(LIBS)

vpoller_cclient_clean:
@rm -rf vpoller-cclient
@echo "Cleaning target vpoller-cclient"

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


/*
* vmpoller-cclient is a C client intended to be used for polling/discovering
* vpoller-cclient is a C client intended to be used for polling/discovering
* information from a vSphere host (ESX or vCenter server).
*
* It works by sending a ZeroMQ message to a ZeroMQ Broker/Proxy which in turn
Expand All @@ -46,19 +46,19 @@

#include <zmq.h>

#include "vmpoller-cclient.h"
#include "vpoller-cclient.h"

void
usage(void)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, " vmpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] (-D|-H)\n");
fprintf(stderr, " vpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] (-D|-H)\n");
fprintf(stderr, " -c discover -V <vcenter>\n");
fprintf(stderr, " vmpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] -H\n");
fprintf(stderr, " vpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] -H\n");
fprintf(stderr, " -n <name> -p <property> -c poll -V <vcenter>\n");
fprintf(stderr, " vmpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] -D\n");
fprintf(stderr, " vpoller-cclient [-r <retries>] [-t <timeout>] [-e <endpoint>] -D\n");
fprintf(stderr, " -u <datastore-url> -p <property> -c poll -V <vcenter>\n");
fprintf(stderr, " vmpoller-cclient -h\n\n");
fprintf(stderr, " vpoller-cclient -h\n\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, " -h Display this usage info\n");
fprintf(stderr, " -D Retrieve a datastore object property\n");
Expand All @@ -73,9 +73,9 @@ usage(void)
fprintf(stderr, " -e <endpoint> Endpoint of ZeroMQ Proxy/Broker the client connects to\n");
fprintf(stderr, " [default: tcp://localhost:10123]\n\n");
fprintf(stderr, "Example usage for discovering datastores on a vCenter:\n\n");
fprintf(stderr, " $ vmpoller-cclient -D -c discover -V vc1.example.org\n\n");
fprintf(stderr, " $ vpoller-cclient -D -c discover -V vc1.example.org\n\n");
fprintf(stderr, "Example usage for retrieving a property of an ESX host:\n\n");
fprintf(stderr, " $ vmpoller-cclient -H -c poll -V sof-vc0-mnik -p runtime.bootTime -n esx1.example.org\n");
fprintf(stderr, " $ vpoller-cclient -H -c poll -V sof-vc0-mnik -p runtime.bootTime -n esx1.example.org\n");
}

int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef _VMPOLLER_CCLIENT_H_
#define _VMPOLLER_CCLIENT_H_
#ifndef _VPOLLER_CCLIENT_H_
#define _VPOLLER_CCLIENT_H_

#define DEFAULT_TIMEOUT 3000 /* Timeout is in msec */
#define DEFAULT_RETRIES 3 /* Number of retries before giving up */
#define DEFAULT_ENDPOINT "tcp://localhost:10123" /* Default endpoint we connect to */

void usage(void);

#endif /* !_VMPOLLER_CCLIENT_H_ */
#endif /* !_VPOLLER_CCLIENT_H_ */
22 changes: 11 additions & 11 deletions src/vmpoller-client → src/vpoller-client
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""
vmpoller-client is an application used for polling objects' information from a VMware vCenter server.
vpoller-client is an application used for polling objects' information from a VMware vCenter server.
It is intended to be integrated into a Zabbix template for polling of ESX hosts and Datastores properties.
"""

import sys
import logging

from vmpoller.core import VMPollerClient
from vpoller.core import VPollerClient
from docopt import docopt

def main():

usage="""
Usage:
vmpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] (-D|-H) -c discover -V <vcenter> -e <endpoint>
vmpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -H -n <name> -p <property> -c poll -V <vcenter> -e <endpoint>
vmpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -D -u <datastore-url> -p <property> -c poll -V <vcenter> -e <endpoint>
vmpoller-client --help
vmpoller-client --version
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] (-D|-H) -c discover -V <vcenter> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -H -n <name> -p <property> -c poll -V <vcenter> -e <endpoint>
vpoller-client [-r <retries>] [-t <timeout>] [-o <logfile>] -D -u <datastore-url> -p <property> -c poll -V <vcenter> -e <endpoint>
vpoller-client --help
vpoller-client --version
Options:
-h, --help Display this usage info
Expand All @@ -61,22 +61,22 @@ Options:
-e <endpoint>, --endpoint <endpoint> Endpoint of ZeroMQ Proxy/Broker the client connects to
[default: tcp://localhost:10123]
-o <logfile>, --output <logfile> Specify the log file to use when performing the poll
[default: /var/log/vmpoller/vmpoller-client.log]
[default: /var/log/vpoller/vpoller-client.log]
"""

args = docopt(usage, version="1.0.0")

if args["--output"] == "-":
logging.basicConfig(stream=sys.stdout,
format='%(asctime)s - %(levelname)s - vmpoller-client[%(process)s]: %(message)s',
format='%(asctime)s - %(levelname)s - vpoller-client[%(process)s]: %(message)s',
level=logging.DEBUG)
else:
logging.basicConfig(filename=args["--output"],
format='%(asctime)s - %(levelname)s - vmpoller-client[%(process)s]: %(message)s',
format='%(asctime)s - %(levelname)s - vpoller-client[%(process)s]: %(message)s',
level=logging.DEBUG)

client = VMPollerClient(endpoint=args["--endpoint"], retries=int(args["--retries"]), timeout=int(args["--timeout"]))
client = VPollerClient(endpoint=args["--endpoint"], retries=int(args["--retries"]), timeout=int(args["--timeout"]))

msg = { "type": "hosts" if args["--hosts"] else "datastores",
"vcenter": args["--vcenter"],
Expand Down
44 changes: 22 additions & 22 deletions src/vmpoller-proxy → src/vpoller-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""
vmpoller-proxy is a ZeroMQ proxy/broker that load balances requests
vpoller-proxy is a ZeroMQ proxy/broker that load balances requests
between a pool of ZeroMQ workers.
"""

import sys
import logging

from vmpoller.core import VMPollerProxy, VMPollerClient
from vpoller.core import VPollerProxy, VPollerClient
from docopt import docopt

def start(pidfile, config, daemon):
"""
Start the VMPoller Proxy daemon
Start the VPoller Proxy daemon
Args:
pidfile (string): Location to the daemon's pidfile
config (string): Configuration file of the VMPoller Proxy
daemon (bool): If True daemonize the VMPoller Proxy
config (string): Configuration file of the VPoller Proxy
daemon (bool): If True daemonize the VPoller Proxy
"""
proxy = VMPollerProxy(pidfile)
proxy = VPollerProxy(pidfile)

if daemon:
# Run as daemon
Expand All @@ -57,7 +57,7 @@ def start(pidfile, config, daemon):

def stop(endpoint):
"""
Stops the VMPoller Proxy daemon
Stops the VPoller Proxy daemon
Args:
endpoint (string): The endpoint we send the shutdown message to
Expand All @@ -67,14 +67,14 @@ def stop(endpoint):
msg = { "cmd": "shutdown" }

# Send out our message
client = VMPollerClient(endpoint=endpoint, timeout=1000, retries=3)
client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3)
result = client.run(msg)

print result

def status(endpoint):
"""
Get status information from the VMPoller Proxy daemon
Get status information from the VPoller Proxy daemon
Args:
endpoint (string): The endpoint we send the status message to
Expand All @@ -84,23 +84,23 @@ def status(endpoint):
msg = { "cmd": "status" }

# Send out our message
client = VMPollerClient(endpoint=endpoint, timeout=1000, retries=3)
client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3)
result = client.run(msg)

print result

def main():

usage="""
Usage: vmpoller-proxy [-d] [-p <pidfile>] [-f <config-file>] [-o <logfile>] start
vmpoller-proxy -e <endpoint> stop
vmpoller-proxy -e <endpoint> status
vmpoller-proxy --help
vmpoller-proxy --version
Usage: vpoller-proxy [-d] [-p <pidfile>] [-f <config-file>] [-o <logfile>] start
vpoller-proxy -e <endpoint> stop
vpoller-proxy -e <endpoint> status
vpoller-proxy --help
vpoller-proxy --version
Arguments:
start Start the VMPoller Proxy
stop Stop the VMPoller Proxy
start Start the VPoller Proxy
stop Stop the VPoller Proxy
status Get status information
Options:
Expand All @@ -109,24 +109,24 @@ Options:
-d, --daemon Start as a daemon, otherwise
run in the foreground
-p <pidfile>, --pidfile <pidfile> Specify pidfile file to use
[default: /var/run/vmpoller/vmpoller-proxy.pid]
[default: /var/run/vpoller/vpoller-proxy.pid]
-f <config-file>, --config <config-file> Specify config file to use
[default: /etc/vmpoller/vmpoller-proxy.conf]
[default: /etc/vpoller/vpoller-proxy.conf]
-e <endpoint>, --endpoint <endpoint> Specify the endpoint we connect to
-o <logfile>, --output <logfile> Specify the logfile to use
[default: /var/log/vmpoller/vmpoller-proxy.log]
[default: /var/log/vpoller/vpoller-proxy.log]
"""

args = docopt(usage, version="1.0.0")

if args["--output"] == "-":
logging.basicConfig(stream=sys.stdout,
format='%(asctime)s - %(levelname)s - vmpoller-proxy[%(process)s]: %(message)s',
format='%(asctime)s - %(levelname)s - vpoller-proxy[%(process)s]: %(message)s',
level=logging.DEBUG)
else:
logging.basicConfig(filename=args["--output"],
format='%(asctime)s - %(levelname)s - vmpoller-proxy[%(process)s]: %(message)s',
format='%(asctime)s - %(levelname)s - vpoller-proxy[%(process)s]: %(message)s',
level=logging.DEBUG)

if args["start"]:
Expand Down
Loading

0 comments on commit 76e4a12

Please sign in to comment.