diff --git a/linspector/core/interface.py b/linspector/core/interface.py index e5a5cc9..77f7a01 100644 --- a/linspector/core/interface.py +++ b/linspector/core/interface.py @@ -155,4 +155,8 @@ class LinspectorInterface(object): pass def get_enabled_layouts(self): - self._config.get_enabled_layouts() \ No newline at end of file + self._config.get_enabled_layouts() + + def get_thread_count(self): + return {"Num Threads": str(self._scheduler._threadpool.num_threads), + "Max Threads": str(self._scheduler._threadpool.max_threads)} \ No newline at end of file diff --git a/linspector/frontends/lish.py b/linspector/frontends/lish.py index 55b1a73..33f524a 100644 --- a/linspector/frontends/lish.py +++ b/linspector/frontends/lish.py @@ -244,7 +244,12 @@ class LishCommander(Exit): print('''Manage logging''') def do_status(self, text): - print('''executed %s''' % text) + # print instance name from core config + print GREEN + "Hostname" + END + ":\t" + socket.gethostname() + # print instance uptime + print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count()) + thread_info = self.interface.get_thread_count() + print GREEN + "Threads" + END + ":\t" + str(thread_info["Num Threads"]) + "/" + str(thread_info["Max Threads"]) def help_status(self): print('''Show status information about the Linspector instance''') diff --git a/linspector/linspector.py b/linspector/linspector.py deleted file mode 100644 index dcb861f..0000000 --- a/linspector/linspector.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -The Linspector main thread. Here all scheduling is done so backends and -frontends can start before all jobs are scheduled. - -Copyright (c) 2011-2013 by 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 . -""" - -import datetime -import threading - -from logging import getLogger - -from core.job import Job - -logger = getLogger(__name__) - - -def handle_job(jobInfo): - jobInfo.handle_call() - - -class Linspector(threading.Thread): - def __init__(self, linConf, core, scheduler, q): - self.linConf = linConf - self.core = core - self.scheduler = scheduler - self.q = q - threading.Thread.__init__(self) - - def handle_job(self, jobInfo): - jobInfo.handle_call() - - def run(self): - start_date = datetime.datetime.now() - time_delta = 0 - jobs = [] - for layout in self.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(): - time_delta += 2.315379 - new_start_date = start_date + datetime.timedelta(seconds=time_delta) - job = Job(service, - host, - hostgroup.get_members(), - hostgroup.get_processors(), - self.core, - hostgroup) - schedulerJob = period.createJob(self.scheduler, job, handle_job, start_date=new_start_date) - if schedulerJob is not None: - job.set_job(schedulerJob) - jobs.append(job) - self.q.put(jobs) \ No newline at end of file