Skip to content

Commit

Permalink
Merge pull request #38 from blackcobra1973/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dnaeon committed Aug 22, 2014
2 parents 89f5b9c + f9c9cb6 commit 9ee42c4
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 2 deletions.
58 changes: 58 additions & 0 deletions README.gentoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Dependencies:

- Make sure you have python 2.7 installed on your system

- Unmask the following packages:

net-libs/zeromq
dev-libs/libsodium (required for version 4.x of zeromq)
dev-python/docopt
dev-python/tabulate

- Emerge the packages:

emerge pyzmq docopt tabulate zeromq jq

- Switch to python 2.7 to install the manually requirements for the right python or use the right python binary.

- Install pyVmomi

git clone https://github.com/vmware/pyvmomi.git

cd pyvmomi
python2.7 setup.py install

- Install pv-vconnector

git clone https://github.com/dnaeon/py-vconnector.git

cd py-vconnector
python2.7 setup.py install

- Create needed directories:

mkdir /var/lib/vconnector /var/log/vpoller /var/log/vconnector /etc/vpoller /var/run/vpoller

- Install py-vpoller

git clone https://github.com/blackcobra1973/py-vpoller.git

cd py-vpoller
python2.7 setup.py install

cp src/conf/vpoller.conf /etc/vpoller/

- Compile the c-client

cd src/vpoller-cclient/
make
mv vpoller-cclient /usr/local/bin/

- Install init scripts

cp src/init.d/vpoller-proxy.gentoo /etc/init.d/vpoller-proxy
cp src/init.d/vpoller-worker.gentoo /etc/init.d/vpoller-worker

- Install the logrotate template

cp src/logrotate.d/vpoller /etc/logrotate.d/
9 changes: 9 additions & 0 deletions src/conf/vpoller.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[proxy]
frontend = tcp://*:10123
backend = tcp://*:10124
mgmt = tcp://*:9999

[worker]
db = /var/lib/vconnector/vconnector.db
proxy = tcp://localhost:10124
mgmt = tcp://*:10000
57 changes: 57 additions & 0 deletions src/init.d/vpoller-proxy.gentoo
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

. /etc/init.d/functions.sh

extra_started_commands="fullstatus"

description_fullstatus="Gives the full status of the server."

DESC="vpoller-proxy daemon"
DAEMON=/usr/bin/vpoller-proxy
MGMT_INTERFACE="tcp://localhost:9999"
CONF_DIR=/etc/vpoller
CONF_FILE=${CONF_DIR}/vpoller.conf
PID_DIR=/var/run/vpoller
LOG_DIR=/var/log/vpoller

depend() {
use logger net
}

checkconfig() {
checkpath --directory -m 0755 -o zabbix:zabbix ${PID_DIR}
checkpath --directory -m 0755 -o zabbix:zabbix ${LOG_DIR}
}

start() {
checkconfig || return 1

ebegin "Starting ${DESC}"
if [ ! -d ${CONF_DIR} ]; then
eend 1 "${CONF_DIR} does not exist"
return 1
fi
if [ ! -f ${CONF_FILE} ]; then
eend 1 "${CONF_FILE} does not exist"
return 1
fi
# $DAEMON -d start >/dev/null 2>&1
start-stop-daemon --start --quiet \
--user zabbix --group zabbix \
--exec ${DAEMON} -- \
-d start
eend $?
}

stop() {
ebegin "Stopping ${DESC}"
${DAEMON} -e ${MGMT_INTERFACE} stop >/dev/null 2>&1
eend
}

fullstatus() {
${DAEMON} -e ${MGMT_INTERFACE} status
}

58 changes: 58 additions & 0 deletions src/init.d/vpoller-worker.gentoo
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

. /etc/init.d/functions.sh

extra_started_commands="fullstatus"

description_fullstatus="Gives the full status of the server."

DESC="vpoller-worker daemon"
DAEMON=/usr/bin/vpoller-worker
MGMT_INTERFACE="tcp://localhost:10000"
CONF_DIR=/etc/vpoller
CONF_FILE=${CONF_DIR}/vpoller.conf
PID_DIR=/var/run/vpoller
LOG_DIR=/var/log/vpoller

depend() {
use logger net
after vpoller-proxy
}

checkconfig() {
checkpath --directory -m 0755 -o zabbix:zabbix ${PID_DIR}
checkpath --directory -m 0755 -o zabbix:zabbix ${LOG_DIR}
}

start() {
checkconfig || return 1

ebegin "Starting ${DESC}"
if [ ! -d ${CONF_DIR} ]; then
eend 1 "${CONF_DIR} does not exist"
return 1
fi
if [ ! -f ${CONF_FILE} ]; then
eend 1 "${CONF_FILE} does not exist"
return 1
fi
# $DAEMON -d start >/dev/null 2>&1
start-stop-daemon --start --quiet \
--user zabbix --group zabbix \
--exec ${DAEMON} -- \
-d start
eend $?
}

stop() {
ebegin "Stopping ${DESC}"
${DAEMON} -e ${MGMT_INTERFACE} stop >/dev/null 2>&1
eend
}

fullstatus() {
${DAEMON} -e ${MGMT_INTERFACE} status
}

17 changes: 17 additions & 0 deletions src/logrotate.d/vpoller
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/logrotate.mysql,v 1.2 2011/01/13 20:06:06 robbat2 Exp $

/var/log/vpoller/*.log {
# rotate 4
# monthly
# compress
create 640 zabbix zabbix
notifempty
size 5M
sharedscripts
postrotate
[ -f /etc/init.d/vpoller-proxy ] && /etc/init.d/vpoller-proxy restart > /dev/null 2>&1
[ -f /etc/init.d/vpoller-worker ] && /etc/init.d/vpoller-worker restart > /dev/null 2>&1
endscript
}
17 changes: 15 additions & 2 deletions src/zabbix/cvpoller-zabbix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@

# Simple wrapper script to use with Zabbix and the C client of vPoller

_args="$@"
whitespace="[[:space:]]"
_args=''

### Process variables with spaces in
for i in "$@"
do
if [[ $i =~ $whitespace ]]
then
_args="${_args} \"$i\""
else
_args="${_args} $i"
fi
done

_property_name=`echo ${_args} | sed -ne 's|.* -p \([a-zA-Z\.]*\)|\1|p'`

# Rename property as it might contain dots in the complete property name, so that 'jq' can parse it
vpoller-cclient ${_args} 2>/dev/null | jq -r ".result[0] | {\"property\": .[\"${_property_name}\"]}.property"
sh -c "vpoller-cclient ${_args} 2>/dev/null" | jq -r ".result[0] | {\"property\": .[\"${_property_name}\"]}.property"

0 comments on commit 9ee42c4

Please sign in to comment.