diff --git a/linspector b/linspector deleted file mode 100755 index 8ba8a1d..0000000 --- a/linspector +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/python2.7 -tt - -""" -Copyright (c) 2011-2013 "Johannes Findeisen and Rafael Timmerberg" - -This file is part of Linspector (http://linspector.org). - -Linspector is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -""" - -__version__ = "0.6/TCPCONNECT" -__default_config__ = "./examples/minimal.json" - -import argparse -import logging -import logging.handlers -import os -import os.path as path - -from lib.config.parser import FullConfigParser -from lib.core.job import Job -from lib.core.scheduler import Scheduler -from lib.backends.https import HttpsBackend -from lib.frontends.lish import LishFrontend - - -def parseArgs(): - parser = argparse.ArgumentParser( - description="Linspector is for monitoring the vital information of hosts, services and devices in a network.", - epilog="linspector is not some program expecting computers to run! Visit http://linspector.org for more " - "information.", - prog="linspector") - - parser.add_argument("--version", action="version", version="%(prog)s " + str(__version__)) - #TODO: make the config file a required field without -c or --config at the end eg: linspector config.json - parser.add_argument("-c", "--config", default=__default_config__, - help="select configfile to use") - parser.add_argument("-l", "--logfile", default="./log/linspector.log", metavar="FILE", - help="set logfile to use") - - output = parser.add_mutually_exclusive_group() - output.add_argument("-q", "--quiet", action="store_const", dest="loglevel", const=logging.ERROR, - help="output only errors") - output.add_argument("-w", "--warning", action="store_const", dest="loglevel", const=logging.WARNING, - help="output warnings") - output.add_argument("-v", "--verbose", action="store_const", dest="loglevel", const=logging.INFO, - help="output info messages") - output.add_argument("-d", "--debug", action="store_const", dest="loglevel", const=logging.DEBUG, - help="output debug messages") - output.set_defaults(loglevel=logging.INFO) - return parser.parse_args() - - -def setupLogging(logfile="./log/linspector.log", logLevel=logging.DEBUG, logfileLevel=logging.DEBUG): - logfile = path.expanduser(logfile) - if not path.exists(path.dirname(logfile)): - os.makedirs(path.dirname(logfile)) - - log = logging.getLogger(__name__) - log.setLevel(logging.DEBUG) - - consoleHandler = logging.StreamHandler() - consoleHandler.setLevel(logLevel) - - fileHandler = logging.handlers.RotatingFileHandler(logfile, maxBytes=1024000, backupCount=4) - fileHandler.setLevel(logfileLevel) - - consoleFormatter = logging.Formatter('[%(levelname)s]: %(message)s') - #TODO: if debug with file and function else without that - fileFormatter = logging.Formatter('%(asctime)s %(pathname)s %(module)s %(funcName)s %(lineno)d [%(levelname)s]: %(message)s') - - consoleHandler.setFormatter(consoleFormatter) - fileHandler.setFormatter(fileFormatter) - - log.addHandler(consoleHandler) - log.addHandler(fileHandler) - return log - - -def handleJob(jobInfo): - jobInfo.handle_call() - - -def main(): - args = parseArgs() - #TODO: catch all log messages (apscheduler etc.); make logging more generic to support libraries logging - log = setupLogging(args.logfile, args.loglevel) - - log.info("parsed arguments") - - configParser = FullConfigParser(log) - linConf, core = configParser.parse_config(args.config) - - scheduler = Scheduler() - - scheduler.start() - jobs = [] - - for layout in linConf.get_enabled_layouts(): - for hostgroup in layout.get_hostgroups(): - for service in hostgroup.get_services(): - for host in hostgroup.get_hosts(): - for period in service.get_periods(): - job = Job(service, host, hostgroup.get_members(), hostgroup.get_processors(), core) - schedulerJob = period.createJob(scheduler, job, handleJob) - if schedulerJob is not None: - job.set_job(schedulerJob) - job.set_logger(log) - jobs.append(job) - - #TODO: Load Backend Threads here before initializing the frontend. - ''' - for backend in backends.enabled - backend.start - - take care of signals etc. to sthutdown the threads when stopping linspector. - ''' - frontend = LishFrontend(jobs=jobs, scheduler=scheduler, linspectorConfig=linConf) - - log.debug("shutting down scheduler") - logging.shutdown() - scheduler.shutdown(wait=True) - - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/lib/backends/__init__.py b/linspector/__init__.py similarity index 100% rename from lib/backends/__init__.py rename to linspector/__init__.py diff --git a/lib/config/__init__.py b/linspector/backends/__init__.py similarity index 100% rename from lib/config/__init__.py rename to linspector/backends/__init__.py diff --git a/lib/backends/backend.py b/linspector/backends/backend.py similarity index 100% rename from lib/backends/backend.py rename to linspector/backends/backend.py diff --git a/lib/backends/https.py b/linspector/backends/https.py similarity index 95% rename from lib/backends/https.py rename to linspector/backends/https.py index 9e71203..f8faf20 100644 --- a/lib/backends/https.py +++ b/linspector/backends/https.py @@ -22,7 +22,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.backends.backend import Backend +from linspector.backends.backend import Backend class HttpsBackend(Backend): diff --git a/lib/backends/jsonrpc.py b/linspector/backends/jsonrpc.py similarity index 94% rename from lib/backends/jsonrpc.py rename to linspector/backends/jsonrpc.py index e25cd47..54ac2be 100644 --- a/lib/backends/jsonrpc.py +++ b/linspector/backends/jsonrpc.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.backends.backend import Backend +from linspector.backends.backend import Backend class JsonrpcBackend(Backend): diff --git a/lib/backends/xmpp.py b/linspector/backends/xmpp.py similarity index 95% rename from lib/backends/xmpp.py rename to linspector/backends/xmpp.py index 88853af..ad852ba 100644 --- a/lib/backends/xmpp.py +++ b/linspector/backends/xmpp.py @@ -22,7 +22,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.backends.backend import Backend +from linspector.backends.backend import Backend class XmmpBackend(Backend): diff --git a/lib/core/__init__.py b/linspector/config/__init__.py similarity index 100% rename from lib/core/__init__.py rename to linspector/config/__init__.py diff --git a/lib/config/config.py b/linspector/config/config.py similarity index 100% rename from lib/config/config.py rename to linspector/config/config.py diff --git a/lib/config/hostgroups.py b/linspector/config/hostgroups.py similarity index 100% rename from lib/config/hostgroups.py rename to linspector/config/hostgroups.py diff --git a/lib/config/layouts.py b/linspector/config/layouts.py similarity index 100% rename from lib/config/layouts.py rename to linspector/config/layouts.py diff --git a/lib/config/members.py b/linspector/config/members.py similarity index 100% rename from lib/config/members.py rename to linspector/config/members.py diff --git a/lib/config/parser.py b/linspector/config/parser.py similarity index 97% rename from lib/config/parser.py rename to linspector/config/parser.py index 12fdca7..bf5f675 100644 --- a/lib/config/parser.py +++ b/linspector/config/parser.py @@ -28,10 +28,10 @@ from members import Member from config import LinspectorConfig from periods import CronPeriod, DatePeriod, IntervalPeriod -from lib.services.service import Service -from lib.processors.processor import Processor -from lib.parsers.parser import Parser -from lib.tasks.task import Task +from linspector.services.service import Service +from linspector.processors.processor import Processor +from linspector.parsers.parser import Parser +from linspector.tasks.task import Task MOD_SERVICES = "services" MOD_PROCESSORS = "processors" @@ -127,7 +127,7 @@ class ConfigParser: return mods[clazz] else: #mod = __import__(clazz) - p = join("lib", modPart, clazz + ".py") + p = join("linspector", modPart, clazz + ".py") mod = imp.load_source(clazz, p) mods[clazz] = mod return mod diff --git a/lib/config/periods.py b/linspector/config/periods.py similarity index 100% rename from lib/config/periods.py rename to linspector/config/periods.py diff --git a/lib/frontends/__init__.py b/linspector/core/__init__.py similarity index 100% rename from lib/frontends/__init__.py rename to linspector/core/__init__.py diff --git a/lib/core/command.py b/linspector/core/command.py similarity index 100% rename from lib/core/command.py rename to linspector/core/command.py diff --git a/lib/core/daemon.py b/linspector/core/daemon.py similarity index 100% rename from lib/core/daemon.py rename to linspector/core/daemon.py diff --git a/lib/core/interface.py b/linspector/core/interface.py similarity index 100% rename from lib/core/interface.py rename to linspector/core/interface.py diff --git a/lib/core/job.py b/linspector/core/job.py similarity index 100% rename from lib/core/job.py rename to linspector/core/job.py diff --git a/lib/core/linspector_daemon.py b/linspector/core/linspector_daemon.py similarity index 96% rename from lib/core/linspector_daemon.py rename to linspector/core/linspector_daemon.py index 2e01f10..ee9d940 100644 --- a/lib/core/linspector_daemon.py +++ b/linspector/core/linspector_daemon.py @@ -22,7 +22,7 @@ from ..core.daemon import Daemon """ TODO: Think about, that daemonizing this software is not our goal but when we want to that, this needs a rewrite and -should maybe move over to the daemon frontend. daemon.py will remain the the base for this and should stay in lib/core . +should maybe move over to the daemon frontend. daemon.py will remain the the base for this and should stay in linspector/core . Since a daemon it normally not a frontend we should think about how to handle this. When daemonizing a real frontend like "Lish" will make no sense but a frontend like "https" or "xmpp" could be useful anyway... """ diff --git a/lib/core/logger.py b/linspector/core/logger.py similarity index 100% rename from lib/core/logger.py rename to linspector/core/logger.py diff --git a/lib/core/scheduler.py b/linspector/core/scheduler.py similarity index 100% rename from lib/core/scheduler.py rename to linspector/core/scheduler.py diff --git a/lib/parsers/__init__.py b/linspector/frontends/__init__.py similarity index 100% rename from lib/parsers/__init__.py rename to linspector/frontends/__init__.py diff --git a/lib/frontends/frontend.py b/linspector/frontends/frontend.py similarity index 100% rename from lib/frontends/frontend.py rename to linspector/frontends/frontend.py diff --git a/lib/frontends/lish.py b/linspector/frontends/lish.py similarity index 99% rename from lib/frontends/lish.py rename to linspector/frontends/lish.py index 5f1f11b..4861cf0 100644 --- a/lib/frontends/lish.py +++ b/linspector/frontends/lish.py @@ -22,7 +22,7 @@ along with this program. If not, see . """ -from lib.frontends.frontend import Frontend +from linspector.frontends.frontend import Frontend import os from shlex import split as shsplit from cmd import Cmd diff --git a/lib/processors/__init__.py b/linspector/parsers/__init__.py similarity index 100% rename from lib/processors/__init__.py rename to linspector/parsers/__init__.py diff --git a/lib/parsers/parser.py b/linspector/parsers/parser.py similarity index 100% rename from lib/parsers/parser.py rename to linspector/parsers/parser.py diff --git a/lib/parsers/shell.py b/linspector/parsers/shell.py similarity index 95% rename from lib/parsers/shell.py rename to linspector/parsers/shell.py index 5c7ec91..3218e2d 100644 --- a/lib/parsers/shell.py +++ b/linspector/parsers/shell.py @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.parsers.parser import Parser +from linspector.parsers.parser import Parser class ShellParser(Parser): diff --git a/lib/services/__init__.py b/linspector/processors/__init__.py similarity index 100% rename from lib/services/__init__.py rename to linspector/processors/__init__.py diff --git a/lib/processors/mariadb.py b/linspector/processors/mariadb.py similarity index 94% rename from lib/processors/mariadb.py rename to linspector/processors/mariadb.py index e31e94e..5f92d9e 100644 --- a/lib/processors/mariadb.py +++ b/linspector/processors/mariadb.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.processors.processor import Processor +from linspector.processors.processor import Processor class MariadbProcessor(Processor): diff --git a/lib/processors/mongodb.py b/linspector/processors/mongodb.py similarity index 94% rename from lib/processors/mongodb.py rename to linspector/processors/mongodb.py index b5cbe0f..5d127cf 100644 --- a/lib/processors/mongodb.py +++ b/linspector/processors/mongodb.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.processors.processor import Processor +from linspector.processors.processor import Processor class MongodbProcessor(Processor): diff --git a/lib/processors/processor.py b/linspector/processors/processor.py similarity index 100% rename from lib/processors/processor.py rename to linspector/processors/processor.py diff --git a/lib/processors/syslog.py b/linspector/processors/syslog.py similarity index 94% rename from lib/processors/syslog.py rename to linspector/processors/syslog.py index 5060188..01fc7ad 100644 --- a/lib/processors/syslog.py +++ b/linspector/processors/syslog.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.processors.processor import Processor +from linspector.processors.processor import Processor class SyslogProcessor(Processor): diff --git a/lib/tasks/__init__.py b/linspector/services/__init__.py similarity index 100% rename from lib/tasks/__init__.py rename to linspector/services/__init__.py diff --git a/lib/services/http.py b/linspector/services/http.py similarity index 97% rename from lib/services/http.py rename to linspector/services/http.py index b9db8ef..7986370 100644 --- a/lib/services/http.py +++ b/linspector/services/http.py @@ -26,7 +26,7 @@ along with this program. If not, see . """ import urllib -from lib.services.service import Service +from linspector.services.service import Service class HttpService(Service): diff --git a/lib/services/ping.py b/linspector/services/ping.py similarity index 99% rename from lib/services/ping.py rename to linspector/services/ping.py index b102869..e85230f 100644 --- a/lib/services/ping.py +++ b/linspector/services/ping.py @@ -20,7 +20,7 @@ along with this program. If not, see . """ # http://code.activestate.com/recipes/409689-icmplib-library-for-creating-and-reading-icmp-pack/ -from lib.services.service import Service +from linspector.services.service import Service import struct diff --git a/lib/services/service.py b/linspector/services/service.py similarity index 100% rename from lib/services/service.py rename to linspector/services/service.py diff --git a/lib/services/shell.py b/linspector/services/shell.py similarity index 96% rename from lib/services/shell.py rename to linspector/services/shell.py index 26512a6..d840b1c 100644 --- a/lib/services/shell.py +++ b/linspector/services/shell.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.services.service import Service +from linspector.services.service import Service class ShellService(Service): diff --git a/lib/services/snmpget.py b/linspector/services/snmpget.py similarity index 97% rename from lib/services/snmpget.py rename to linspector/services/snmpget.py index dc59827..776efae 100644 --- a/lib/services/snmpget.py +++ b/linspector/services/snmpget.py @@ -20,7 +20,7 @@ along with this program. If not, see . """ #from pysnmp.entity.rfc3413.oneliner import cmdgen -from lib.services.service import Service +from linspector.services.service import Service class SnmpgetService(Service): diff --git a/lib/services/ssh.py b/linspector/services/ssh.py similarity index 97% rename from lib/services/ssh.py rename to linspector/services/ssh.py index 3ce2766..9b30ae1 100644 --- a/lib/services/ssh.py +++ b/linspector/services/ssh.py @@ -24,7 +24,7 @@ along with this program. If not, see . import paramiko import pprint import os -from lib.services.service import Service +from linspector.services.service import Service class SshService(Service): diff --git a/lib/services/tcpconnect.py b/linspector/services/tcpconnect.py similarity index 98% rename from lib/services/tcpconnect.py rename to linspector/services/tcpconnect.py index d1edf38..63bb028 100644 --- a/lib/services/tcpconnect.py +++ b/linspector/services/tcpconnect.py @@ -23,7 +23,7 @@ along with this program. If not, see . """ import socket -from lib.services.service import Service +from linspector.services.service import Service class TcpconnectService(Service): diff --git a/linspector/tasks/__init__.py b/linspector/tasks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/jabber.py b/linspector/tasks/jabber.py similarity index 97% rename from lib/tasks/jabber.py rename to linspector/tasks/jabber.py index f1e9476..cf1bc86 100644 --- a/lib/tasks/jabber.py +++ b/linspector/tasks/jabber.py @@ -22,7 +22,7 @@ along with this program. If not, see . """ import xmpp -from lib.tasks.task import Task +from linspector.tasks.task import Task class JabberTask(Task): diff --git a/lib/tasks/mail.py b/linspector/tasks/mail.py similarity index 98% rename from lib/tasks/mail.py rename to linspector/tasks/mail.py index 5551c2f..bd7f617 100644 --- a/lib/tasks/mail.py +++ b/linspector/tasks/mail.py @@ -24,7 +24,7 @@ along with this program. If not, see . import datetime import smtplib from email.mime.text import MIMEText -from lib.tasks.task import Task +from linspector.tasks.task import Task class MailTask(Task): diff --git a/lib/tasks/sms.py b/linspector/tasks/sms.py similarity index 96% rename from lib/tasks/sms.py rename to linspector/tasks/sms.py index 79d07dd..a5fd66a 100644 --- a/lib/tasks/sms.py +++ b/linspector/tasks/sms.py @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -from lib.tasks.task import Task +from linspector.tasks.task import Task class SmsTask(Task): diff --git a/lib/tasks/task.py b/linspector/tasks/task.py similarity index 100% rename from lib/tasks/task.py rename to linspector/tasks/task.py diff --git a/lib/tasks/tweet.py b/linspector/tasks/tweet.py similarity index 97% rename from lib/tasks/tweet.py rename to linspector/tasks/tweet.py index 388c7c2..68bf5ed 100644 --- a/lib/tasks/tweet.py +++ b/linspector/tasks/tweet.py @@ -22,7 +22,7 @@ along with this program. If not, see . """ import tweepy -from lib.tasks.task import Task +from linspector.tasks.task import Task class TweetTask(Task):