+ ServiceCheck.SSH(host[, port]) Added
authorAlex Kirhenshtein <alk@netxms.org>
Wed, 19 Jan 2005 13:42:47 +0000 (13:42 +0000)
committerAlex Kirhenshtein <alk@netxms.org>
Wed, 19 Jan 2005 13:42:47 +0000 (13:42 +0000)
.gitattributes
src/agent/subagents/portCheck/Makefile.am
src/agent/subagents/portCheck/main.cpp
src/agent/subagents/portCheck/ssh.cpp [new file with mode: 0644]
src/agent/subagents/portCheck/ssh.h [new file with mode: 0644]

index 0691f8c..b635b5b 100644 (file)
@@ -152,6 +152,8 @@ src/agent/subagents/portCheck/net.cpp -text
 src/agent/subagents/portCheck/net.h -text
 src/agent/subagents/portCheck/pop3.cpp -text
 src/agent/subagents/portCheck/pop3.h -text
+src/agent/subagents/portCheck/ssh.cpp -text
+src/agent/subagents/portCheck/ssh.h -text
 src/agent/subagents/skeleton/Makefile.am -text
 src/agent/subagents/skeleton/Makefile.nw -text
 src/agent/subagents/skeleton/skeleton.cpp -text
index 6b1980e..afa918f 100644 (file)
@@ -1,8 +1,8 @@
-# $Id: Makefile.am,v 1.2 2005-01-18 18:42:39 alk Exp $
+# $Id: Makefile.am,v 1.3 2005-01-19 13:42:47 alk Exp $
 
 INCLUDES=-I@top_srcdir@/include
 
 lib_LTLIBRARIES = libnsm_portCheck.la
-libnsm_portCheck_la_SOURCES = main.cpp net.cpp pop3.cpp
+libnsm_portCheck_la_SOURCES = main.cpp net.cpp pop3.cpp ssh.cpp
 
-EXTRA_DIST = net.h pop3.h
+EXTRA_DIST = net.h pop3.h ssh.h
index 927f8f6..59011e9 100644 (file)
@@ -1,10 +1,11 @@
-/* $Id: main.cpp,v 1.1.1.1 2005-01-18 18:38:54 alk Exp $ */
+/* $Id: main.cpp,v 1.2 2005-01-19 13:42:47 alk Exp $ */
 
 #include <nms_common.h>
 #include <nms_agent.h>
 
 #include "net.h"
 #include "pop3.h"
+#include "ssh.h"
 
 //
 // Subagent information
@@ -13,6 +14,7 @@
 static NETXMS_SUBAGENT_PARAM m_parameters[] =
 {
    { "ServiceCheck.POP3(*)",         H_CheckPOP3,       NULL },
+   { "ServiceCheck.SSH(*)",          H_CheckSSH,        NULL },
 };
 
 static NETXMS_SUBAGENT_ENUM m_enums[] =
@@ -47,5 +49,11 @@ extern "C" BOOL NxSubAgentInit(NETXMS_SUBAGENT_INFO **ppInfo)
 /*
 
 $Log: not supported by cvs2svn $
+Revision 1.1.1.1  2005/01/18 18:38:54  alk
+Initial import
+
+implemented:
+       ServiceCheck.POP3(host, user, password) - connect to host:110 and try to login
+
 
 */
diff --git a/src/agent/subagents/portCheck/ssh.cpp b/src/agent/subagents/portCheck/ssh.cpp
new file mode 100644 (file)
index 0000000..1b6e671
--- /dev/null
@@ -0,0 +1,63 @@
+/* $Id: ssh.cpp,v 1.1 2005-01-19 13:42:47 alk Exp $ */
+
+#include <nms_common.h>
+#include <nms_agent.h>
+
+#include "net.h"
+
+LONG H_CheckSSH(char *pszParam, char *pArg, char *pValue)
+{
+       LONG nRet = SYSINFO_RC_SUCCESS;
+       char szHost[256];
+       char szPort[256];
+       unsigned short nPort;
+       int nSd;
+       bool bIsOk = false;
+
+   NxGetParameterArg(pszParam, 1, szHost, sizeof(szHost));
+   NxGetParameterArg(pszParam, 2, szPort, sizeof(szPort));
+
+       if (szHost[0] == 0)
+       {
+               return SYSINFO_RC_ERROR;
+       }
+       nPort = (unsigned short)atoi(szPort);
+       if (nPort == 0)
+       {
+               nPort = 22;
+       }
+
+       nSd = NetConnectTCP(szHost, nPort);
+       if (nSd > 0)
+       {
+               char szBuff[512];
+               char szTmp[128];
+
+               if (NetRead(nSd, szBuff, sizeof(szBuff)) >= 8)
+               {
+                       int nMajor, nMinor;
+
+                       if (sscanf(szBuff, "SSH-%d.%d-", &nMajor, &nMinor) == 2)
+                       {
+                               snprintf(szTmp, sizeof(szTmp), "SSH-%d.%d-NetXMS\n",
+                                               nMajor, nMinor);
+                               if (NetWrite(nSd, szTmp, strlen(szTmp)) > 0)
+                               {
+                                       bIsOk = true;
+                               }
+                       }
+               }
+
+               NetClose(nSd);
+       }
+       ret_int(pValue, bIsOk ? 1 : 0);
+
+       return nRet;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/*
+
+$Log: not supported by cvs2svn $
+
+*/
diff --git a/src/agent/subagents/portCheck/ssh.h b/src/agent/subagents/portCheck/ssh.h
new file mode 100644 (file)
index 0000000..21ff57f
--- /dev/null
@@ -0,0 +1,15 @@
+/* $Id: ssh.h,v 1.1 2005-01-19 13:42:47 alk Exp $ */
+
+#ifndef __SSH__H__
+#define __SSH__H__
+
+LONG H_CheckSSH(char *, char *, char *);
+
+#endif // __SSH__H__
+
+///////////////////////////////////////////////////////////////////////////////
+/*
+
+$Log: not supported by cvs2svn $
+
+*/