Skip to content

Commit

Permalink
HPCC-14188 Add Thor master process checks to nagios monitoring
Browse files Browse the repository at this point in the history
Signed-off-by: Gleb Aronsky <[email protected]>
  • Loading branch information
Gleb Aronsky committed Sep 9, 2015
1 parent 0517a26 commit d3dcb37
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/hpcc_nagios.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ define command{
command_line /usr/lib/nagios/plugins/check_http -I $HOSTADDRESS$ -p $ARG1$
}

# 'check_thormaster' command definition
define command{
command_name check_thormaster
command_line /usr/lib/nagios/plugins/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

# 'check_esp_service_https' command definition with authentication
define command{
command_name check_esp_service_https_auth
command_line /usr/lib/nagios/plugins/check_http -S -I $HOSTADDRESS$ -p $ARG1$ -a $ARG2$:$ARG3$
}

# 'check_esp_service_http' command definition with authenticaiton
define command{
command_name check_esp_service_http_auth
Expand Down
106 changes: 106 additions & 0 deletions hpcc-nagios-tools/HPCCNagiosToolSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const char *P_DALI("dali");
const char *P_SASHA("sasha");
const char *P_ROXIE("roxie");
const char *P_DAFILESRV("dafilesrv");
const char *P_THOR("thor");

const char *P_ECLWATCH_FLAG(" -e ");
const char *P_USER_MACRO_FLAG(" -u ");
Expand Down Expand Up @@ -546,6 +547,7 @@ bool CHPCCNagiosToolSet::generateServerAndHostConfigurationFile(const char* pOut

CHPCCNagiosToolSet::generateNagiosEspServiceConfig(strServiceConfig, pEnvXML, pConfigGenPath);
CHPCCNagiosToolSet::generateNagiosDaliCheckConfig(strServiceConfig, pEnvXML, pConfigGenPath);
CHPCCNagiosToolSet::generateNagiosThorCheckConfig(strServiceConfig, pEnvXML, pConfigGenPath);
CHPCCNagiosToolSet::generateNagiosSashaCheckConfig(strServiceConfig, pEnvXML, pConfigGenPath);
CHPCCNagiosToolSet::generateNagiosRoxieCheckConfig(strServiceConfig, pEnvXML, pConfigGenPath);
CHPCCNagiosToolSet::generateNagiosDafileSrvCheckConfig(strServiceConfig, pEnvXML, pConfigGenPath);
Expand Down Expand Up @@ -1149,6 +1151,110 @@ bool CHPCCNagiosToolSet::generateNagiosSystemCheckConfig(StringBuffer &strServic
return true;
}

bool CHPCCNagiosToolSet::generateNagiosThorCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML, const char* pConfigGenPath)
{
const int nNumValues = 5;

char *pOutput = CHPCCNagiosToolSet::invokeConfigGen(pEnvXML, pConfigGenPath, P_CONFIGGEN_PARAM_LIST_ALL, P_THOR);

if (pOutput == NULL)
return false;

int i = -1;
char pProcess[BUFFER_SIZE_3] = "";
int nCount = 0;
char *pch = NULL;
pch = strtok(pOutput, ",\n");
StringBuffer strPort;
StringBuffer strIPAddress;
char pHostName[BUFFER_SIZE_3] = "";
char pProcessName[BUFFER_SIZE_3] = "";

while (pch != NULL)
{
if (nCount % nNumValues == 0) // Process name
{
if (*pch != 0 && strcmp(pch, XML_TAG_THORMASTERPROCESS) != 0 && strcmp(pch, XML_TAG_THORSLAVEPROCESS) != 0 && strcmp(pch, XML_TAG_THORSPAREPROCESS) != 0)
{
free(pOutput);
return false; // expecting only thor processes
}
else if (strcmp(pch, XML_TAG_THORSLAVEPROCESS) == 0 || strcmp(pch, XML_TAG_THORSPAREPROCESS) == 0)
{
for (int i = 0; i < nNumValues; i++)
{
pch = strtok(NULL, ",\n");
nCount++;
}
continue;
}
else if (pProcess != NULL && *pProcess != 0 && strcmp(pProcess, pch) != 0)
{
strncpy(pProcess, pch, sizeof(pProcess));
i = 0;
}
else if (pProcess == NULL || *pProcess == 0 || strcmp(pProcess, pch) != 0)

This comment has been minimized.

Copy link
@wangkx

wangkx Sep 15, 2015

Remove ' || strcmp(pProcess, pch) != 0'?

{
strncpy(pProcess, pch, sizeof(pProcess));
i++;
}
else if (strcmp(pProcess,pch) == 0)
{
i++;
}

This comment has been minimized.

Copy link
@wangkx

wangkx Sep 15, 2015

In fact, it may be better if you use the following to replace the last three 'else if's:
if (pProcess == NULL || *pProcess == 0) {...}
else if (strcmp(pProcess, pch) != 0) { ... }
else { ... }

}
else if (nCount % nNumValues == 1) // process name
{
strcpy(pProcessName,pch);
}
else if (nCount % nNumValues == 2) // IP Address
{
strIPAddress.clear().append(pch);

struct hostent* hp = NULL;

if (bDoLookUp == true)
{
unsigned int addr = inet_addr(pch);
hp = gethostbyaddr((const char*)&addr, sizeof(addr), AF_INET);
}

if (hp == NULL)
{
bDoLookUp = m_retryHostNameLookUp;
strcpy(pHostName, pch);
}
else
{
strcpy(pHostName,hp->h_name);
}
}
else if (nCount % nNumValues == 3)
{
strPort.clear().append(pch);
}
else if (nCount % nNumValues == 4)
{
VStringBuffer strNote("check for %s of type %s %s%s:%s", pProcessName, pProcess, CHPCCNagiosToolSet::m_pSeparator, strIPAddress.str(), strPort.str());

strServiceConfig.append(P_NAGIOS_SERVICE_CONFIG_2).append(pHostName).append(P_NAGIOS_SERVICE_DESCRIPTION).append(strNote.str())\
.append(P_NAGIOS_SERVICE_CHECK_COMMAND).append(CHPCCNagiosToolSet::m_pNRPE).append(P_CHECK_THORMASTER).append(P_NAGIOS_SEPERATOR).append(strPort.str());

CHPCCNagiosToolSet::generateNagiosServiceEscalationConfig(strServiceConfig, XML_TAG_THORMASTERPROCESS, strNote.str());

strServiceConfig.append(P_NAGIOS_SERVICE_END_BRACKET).append("\n");
}

pch = strtok(NULL, ",\n");

nCount++;
}

free(pOutput);

return true;
}

bool CHPCCNagiosToolSet::generateNagiosDafileSrvCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML, const char* pConfigGenPath)
{
const int nNumValues = 5;
Expand Down
1 change: 1 addition & 0 deletions hpcc-nagios-tools/HPCCNagiosToolSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class CHPCCNagiosToolSet

static bool generateNagiosEspServiceConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
static bool generateNagiosDaliCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
static bool generateNagiosThorCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
static bool generateNagiosSashaCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
static bool generateNagiosRoxieCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
static bool generateNagiosDafileSrvCheckConfig(StringBuffer &strServiceConfig, const char* pEnvXML = PENV_XML, const char* pConfigGenPath = PCONFIGGEN_PATH);
Expand Down
1 change: 1 addition & 0 deletions hpcc-nagios-tools/HPCCNagiosToolSetCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static const char *P_CHECK_SASHA("check_sasha");
static const char *P_CHECK_ROXIE("check_roxie");
static const char *P_SSH("ssh");
static const char *P_CHECK_DAFILESRV("check_dafilesrv");
static const char *P_CHECK_THORMASTER("check_thormaster");
static const char *P_HTTP("http");
static const char *P_HTTPS("https");
static const char *P_BY_TYPE(" -t ");
Expand Down

0 comments on commit d3dcb37

Please sign in to comment.