{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/comments/36997637","id":36997637,"diff_hunk":"@@ -0,0 +1,572 @@\n+#!/bin/sh\n+#  License:      GNU General Public License (GPL)\n+#        (c) 2015 T.J. Yang  and Linux-HA contributors\n+# -----------------------------------------------------------------------------\n+#      O C F    R E S O U R C E    S C R I P T   S P E C I F I C A T I O N\n+# -----------------------------------------------------------------------------\n+#\n+# NAME\n+#       nagios4 : OCF resource agent script for Nagios 4 Server\n+#\n+# REVISION HISTORY\n+#       04/15/2015    T.J. Yang   Adding     moto bash script specification\n+#       07/01/2015    T.J. Yang   submitted to https://github.com/ClusterLabs/resource-agents \n+#\n+# USAGE\n+#   1. put this script in OCF resource directory(/usr/lib/ocf/resource.d/heartbeat/nagios4)\n+#\n+# DEBUG    \n+#\n+# OCF_ROOT=/usr/lib/ocf /usr/lib/ocf/resource.d/heartbeat/nagios4\n+#\n+# DESCRIPTION\n+#       \n+#\n+# OPTIONS\n+#\n+#\n+# RETURN CODE\n+#     OCF_SUCCESS (0)\n+#     OCF_ERR_GENERIC (1)\n+#     OCF_ERR_ARGS (2)\n+#     OCF_ERR_UNIMPLEMENTED (3)\n+#     OCF_ERR_PERM (4)\n+#     OCF_ERR_INSTALLED (5)\n+#     OCF_ERR_CONFIGURED (6)\n+#     OCF_NOT_RUNNING (7)\n+#     OCF_RUNNING_MASTER (8)\n+#     OCF_FAILED_MASTER (9)\n+#\n+#  REFERENCE:\n+#   1. http://www.linux-ha.org/doc/dev-guides/ra-dev-guide.html\n+#   2. TBC: link to an old OCF script for Nagios 3\n+#\n+# ---------------------------- CONSTANT DECLARATION ---------------------------\n+# WHAT: Define exit status flags.\n+# WHY:  Easier to program with a mnemonic than with the numbers.\n+#     OCF_SUCCESS (0)\n+#     OCF_ERR_GENERIC (1)\n+#     OCF_ERR_ARGS (2)\n+#     OCF_ERR_UNIMPLEMENTED (3)\n+#     OCF_ERR_PERM (4)\n+#     OCF_ERR_INSTALLED (5)\n+#     OCF_ERR_CONFIGURED (6)\n+#     OCF_NOT_RUNNING (7)\n+#     OCF_RUNNING_MASTER (8)\n+#     OCF_FAILED_MASTER (9)\n+       \n+\n+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}\n+#[root@nagios1 heartbeat]# locate  .ocf-shellfuncs\n+#/usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs\n+#[root@nagios1 heartbeat]#\n+#\n+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs\n+# Fill in some defaults if no values are specified\n+# cutomized for CentOS 7.1, Nagios 3.5.1\n+: ${OCF_RESKEY_installdir=\"/usr/bin\"}\n+: ${OCF_RESKEY_vardir=\"/var/nagios\"}\n+: ${OCF_RESKEY_binary=\"/usr/bin/nagios\"}\n+: ${OCF_RESKEY_cgidir=\"/usr/lib64/nagios/cgi-bin\"}\n+NAGIOS_BINDIR=`dirname ${OCF_RESKEY_binary}`\n+: ${OCF_RESKEY_config=\"/etc/nagios/nagios.cfg\"}\n+: ${OCF_RESKEY_statusfile=\"/var/nagios/status.dat\"}\n+: ${OCF_RESKEY_statuslog=\"/var/nagios/livestatus.log\"}\n+: ${OCF_RESKEY_tempfile=\"/var/nagios/nagios.tmp*\"}\n+: ${OCF_RESKEY_retentionfile=\"/var/nagios/retention.dat\"}\n+: ${OCF_RESKEY_commandfile=\"/var/nagios/cmd/nagios.cmd\"}\n+: ${OCF_RESKEY_tempfile=\"/var/nagios/nagios.tmp\"}\n+: ${OCF_RESKEY_plugindir=\"/usr/lib64/nagios/plugins\"}\n+: ${OCF_RESKEY_user=\"nagios\"}\n+: ${OCF_RESKEY_group=\"nagios\"}\n+: ${OCF_RESKEY_PidFile=\"/var/nagios/nagios.pid\"}\n+\n+OCF_RESKEY_PidFile=\"/var/nagios/nagios.pid\"\n+\n+#\n+# ---------------------------- VARIABLE DECLARATION ---------------------------\n+\n+\n+# ---------------------------- FUNCTION DECLARATION ---------------------------\n+# WHAT: define usage function.\n+# WHY:  to advise the usage of this script.\n+# NOTE: \n+nagios_usage() {\n+  cat <<USAGEND\n+    usage: $0 (start|stop|validate-all|meta-data|help|usage|monitor)\n+    $0 manages a nagios instance as an OCF HA resource.\n+    The 'start' operation starts the instance.\n+    The 'stop' operation stops the instance.\n+    The 'status' operation reports whether the instance is running\n+    The 'monitor' operation reports whether the instance seems to be working\n+    The 'validate-all' operation reports whether the parameters are valid\n+USAGEND\n+}\n+\n+# WHAT: Define meta data to describe Nagios service for pacemaker.\n+# WHY:  OCF script requirement.\n+nagios_meta_data() {\n+        cat <<END\n+<?xml version=\"1.0\"?>\n+<!DOCTYPE resource-agent SYSTEM \"ra-api-1.dtd\">\n+<resource-agent name=\"nagios\">\n+<version>0.75</version>\n+\n+<longdesc lang=\"en\">OCF Resource script for nagios 3.x or 4.x. It manages a nagios instance as an HA resource.</longdesc>\n+<shortdesc lang=\"en\">nagios resource agent</shortdesc>\n+\n+<parameters>\n+\n+<parameter name=\"installdir\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Root directory of the nagios installation</longdesc>\n+\t<shortdesc lang=\"en\">nagios install directory</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios\" />\n+</parameter>\n+\n+<parameter name=\"vardir\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">var directory of the nagios installation</longdesc>\n+\t<shortdesc lang=\"en\">nagios var directory</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var\" />\n+</parameter>\n+\n+<parameter name=\"cgidir\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">cgi directory of the nagios installation</longdesc>\n+\t<shortdesc lang=\"en\">nagios cgi directory</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/sbin\" />\n+</parameter>\n+\n+<parameter name=\"binary\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Location of the nagios binary</longdesc>\n+\t<shortdesc lang=\"en\">nagios binary</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/bin/nagios\" />\n+</parameter>\n+\n+<parameter name=\"config\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Configuration file</longdesc>\n+\t<shortdesc lang=\"en\">nagios config</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/etc/nagios.cfg\" />\n+</parameter>\n+\n+<parameter name=\"user\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">User running nagios daemon</longdesc>\n+\t<shortdesc lang=\"en\">nagios user</shortdesc>\n+\t<content type=\"string\" default=\"nagios\" />\n+</parameter>\n+\n+<parameter name=\"group\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Group running nagios daemon (for logfile and directory permissions)</longdesc>\n+\t<shortdesc lang=\"en\">nagios group</shortdesc>\n+\t<content type=\"string\" default=\"nagios\"/>\n+</parameter>\n+\n+<parameter name=\"statusfile\" unique=\"1\" required=\"0\">\n+\t<longdesc lang=\"en\">Location of the nagios status file</longdesc>\n+\t<shortdesc lang=\"en\">nagios statusfile</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/status.dat\" />\n+</parameter>\n+\n+<parameter name=\"statuslog\" unique=\"1\" required=\"0\">\n+\t<longdesc lang=\"en\">Location of the nagios status log</longdesc>\n+\t<shortdesc lang=\"en\">nagios statuslog</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/status.log\" />\n+</parameter>\n+\n+<parameter name=\"tempfile\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Location of the nagios temporary file</longdesc>\n+\t<shortdesc lang=\"en\">nagios tempfile</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/nagios.tmp\" />\n+</parameter>\n+\n+<parameter name=\"retentionfile\" unique=\"1\" required=\"0\">\n+\t<longdesc lang=\"en\">Location of the nagios retention file</longdesc>\n+\t<shortdesc lang=\"en\">nagios retention file</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/retention.dat\" />\n+</parameter>\n+\n+<parameter name=\"commandfile\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Location of the nagios external command file</longdesc>\n+\t<shortdesc lang=\"en\">nagios command file</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/rw/nagios.cmd\" />\n+</parameter>\n+\n+<parameter name=\"plugindir\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Location of the nagios plugins</longdesc>\n+\t<shortdesc lang=\"en\">nagios plugins location</shortdesc>\n+\t<content type=\"string\" default=\"/usr/lib/nagios/plugins\" />\n+</parameter>\n+\n+<parameter name=\"pid\" unique=\"1\" required=\"1\">\n+\t<longdesc lang=\"en\">Location of the nagios pid/lock</longdesc>\n+\t<shortdesc lang=\"en\">nagios pid file</shortdesc>\n+\t<content type=\"string\" default=\"/usr/local/nagios/var/nagios.lock\" />\n+</parameter>\n+\n+</parameters>\n+\n+<actions>\n+<action name=\"start\" timeout=\"120\" />\n+<action name=\"stop\" timeout=\"120\" />\n+<action name=\"status\" timeout=\"60\" />\n+<action name=\"monitor\" depth=\"0\" timeout=\"30\" interval=\"10\" start-delay=\"10\" />\n+<action name=\"validate-all\" timeout=\"5\" />\n+<action name=\"meta-data\" timeout=\"5\" />\n+</actions>\n+</resource-agent>\n+END\n+}\n+\n+\n+# WHAT: Validate all the config is correct.\n+# WHY:  \n+# NOTE: \n+\n+#foobar_validate_all() {\n+#    # Test for configuration errors first\n+#    if ! ocf_is_decimal $OCF_RESKEY_eggs; then\n+#       ocf_log err \"eggs is not numeric!\"\n+#       exit $OCF_ERR_CONFIGURED\n+#    fi\n+#\n+#    # Test for required binaries\n+#    check_binary frobnicate\n+#\n+#    # Check for data directory (this may be on shared storage, so\n+#    # disable this test during probes)\n+#    if ! ocf_is_probe; then\n+#       if ! [ -d $OCF_RESKEY_datadir ]; then\n+#          ocf_log err \"$OCF_RESKEY_datadir does not exist or is not a directory!\"\n+#          exit $OCF_ERR_INSTALLED\n+#       fi\n+#    fi\n+#\n+#    return $OCF_SUCCESS\n+#}\n+\n+# TODO: change the login to above sample code, the logic is better.\n+# WHAT: a series of check to ensure current node has all the needed configuration.\n+nagios_validate_all(){\n+    ocf_log debug \"nagios_validate_all: checking all the config files\"\n+    # Check that nagios binary exists.\n+    if [ ! -f ${OCF_RESKEY_binary} ]; then\n+        ocf_log debug \"nagios_validate_all: Executable file ${OCF_RESKEY_binary} not found.  Exiting.\"\n+        exit ${OCF_ERR_GENERIC}\n+    fi\n+    \n+    # Check that configuration file exists.\n+    if [ ! -f ${OCF_RESKEY_config} ]; then\n+         ocf_log debug \"nagios_validate_all: Configuration file ${OCF_RESKEY_config} not found.  Exiting.\"\n+        exit ${OCF_ERR_GENERIC}\n+    fi\n+    \n+    # check for plugin installation\n+    if [ ! -d ${OCF_RESKEY_plugindir} ]; then\n+    \t ocf_log debug \"nagios_validate_all: Plugins do not seem to be installed\"\n+    \t ocf_log debug \"nagios_validate_all: installation location should be: ${OCF_RESKEY_plugindir}\"\n+    \texit ${OCF_ERR_GENERIC}\n+    fi\n+    # run nagios config check\n+\t ocf_log debug \"nagios_validate_all: running ${OCF_RESKEY_binary} -v ${OCF_RESKEY_config}\"\n+    ${OCF_RESKEY_binary} -v ${OCF_RESKEY_config} > /dev/null 2>&1;\n+\tif [ $? != \"0\" ]; then\n+   \t ocf_log debug \"nagios_validate_all: running ${OCF_RESKEY_binary} -v ${OCF_RESKEY_config}\"\n+    \t   return ${OCF_ERR_GENERIC}\n+\tfi\n+}\n+\n+nagios_monitor(){\n+    local rc\n+    # exit immediately if configuration is not valid\n+    # nagios_validate_all || exit $?\n+    # test if nagios is running.\n+    get_nagios_status\n+    case \"$?\" in\n+        0)\n+            rc=$OCF_SUCCESS\n+            ocf_log debug \"monitor: Resource is running\"\n+            ;;\n+        1)\n+            rc=$OCF_NOT_RUNNING\n+            ocf_log debug \"monitor: Resource is not running\"\n+            ;;\n+        *)\n+            ocf_log err \"monitor: Resource has failed\"\n+            exit $OCF_ERR_GENERIC\n+    esac\n+    return $rc\n+}\n+\n+# WHAT: return TRUE if a process with given PID is running\n+# NOTE: input process id\n+#       output true or false \n+ProcessRunning() {\n+\tocf_log debug  \"start: calling ProcessRunning \"\n+\tRunningPID=$1\n+\t# Use /proc if it looks like it's here...\n+\tif [ -d /proc -a -d /proc/1 ]; then\n+\t\t[ -d /proc/$RunningPID ]\n+\telse\n+\t\t# This assumes we're running as root...\n+\t\tkill -s 0 \"$RunningPID\" >/dev/null 2>&1\n+\tfi\n+}\n+\n+silent_status() {\n+\tocf_log debug  \"start: calling silent_status \"\n+\tlocal OCF_RESKEY_PidFile=\"/var/nagios/nagios.pid\"\n+\tif [ -f $OCF_RESKEY_PidFile ]; then\n+\t    local PID=`cat $OCF_RESKEY_PidFile`\n+\tocf_log debug  \"start: calling silent_status in if pid=$PID  \"\n+            ProcessRunning `cat $OCF_RESKEY_PidFile`\n+\telse\n+\tocf_log debug  \"start: calling silent_status in ELSE  pid=$PID  \"\n+\t\t: No pid file\n+\t\tfalse\n+\tfi\n+}\n+\n+\n+# WHAT: return running PIDs if any or return false\n+# WHY:  \n+# NOTE: return 1 or running PIDs numbers\n+nagios_running_pid(){\n+        RunningPID=`ps auxww | grep nagios | grep -v grep | grep ${OCF_RESKEY_config} | awk '{print $2}'`\n+\tif [ ${RunningPID}=\"\"  ]; then\n+\t        ocf_log debug \"Nagios is not Running.\"\n+\t\treturn ${OCF_NOT_RUNNING}\n+\tfi\n+\tocf_log debug \"Nagios Running PID=${RunningPID}\"\n+\treturn ${RunningPID}\n+}\n+\n+# WHAT: find nagios running status\n+# WHY:  \n+nagios_file_pid(){\n+    local OCF_RESKEY_PidFile=/var/nagios/nagios.pid\n+\tif [ -f ${OCF_RESKEY_PidFile} ]; then\n+\t\tNagiosPID=`head -n 1 ${OCF_RESKEY_PidFile}`\n+                ocf_log debug \"Nagios PID=${NagiosPID}\"\n+\telse\n+\t        ocf_log debug \"No Nagios PID lock file found in ${OCF_RESKEY_PidFile}\"\n+\t\treturn ${OCF_NOT_RUNNING}\n+\tfi\n+\treturn $OCF_SUCCESS\n+}\n+\n+get_nagios_pid(){\n+\t ocf_log debug \"get_nagios_pid: OCF_RESKEY_PidFile=${OCF_RESKEY_PidFile}\"\n+\tif [ -f ${OCF_RESKEY_PidFile} ]; then\n+\t\tNagiosPID=`head -n 1 ${OCF_RESKEY_PidFile}`\n+                ocf_log debug \"get_nagios_pid: Nagios PID=${NagiosPID}\"\n+\telse\n+\t\t ocf_log debug \"get_nagios_pid: No Nagios PID lock file found in ${OCF_RESKEY_PidFile}\"\n+\t\treturn ${OCF_NOT_RUNNING}\n+\tfi\n+\treturn $OCF_SUCCESS\n+}\n+get_nagios_status(){\n+\tget_nagios_pid\n+\t# find if PID in ${OCF_RESKEY_PidFile}\"\n+\tps -p ${NagiosPID} > /dev/null 2>&1\n+\tif [ $? = \"0\" ]; then\n+\t\treturn ${OCF_SUCCESS}\n+\telse\n+    \t\treturn ${OCF_ERR_GENERIC}\n+\tfi\n+}\n+\n+kill_nagios_process(){\n+\tif [ nagios_monitor ]; then\n+\t\t ocf_log debug \"killing Nagios PID: ${NagiosPID}\"\n+\t\tkill ${2} ${NagiosPID}\n+\telse\n+\t\t ocf_log debug \"Nagios is not running\"\n+\t\texit 0\n+\tfi\n+}\n+\n+#WHAT:\n+#WHY:\n+#NOTE: this function need to be able to run sucessfully \n+#      on master or slave Nagio server with/without shared drbd storage.\n+nagios_stop() {\n+    local rc\n+    # exit immediately if configuration is not valid\n+    # nagios_validate_all_master  || exit $?\n+    nagios_monitor;rc=$?\n+    case \"$rc\" in\n+        \"$OCF_SUCCESS\")\n+            # Currently running. Normal, expected behavior.\n+            ocf_log debug \"Resource is currently running\"\n+            ;;\n+        \"$OCF_NOT_RUNNING\")\n+            # Currently not running. Nothing to do.\n+            ocf_log info \"Resource is already stopped\"\n+        # WHAT:make sure temp fiiles are removed\n+        # WHY:\n+            ocf_log debug \"ls -l ${OCF_RESKEY_vardir}/\"\n+            ocf_log debug \"Removing appropriate Nagios temp files\"\n+            rm -f ${OCF_RESKEY_statusfile}\n+            rm -f ${OCF_RESKEY_tempfile}\n+            rm -f ${OCF_RESKEY_tempfile}\n+            rm -f ${OCF_RESKEY_PidFile}\n+            rm -f ${OCF_RESKEY_commandfile}\n+\n+            return $OCF_SUCCESS\n+            ;;\n+    esac\n+\n+    # actually shut down the resource here (make sure to immediately\n+    # exit with an $OCF_ERR_ error code if anything goes seriously\n+    # wrong)\n+    kill_nagios_process\n+\n+    # After the resource has been stopped, check whether it shut down\n+    # correctly. If the resource stops asynchronously, the agent may\n+    # spin on the monitor function here -- if the resource does not\n+    # shut down within the defined timeout, the cluster manager will\n+    # consider the stop action failed\n+    sleep 2\n+    while nagios_monitor; do\n+        ocf_log debug \"Resource has not stopped yet, waiting\"\n+        sleep 2\n+    done\n+    \n+    # only return $OCF_SUCCESS if _everything_ succeeded as expected\n+    return $OCF_SUCCESS\n+\n+}\n+\n+nagios_start() {\n+\tif \n+\t    silent_status \n+ \tthen\n+\t    ocf_log debug  \"$0  already running (pid `cat ${OCF_RESKEY_PidFile}` )\"\n+\t    return $OCF_SUCCESS\n+\tfi\n+\n+    # exit immediately if configuration is not valid\n+    # only node has access to config files which reside on shared drbd file can start Nagios.\n+    # will exit with error if nagios_validate !=0.\n+    ocf_log debug \"nagios_start: Called by PCS start,running nagios_validate_all\"\n+\n+#    if  nagios_validate_all \n+#    then\n+#        ocf_log debug \"nagios_start:nagios_validate_all: config errors\"\n+#        return $OCF_ERR_CONFIGURED\n+#    fi\n+\n+\n+    # if resource is already running,no need to continue code after this.\n+    if nagios_monitor; then\n+        ocf_log debug \"nagios_start: Called by PCS start, Resource is already running\"\n+        return $OCF_SUCCESS\n+    fi\n+\n+    # actually start up the resource here (make sure to immediately\n+    # exit with an $OCF_ERR_ error code if anything goes seriously\n+    # wrong)\n+\n+    #su - ${OCF_RESKEY_user} -c \"touch ${OCF_RESKEY_log} ${OCF_RESKEY_retentionfile}\"\n+    #rm -f ${OCF_RESKEY_commandfile}\n+    #touch ${OCF_RESKEY_PidFile}\n+    #chown ${OCF_RESKEY_user}:${OCF_RESKEY_group} ${OCF_RESKEY_PidFile}\n+    ${OCF_RESKEY_binary} -d ${OCF_RESKEY_config}; rc=$?\n+    if [ $rc  = \"0\" ]; then\n+\tget_nagios_pid\n+        ocf_log debug \"start: Nagios started with PID=${NagiosPID}\"\n+\treturn ${OCF_SUCCESS}\n+    fi\n+\n+    # $?\n+    # not needed \n+    #MYNAGPID=`ps auxww | grep nagios | grep -v grep | grep ${OCF_RESKEY_config} | awk '{print $2}'`\n+    #echo ${MYNAGPID}\n+    #echo ${MYNAGPID} > ${OCF_RESKEY_PidFile}\n+\n+    # WHAT: After the resource has been started, check whether it started up\n+    # correctly. If the resource starts asynchronously, the agent may\n+    # spin on the monitor function here -- if the resource does not\n+    # start up within the defined timeout, the cluster manager will\n+    # consider the start action failed\n+#    while ! nagios_monitor; do\n+#        ocf_log debug \"Resource has not started yet, waiting\"\n+#        sleep 1\n+#    done\n+\n+    # only return $OCF_SUCCESS if _everything_ succeeded as expected\n+    return $OCF_SUCCESS\n+}\n+\n+# WHAT: reload nagios configuration \n+# WHY:  so we can activate the changes of nagios configuration file.\n+# NOTE: \n+nagios_reload() {\n+    # exit immediately if configuration is not valid\n+    ocf_log debug \"nagios_reload: Running nagios_validate_all\"\n+    nagios_validate_all || exit $?\n+\n+    # if resource is already running, bail out early\n+    ocf_log debug \"nagios_reload: calling nagios_monitor.\"\n+    if [ nagios_monitor ]; then\n+\tPID=`cat $OCF_RESKEY_PidFile`\n+        ocf_log debug \"kill -HUP ${PID} to reload config files\"\n+\tkill -HUP $PID\n+    fi\n+    # WHAT: After the resource has been started, check whether it started up\n+    # correctly. If the resource starts asynchronously, the agent may\n+    # spin on the monitor function here -- if the resource does not\n+    # start up within the defined timeout, the cluster manager will\n+    # consider the start action failed\n+    while ! nagios_monitor; do\n+        ocf_log debug \"Resource has not started yet, waiting\"\n+        sleep 1\n+    done","path":"heartbeat/nagios4","position":523,"original_position":523,"commit_id":"c452945c2e7dd5b8a344b5f6f7d513d5dbccedeb","original_commit_id":"c452945c2e7dd5b8a344b5f6f7d513d5dbccedeb","user":{"login":"guessi","id":984415,"avatar_url":"https://avatars.githubusercontent.com/u/984415?v=3","gravatar_id":"","url":"https://api.github.com/users/guessi","html_url":"https://github.com/guessi","followers_url":"https://api.github.com/users/guessi/followers","following_url":"https://api.github.com/users/guessi/following{/other_user}","gists_url":"https://api.github.com/users/guessi/gists{/gist_id}","starred_url":"https://api.github.com/users/guessi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guessi/subscriptions","organizations_url":"https://api.github.com/users/guessi/orgs","repos_url":"https://api.github.com/users/guessi/repos","events_url":"https://api.github.com/users/guessi/events{/privacy}","received_events_url":"https://api.github.com/users/guessi/received_events","type":"User","site_admin":false},"body":"same here, could fall into infinite wait.","created_at":"2015-08-13T16:56:47Z","updated_at":"2015-08-13T16:56:47Z","html_url":"https://github.com/ClusterLabs/resource-agents/pull/636#discussion_r36997637","pull_request_url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636","_links":{"self":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/comments/36997637"},"html":{"href":"https://github.com/ClusterLabs/resource-agents/pull/636#discussion_r36997637"},"pull_request":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636","id":39025332,"html_url":"https://github.com/ClusterLabs/resource-agents/pull/636","diff_url":"https://github.com/ClusterLabs/resource-agents/pull/636.diff","patch_url":"https://github.com/ClusterLabs/resource-agents/pull/636.patch","issue_url":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/636","number":636,"state":"open","locked":false,"title":"ocf agent script for Nagios 4 server","user":{"login":"tjyang","id":378638,"avatar_url":"https://avatars.githubusercontent.com/u/378638?v=3","gravatar_id":"","url":"https://api.github.com/users/tjyang","html_url":"https://github.com/tjyang","followers_url":"https://api.github.com/users/tjyang/followers","following_url":"https://api.github.com/users/tjyang/following{/other_user}","gists_url":"https://api.github.com/users/tjyang/gists{/gist_id}","starred_url":"https://api.github.com/users/tjyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjyang/subscriptions","organizations_url":"https://api.github.com/users/tjyang/orgs","repos_url":"https://api.github.com/users/tjyang/repos","events_url":"https://api.github.com/users/tjyang/events{/privacy}","received_events_url":"https://api.github.com/users/tjyang/received_events","type":"User","site_admin":false},"body":"Hi\r\nThis is my first OCF agent scripting so try it at your own risk.\r\nThere is occasional error message  in my Centos 7.1+pacemaker+Nagios 4 two nodes cluster.\r\n\r\n\r\n```\r\n[root@lnagios1 ~]# pcs status\r\nCluster name: NagiosCluster\r\nLast updated: Wed Jul  1 17:02:06 2015\r\nLast change: Sun Jun 28 08:27:40 2015\r\nStack: corosync\r\nCurrent DC: lnagios1 (1) - partition with quorum\r\nVersion: 1.1.12-a14efad\r\n2 Nodes configured\r\n5 Resources configured\r\n\r\n\r\nOnline: [ lnagios2 lnagios1 ]\r\n\r\nFull list of resources:\r\n\r\n Master/Slave Set: DrbdDataClone [DrbdData]\r\n     Masters: [ lnagios1 ]\r\n     Slaves: [ lnagios2 ]\r\n DataFS (ocf::heartbeat:Filesystem):    Started lnagios1\r\n WebSite        (ocf::heartbeat:apache):        Started lnagios1\r\n NagiosServer   (ocf::heartbeat:nagios):        Started lnagios1\r\n\r\nFailed actions:\r\n    NagiosServer_monitor_60000 on lnagios2 'not running' (7): call=4302, status=complete, exit-reason='none', last-rc-\\\r\nchange='Mon Jun 29 19:16:36 2015', queued=961ms, exec=18ms\r\n\r\n\r\nPCSD Status:\r\n  lnagios1: Online\r\n  lnagios2: Online\r\n\r\nDaemon Status:\r\n  corosync: active/disabled\r\n  pacemaker: active/disabled\r\n  pcsd: active/enabled\r\n[root@lnagios1 ~]#\r\n\r\n```\r\n ","created_at":"2015-07-01T21:07:23Z","updated_at":"2015-08-13T16:56:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44bb074b4bd12951be72edbd326f4779df0b0c1f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636/commits","review_comments_url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636/comments","review_comment_url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/636/comments","statuses_url":"https://api.github.com/repos/ClusterLabs/resource-agents/statuses/c452945c2e7dd5b8a344b5f6f7d513d5dbccedeb","head":{"label":"tjyang:tjyang","ref":"tjyang","sha":"c452945c2e7dd5b8a344b5f6f7d513d5dbccedeb","user":{"login":"tjyang","id":378638,"avatar_url":"https://avatars.githubusercontent.com/u/378638?v=3","gravatar_id":"","url":"https://api.github.com/users/tjyang","html_url":"https://github.com/tjyang","followers_url":"https://api.github.com/users/tjyang/followers","following_url":"https://api.github.com/users/tjyang/following{/other_user}","gists_url":"https://api.github.com/users/tjyang/gists{/gist_id}","starred_url":"https://api.github.com/users/tjyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjyang/subscriptions","organizations_url":"https://api.github.com/users/tjyang/orgs","repos_url":"https://api.github.com/users/tjyang/repos","events_url":"https://api.github.com/users/tjyang/events{/privacy}","received_events_url":"https://api.github.com/users/tjyang/received_events","type":"User","site_admin":false},"repo":{"id":33459840,"name":"resource-agents","full_name":"tjyang/resource-agents","owner":{"login":"tjyang","id":378638,"avatar_url":"https://avatars.githubusercontent.com/u/378638?v=3","gravatar_id":"","url":"https://api.github.com/users/tjyang","html_url":"https://github.com/tjyang","followers_url":"https://api.github.com/users/tjyang/followers","following_url":"https://api.github.com/users/tjyang/following{/other_user}","gists_url":"https://api.github.com/users/tjyang/gists{/gist_id}","starred_url":"https://api.github.com/users/tjyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjyang/subscriptions","organizations_url":"https://api.github.com/users/tjyang/orgs","repos_url":"https://api.github.com/users/tjyang/repos","events_url":"https://api.github.com/users/tjyang/events{/privacy}","received_events_url":"https://api.github.com/users/tjyang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjyang/resource-agents","description":"Combined repository of OCF agents from the RHCS and Linux-HA projects","fork":true,"url":"https://api.github.com/repos/tjyang/resource-agents","forks_url":"https://api.github.com/repos/tjyang/resource-agents/forks","keys_url":"https://api.github.com/repos/tjyang/resource-agents/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjyang/resource-agents/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjyang/resource-agents/teams","hooks_url":"https://api.github.com/repos/tjyang/resource-agents/hooks","issue_events_url":"https://api.github.com/repos/tjyang/resource-agents/issues/events{/number}","events_url":"https://api.github.com/repos/tjyang/resource-agents/events","assignees_url":"https://api.github.com/repos/tjyang/resource-agents/assignees{/user}","branches_url":"https://api.github.com/repos/tjyang/resource-agents/branches{/branch}","tags_url":"https://api.github.com/repos/tjyang/resource-agents/tags","blobs_url":"https://api.github.com/repos/tjyang/resource-agents/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjyang/resource-agents/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjyang/resource-agents/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjyang/resource-agents/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjyang/resource-agents/statuses/{sha}","languages_url":"https://api.github.com/repos/tjyang/resource-agents/languages","stargazers_url":"https://api.github.com/repos/tjyang/resource-agents/stargazers","contributors_url":"https://api.github.com/repos/tjyang/resource-agents/contributors","subscribers_url":"https://api.github.com/repos/tjyang/resource-agents/subscribers","subscription_url":"https://api.github.com/repos/tjyang/resource-agents/subscription","commits_url":"https://api.github.com/repos/tjyang/resource-agents/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjyang/resource-agents/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjyang/resource-agents/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjyang/resource-agents/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjyang/resource-agents/contents/{+path}","compare_url":"https://api.github.com/repos/tjyang/resource-agents/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjyang/resource-agents/merges","archive_url":"https://api.github.com/repos/tjyang/resource-agents/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjyang/resource-agents/downloads","issues_url":"https://api.github.com/repos/tjyang/resource-agents/issues{/number}","pulls_url":"https://api.github.com/repos/tjyang/resource-agents/pulls{/number}","milestones_url":"https://api.github.com/repos/tjyang/resource-agents/milestones{/number}","notifications_url":"https://api.github.com/repos/tjyang/resource-agents/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjyang/resource-agents/labels{/name}","releases_url":"https://api.github.com/repos/tjyang/resource-agents/releases{/id}","created_at":"2015-04-06T00:20:57Z","updated_at":"2015-04-06T00:20:58Z","pushed_at":"2015-07-03T12:29:39Z","git_url":"git://github.com/tjyang/resource-agents.git","ssh_url":"git@github.com:tjyang/resource-agents.git","clone_url":"https://github.com/tjyang/resource-agents.git","svn_url":"https://github.com/tjyang/resource-agents","homepage":"","size":32355,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ClusterLabs:master","ref":"master","sha":"2f35c9c04c487b57e4b19d4bfb05f94f23115f28","user":{"login":"ClusterLabs","id":574912,"avatar_url":"https://avatars.githubusercontent.com/u/574912?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterLabs","html_url":"https://github.com/ClusterLabs","followers_url":"https://api.github.com/users/ClusterLabs/followers","following_url":"https://api.github.com/users/ClusterLabs/following{/other_user}","gists_url":"https://api.github.com/users/ClusterLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterLabs/subscriptions","organizations_url":"https://api.github.com/users/ClusterLabs/orgs","repos_url":"https://api.github.com/users/ClusterLabs/repos","events_url":"https://api.github.com/users/ClusterLabs/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":1316191,"name":"resource-agents","full_name":"ClusterLabs/resource-agents","owner":{"login":"ClusterLabs","id":574912,"avatar_url":"https://avatars.githubusercontent.com/u/574912?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterLabs","html_url":"https://github.com/ClusterLabs","followers_url":"https://api.github.com/users/ClusterLabs/followers","following_url":"https://api.github.com/users/ClusterLabs/following{/other_user}","gists_url":"https://api.github.com/users/ClusterLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterLabs/subscriptions","organizations_url":"https://api.github.com/users/ClusterLabs/orgs","repos_url":"https://api.github.com/users/ClusterLabs/repos","events_url":"https://api.github.com/users/ClusterLabs/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterLabs/resource-agents","description":"Combined repository of OCF agents from the RHCS and Linux-HA projects","fork":false,"url":"https://api.github.com/repos/ClusterLabs/resource-agents","forks_url":"https://api.github.com/repos/ClusterLabs/resource-agents/forks","keys_url":"https://api.github.com/repos/ClusterLabs/resource-agents/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterLabs/resource-agents/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterLabs/resource-agents/teams","hooks_url":"https://api.github.com/repos/ClusterLabs/resource-agents/hooks","issue_events_url":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterLabs/resource-agents/events","assignees_url":"https://api.github.com/repos/ClusterLabs/resource-agents/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterLabs/resource-agents/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterLabs/resource-agents/tags","blobs_url":"https://api.github.com/repos/ClusterLabs/resource-agents/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterLabs/resource-agents/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterLabs/resource-agents/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterLabs/resource-agents/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterLabs/resource-agents/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterLabs/resource-agents/languages","stargazers_url":"https://api.github.com/repos/ClusterLabs/resource-agents/stargazers","contributors_url":"https://api.github.com/repos/ClusterLabs/resource-agents/contributors","subscribers_url":"https://api.github.com/repos/ClusterLabs/resource-agents/subscribers","subscription_url":"https://api.github.com/repos/ClusterLabs/resource-agents/subscription","commits_url":"https://api.github.com/repos/ClusterLabs/resource-agents/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterLabs/resource-agents/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterLabs/resource-agents/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterLabs/resource-agents/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterLabs/resource-agents/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterLabs/resource-agents/merges","archive_url":"https://api.github.com/repos/ClusterLabs/resource-agents/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterLabs/resource-agents/downloads","issues_url":"https://api.github.com/repos/ClusterLabs/resource-agents/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterLabs/resource-agents/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterLabs/resource-agents/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterLabs/resource-agents/labels{/name}","releases_url":"https://api.github.com/repos/ClusterLabs/resource-agents/releases{/id}","created_at":"2011-02-01T13:43:18Z","updated_at":"2015-08-07T11:54:53Z","pushed_at":"2015-08-12T14:00:41Z","git_url":"git://github.com/ClusterLabs/resource-agents.git","ssh_url":"git@github.com:ClusterLabs/resource-agents.git","clone_url":"https://github.com/ClusterLabs/resource-agents.git","svn_url":"https://github.com/ClusterLabs/resource-agents","homepage":"","size":38341,"stargazers_count":251,"watchers_count":251,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":261,"mirror_url":null,"open_issues_count":71,"forks":261,"open_issues":71,"watchers":251,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636"},"html":{"href":"https://github.com/ClusterLabs/resource-agents/pull/636"},"issue":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/636"},"comments":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/issues/636/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/pulls/636/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterLabs/resource-agents/statuses/c452945c2e7dd5b8a344b5f6f7d513d5dbccedeb"}}}}