Permalink
Browse files

[ARMT] initial commit of ARMT code base

  • Loading branch information...
1 parent b632947 commit c707144ea49d6a6344fe2314b55201ffb49122a1 @gnif committed Aug 28, 2012
Showing 1,228 changed files with 718,905 additions and 1 deletion.
View
@@ -2,6 +2,8 @@
*.slo
*.lo
*.o
+*.Po
+*.Plo
# Compiled Dynamic libraries
*.so
@@ -10,3 +12,9 @@
*.lai
*.la
*.a
+
+# Make stamps
+*-stamp
+
+# Temp files
+*~
View
@@ -0,0 +1,61 @@
+CC = g++
+OBJCOPY = objcopy
+CFLAGS = -Wall -D__STDC_LIMIT_MACROS
+OBJECTS = armt.o
+INCFLAGS = -I./
+LDFLAGS = -Wl,-rpath,/usr/local/lib
+OUTPUT = armt
+
+CFLAGS += -g -O2
+LDFLAGS += -Wl,-Bstatic -static -static-libgcc -static-libstdc++
+LDFLAGS += -Wl,-wrap,gethostbyname
+
+INCFLAGS += -Ilibs/pcre-8.20
+INCFLAGS += -Ilibs/polarssl-1.1.4/include
+
+OBJECTS += common/CCommon.o
+OBJECTS += common/CDNS.o
+OBJECTS += common/CProcInfo.o
+OBJECTS += common/CPCIInfo.o
+OBJECTS += common/CHTTP.o
+OBJECTS += common/MD5.o
+
+OBJECTS += block/CBlockEnumerator.o
+OBJECTS += block/CSMARTBlockDevice.o
+OBJECTS += block/CCCISSBlockDevice.o
+OBJECTS += block/CMDBlockDevice.o
+
+ARCHIVES += libs/libs.a
+ARCHIVES += utils/utils.a
+
+#CFLAGS += -DHAS_LIBPCI
+#LIBS += -lpci -lz -lresolv
+
+all: armt
+
+armt: $(ARCHIVES) $(OBJECTS)
+ $(CC) -o $(OUTPUT)_`uname -m` $(OBJECTS) $(ARCHIVES) $(LDFLAGS) $(LIBS)
+
+%.o: %.cc
+ $(CC) -c -o $@ $(CFLAGS) $< $(INCFLAGS)
+
+utils/utils.a:
+ $(MAKE) -C utils
+
+libs/libs.a:
+ $(MAKE) -C libs
+
+clean:
+ rm -f $(OBJECTS) $(OUTPUT)_`uname -m`
+
+distclean: clean
+ $(MAKE) -C utils clean
+ $(MAKE) -C libs clean
+
+pack:
+ strip -s $(OUTPUT)_`uname -m`
+ upx --ultra-brute $(OUTPUT)_`uname -m`
+
+.PHONY: all
+.PHONY: clean
+.PHONY: pack
View
@@ -1,4 +1,41 @@
ARMT
====
-ARMT (Another Remote Monitoring Tool)
+ARMT (Another Remote Monitoring Tool) is another tool to assist server
+administrators in their fight to keep servers online.
+
+This tool is still a work in progress so do not expect too much yet.
+
+Currently monitoring of a remote server is performed via various scripts many of
+which perform simple repeatble tasks, such as checking for a running process or
+checking if a service such as HTTP is alive.
+
+Other checks are not feasable or are a pain to perform as they require support
+of other tools such as a recent version of smartmontools, or other dependent
+libraries that may not be installed on the target machine.
+
+ARMT aims to work around these issues by compiling to a static binary that
+contains all the required support tools embedded also as static binaries. So far
+ARMT is able to perform the following:
+
+* Get installed PCI devices
+* Get SMART status of block devices
+* Get CCISS RAID status of arrays
+* Get MD (Software) RAID status of arrays
+* Get a running process list and ports bound to processes
+* Connect to a HTTP(s) server
+* Create and compare a MD5 hash database of critical system files
+
+To perform these tasks ARMT uses the following support libraries and executables
+
+* libpcre
+* polarssl
+* smartctl
+* cciss\_vol\_status
+* megactl (not used yet)
+* lsscsi (not used yet and may be removed)
+* zlib (not used yet)
+
+To avoid shared linking ARMT also has it's own built-in DNS resolver that wraps
+gethostbyname as linking to `gethostbyname` causes a system dependency on the
+shared libc.
View
146 armt.cc
@@ -0,0 +1,146 @@
+/*
+ * ARMT (Another Remote Monitoring Tool)
+ * Copyright (C) Geoffrey McRae 2012 <geoff@spacevs.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "common/CDNS.h"
+#include "common/CPCIInfo.h"
+#include "common/CProcInfo.h"
+#include "common/CCommon.h"
+#include "common/CHTTP.h"
+
+#include "block/CBlockEnumerator.h"
+
+/* we wrap the libc version to avoid shared linking */
+CDNS DNS;
+static struct hostent *_hostent = NULL;
+extern "C" {
+ struct hostent *__wrap_gethostbyname(const char *host)
+ {
+ if (_hostent)
+ DNS.Free(_hostent);
+ _hostent = DNS.GetHostByName(host);
+ return _hostent;
+ }
+}
+
+void BlockDeviceCheck()
+{
+ IBlockDevice::Map map = CBlockEnumerator::Enumerate();
+ for(IBlockDevice::Map::iterator it = map.begin(); it != map.end(); ++it)
+ {
+ const std::string &error = it->second->GetError();
+ if (!error.empty())
+ {
+ printf(
+ "======== (%s) ========\n"
+ " Device: %s\n"
+ " Error: %s\n",
+ it->second->GetType (),
+ it->second->GetDevName().c_str(),
+ error .c_str()
+ );
+ continue;
+ }
+
+ printf(
+ "======== (%s) ========\n"
+ " Device: %s\n"
+ " Model: %s\n"
+ " Serial: %s\n"
+ "Firmware: %s\n"
+ " Status: %s\n",
+ it->second->GetType (),
+ it->second->GetDevName ().c_str(),
+ it->second->GetModel ().c_str(),
+ it->second->GetSerialNumber().c_str(),
+ it->second->GetFirmware ().c_str(),
+ it->second->IsOK () ? "OK" : "FAILURE"
+ );
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ CCommon::Initialize(argc, argv);
+
+ DNS.AddResolver("8.8.8.8" ); /* Google */
+ DNS.AddResolver("8.8.4.4" ); /* Google */
+ DNS.AddResolver("208.67.222.222"); /* OpenDNS */
+ DNS.AddResolver("208.67.222.220"); /* OpenDNS */
+
+ if (_hostent)
+ DNS.Free(_hostent);
+
+// BlockDeviceCheck();
+ return 0;
+
+
+#if 0
+ CPCIInfo::DeviceList devices = CPCIInfo::GetDeviceList();
+ for(CPCIInfo::DeviceListIterator itt = devices.begin(); itt != devices.end(); ++itt)
+ {
+ printf("[0x%04hx|0x%04hx:0x%04hx] %s"
+#if defined(HAS_PCILIB)
+ " %s - %s"
+#endif
+ "\n",
+ itt->GetClass(),
+ itt->GetVendorID(),
+ itt->GetDeviceID(),
+ itt->GetClassName().c_str()
+#if defined(HAS_PCILIB)
+ ,
+ itt->GetVendorName().c_str(),
+ itt->GetDeviceName().c_str()
+#endif
+ );
+ }
+
+ return 0;
+
+ CProcInfo::ProcessList list = CProcInfo::GetProcessList();
+ for(CProcInfo::ProcessListIterator itt = list.begin(); itt != list.end(); ++itt)
+ {
+ printf(
+ "PID : %d\n"
+ "EXE : %s\n"
+ "COMM : %s\n"
+ "CMDLINE: %s\n",
+ itt->GetPID(),
+ itt->GetExe ().c_str(),
+ itt->GetComm ().c_str(),
+ itt->GetCmdLine().c_str()
+ );
+
+ CProcInfo::BoundList bound = itt->GetBoundList();
+ for(CProcInfo::BoundListIterator itt2 = bound.begin(); itt2 != bound.end(); ++itt2)
+ {
+ if (itt2->GetType() == CProcInfo::PORT_TYPE_UNIX)
+ printf(" BOUND: %s(%s)\n" , CProcInfo::PortTypeToString(itt2->GetType()), itt2->GetPath().c_str());
+ else printf(" BOUND: %s(%s:%u)\n", CProcInfo::PortTypeToString(itt2->GetType()), CProcInfo::IPToString(itt2->GetIP()).c_str(), itt2->GetPort());
+ }
+
+ printf("\n");
+ }
+#endif
+}
View
@@ -0,0 +1,35 @@
+/*
+ * ARMT (Another Remote Monitoring Tool)
+ * Copyright (C) Geoffrey McRae 2012 <geoff@spacevs.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "CBlockEnumerator.h"
+
+#include "common/CCommon.h"
+#include "CSMARTBlockDevice.h"
+#include "CCCISSBlockDevice.h"
+#include "CMDBlockDevice.h"
+
+IBlockDevice::Map CBlockEnumerator::Enumerate()
+{
+ IBlockDevice::Map map;
+ CSMARTBlockDevice::Enumerate(map);
+ CCCISSBlockDevice::Enumerate(map);
+ CMDBlockDevice ::Enumerate(map);
+ return map;
+}
View
@@ -0,0 +1,34 @@
+/*
+ * ARMT (Another Remote Monitoring Tool)
+ * Copyright (C) Geoffrey McRae 2012 <geoff@spacevs.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _CBLOCKENUMERATOR_H_
+#define _CBLOCKENUMERATOR_H_
+
+#include "IBlockDevice.h"
+
+#include <string>
+
+class CBlockEnumerator
+{
+ public:
+ static IBlockDevice::Map Enumerate();
+};
+
+#endif
Oops, something went wrong.

0 comments on commit c707144

Please sign in to comment.