Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created January 9, 2013 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdoye/4494435 to your computer and use it in GitHub Desktop.
Save nicdoye/4494435 to your computer and use it in GitHub Desktop.
Init script for Greenplum 4 SNMP subagent for RHEL 5 Fork it and fix it for SLES, RHEL 6. You could also get it to work with .pgpass (as mentioned in the admin guide - didn't work here, so I put them in the file).
#!/bin/sh
#
# gpsnmpd: Provides the Greenplum SNMP as a sub-agent
#
# chkconfig: 35 99 01
# description: gpsnmpd is the GP Software agent for SNMP
#
#
# Sanity checks.
[ -x /usr/local/greenplum-db/bin/gpsnmpd ] || exit 0
# Source function library.
. /etc/rc.d/init.d/functions
GPSNMPD_USER=gpadmin
GPSNMPD_GROUP=gpadmin
AGENTX_SOCKET=/var/agentx/master
start() {
echo -n $"Starting Greenplum SNMP Agent: "
AGENTX_DIRECTORY=$(dirname ${AGENTX_SOCKET})
if [ -d ${AGENTX_DIRECTORY} ]
then
if [ -S ${AGENTX_SOCKET} ]
then
chgrp ${GPSNMPD_GROUP} ${AGENTX_SOCKET}
chmod g+w ${AGENTX_SOCKET}
/bin/su - gpadmin -c '/usr/local/greenplum-db/bin/gpsnmpd -s -b -C "host=localhost dbname=postgres user=XXXXXXXX password=XXXXXXXX"'
echo_success
else
echo_failure
fi
else
# Note - if this is the first time snmpd has run, it's too late
# to create the socket directory
mkdir -p ${AGENTX_DIRECTORY}
echo_failure
echo "Now created agentx socket directory"
echo "Please restart snmpd"
echo "then start gpsnmpd"
fi
echo
}
stop() {
/sbin/fuser -k /usr/local/greenplum-db/bin/gpsnmpd
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment