Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #53

Merged
merged 2 commits into from
Aug 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/zabbix/contrib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
In this directory you find contributed scripts

in externalscripts: cvpoller-zabbix/vpoller-zabbix both scripts have additional checks
to ensure that when a vcenter server is down or the vpoller-proxy is down the items
get the status: "Not Supported"

This solves the issue of all zabbix agents become unreachable due to vcenter down and the
zabbix queue is getting full.

Requirements for these scripts is that a recent version of `curl` is installed.


68 changes: 68 additions & 0 deletions src/zabbix/contrib/externalscripts/cvpoller-zabbix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env sh
# Simple wrapper script to use with Zabbix and the C client of vPoller

# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

# Initialize our own variables:
whitespace="[[:space:]]"
_vsphere=
_args=''

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

### Processing opts to retrieve vSphere host
while getopts "hvDm:n:p:r:t:e:V:k:U:P:o:H:" opt
do
case "${opt}" in
V) _vsphere=$OPTARG ;;
esac
done
shift $((OPTIND-1))

### Filter the property name out of the args
_property_name=`echo ${_args} | sed -ne 's|.* -p \([a-zA-Z\.]*\)|\1|p'`

### Detect if vcenter SDK is available
_url="https://${_vsphere}/sdk"
_curl_bin=`which curl`
_curl_options="-k"

if [ ! -f $_curl_bin ]
then
echo "ZBX_NOTSUPPORTED no curl"
exit 1
fi

${_curl_bin} ${_curl_options} ${_url} > /dev/null 2>&1

if [ $? -ne 0 ]
then
echo "ZBX_NOTSUPPORTED no SDK"
exit 1
fi

### Detect if vpoller proxy is working:
### Disable this check if the proxy is not running on this host or change the url"
if [ -f /usr/bin/vpoller-proxy ]
then
_running=`/usr/bin/vpoller-proxy -e tcp://localhost:9999 status | grep -w running | wc -l`

if [ $_running -eq 0 ]
then
echo "ZBX_NOTSUPPORTED no vpoller proxy"
exit 1
fi
fi

# Rename property as it might contain dots in the complete property name, so that 'jq' can parse it
sh -c "vpoller-cclient ${_args} 2>/dev/null" | jq -r ".result[0] | {\"property\": .[\"${_property_name}\"]}.property"
55 changes: 55 additions & 0 deletions src/zabbix/contrib/externalscripts/vpoller-zabbix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env sh
# Simple wrapper script to use with Zabbix helper

# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

# Initialize our own variables:
_vsphere=
#_args=$(echo $@ | sed 's@-k [A-Z]:@&\\\\@g')
_args="$@"

### Processing opts to retrieve vSphere host
while getopts "hvDm:n:p:r:t:e:V:k:U:P:o:H:" opt
do
case "${opt}" in
V) _vsphere=$OPTARG ;;
esac
done
shift $((OPTIND-1))

### Detect if vcenter SDK is available
_url="https://${_vsphere}/sdk"
_curl_bin=`which curl`
_curl_options="-k"

if [ ! -f $_curl_bin ]
then
echo "ZBX_NOTSUPPORTED no curl"
exit 1
fi

${_curl_bin} ${_curl_options} ${_url} > /dev/null 2>&1

if [ $? -ne 0 ]
then
echo "ZBX_NOTSUPPORTED no SDK"
exit 1
fi

### Detect if vpoller proxy is working:
### Disable this check if the proxy is not running on this host or change the url"
if [ -f /usr/bin/vpoller-proxy ]
then
_running=`/usr/bin/vpoller-proxy -e tcp://localhost:9999 status | grep -w running | wc -l`

if [ $_running -eq 0 ]
then
echo "ZBX_NOTSUPPORTED no vpoller proxy"
exit 1
fi
fi

### Excute the vpoller-client
#sh -c "vpoller-client -H vpoller.helpers.zabbix ${_args}" | awk '{print $1;}'
vpoller-client -H vpoller.helpers.zabbix ${_args}