mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-23 17:22:46 +03:00
Complete overhaul of imports
Explicit is better than implicit.
This commit is contained in:
parent
db37ff4ad2
commit
b7bbd69a65
@ -21,8 +21,8 @@ Init the Glances software
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system lib
|
# Import system lib
|
||||||
import sys
|
|
||||||
import signal
|
import signal
|
||||||
|
import sys
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
# Note: others Glances libs will be imported optionnaly
|
# Note: others Glances libs will be imported optionnaly
|
||||||
|
@ -21,21 +21,18 @@ Manage the Glances' client
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
|
from xmlrpc.client import ServerProxy, ProtocolError
|
||||||
|
except ImportError: # Python 2
|
||||||
|
from xmlrpclib import ServerProxy, ProtocolError
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.core.glances_globals import __version__
|
from glances.core.glances_globals import __version__
|
||||||
from glances.outputs.glances_curses import glancesCurses
|
|
||||||
from glances.core.glances_stats import GlancesStatsClient
|
from glances.core.glances_stats import GlancesStatsClient
|
||||||
|
from glances.outputs.glances_curses import glancesCurses
|
||||||
try:
|
|
||||||
# Python 2
|
|
||||||
from xmlrpclib import ServerProxy, ProtocolError
|
|
||||||
except ImportError:
|
|
||||||
# Python 3
|
|
||||||
from xmlrpc.client import ServerProxy, ProtocolError
|
|
||||||
|
|
||||||
|
|
||||||
class GlancesClient():
|
class GlancesClient():
|
||||||
|
@ -17,24 +17,25 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__appname__ = 'glances'
|
|
||||||
|
|
||||||
# Import Glances lib
|
|
||||||
from glances.core.glances_globals import *
|
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import os
|
import os
|
||||||
try:
|
try:
|
||||||
# Python 2
|
|
||||||
from ConfigParser import RawConfigParser
|
|
||||||
from ConfigParser import NoOptionError
|
|
||||||
except ImportError:
|
|
||||||
# Python 3
|
|
||||||
from configparser import RawConfigParser
|
from configparser import RawConfigParser
|
||||||
from configparser import NoOptionError
|
from configparser import NoOptionError
|
||||||
|
except ImportError: # Python 2
|
||||||
|
from ConfigParser import RawConfigParser
|
||||||
|
from ConfigParser import NoOptionError
|
||||||
|
|
||||||
|
# Import Glances lib
|
||||||
|
from glances.core.glances_globals import (
|
||||||
|
__appname__,
|
||||||
|
is_Linux,
|
||||||
|
is_python3,
|
||||||
|
work_path
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config(object):
|
||||||
"""
|
"""
|
||||||
This class is used to access/read config file, if it exists
|
This class is used to access/read config file, if it exists
|
||||||
|
|
||||||
|
@ -19,31 +19,31 @@
|
|||||||
|
|
||||||
# Glances informations
|
# Glances informations
|
||||||
__appname__ = 'glances'
|
__appname__ = 'glances'
|
||||||
__version__ = "2.0_Alpha02"
|
__version__ = '2.0_Alpha02'
|
||||||
__author__ = "Nicolas Hennion <nicolas@nicolargo.com>"
|
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
|
||||||
__license__ = "LGPL"
|
__license__ = 'LGPL'
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
# Import PsUtil
|
# Import psutil
|
||||||
try:
|
try:
|
||||||
from psutil import __version__ as __psutil_version__
|
from psutil import __version__ as __psutil_version__
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('PsUtil module not found. Glances cannot start.')
|
print('psutil module not found. Glances cannot start.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# PSutil version
|
# psutil version
|
||||||
psutil_version = tuple([int(num) for num in __psutil_version__.split('.')])
|
psutil_version = tuple([int(num) for num in __psutil_version__.split('.')])
|
||||||
|
|
||||||
# Check PsUtil version
|
# Check psutil version
|
||||||
psutil_min_version = (2, 0, 0)
|
psutil_min_version = (2, 0, 0)
|
||||||
if (psutil_version < psutil_min_version):
|
if (psutil_version < psutil_min_version):
|
||||||
print('PsUtil version %s detected.' % __psutil_version__)
|
print('psutil version %s detected.' % __psutil_version__)
|
||||||
print('PsUtil 2.0 or higher is needed. Glances cannot start.')
|
print('psutil 2.0 or higher is needed. Glances cannot start.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Path definitions
|
# Path definitions
|
||||||
@ -75,8 +75,8 @@ else:
|
|||||||
locale_dir = None
|
locale_dir = None
|
||||||
gettext.install(gettext_domain, locale_dir)
|
gettext.install(gettext_domain, locale_dir)
|
||||||
|
|
||||||
# Instances shared between all Glances's scripts
|
# Instances shared between all Glances' scripts
|
||||||
#===============================================
|
# ===============================================
|
||||||
|
|
||||||
# glances_processes for processcount and processlist plugins
|
# glances_processes for processcount and processlist plugins
|
||||||
from glances.core.glances_processes import glancesProcesses
|
from glances.core.glances_processes import glancesProcesses
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import time
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.core.glances_globals import glances_processes
|
from glances.core.glances_globals import glances_processes
|
||||||
|
@ -21,15 +21,16 @@ Main Glances script
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.core.glances_globals import __appname__, __version__, __author__, __license__
|
|
||||||
from glances.core.glances_globals import *
|
|
||||||
# !!! Todo: rename class
|
|
||||||
from glances.core.glances_config import Config
|
from glances.core.glances_config import Config
|
||||||
|
from glances.core.glances_globals import (
|
||||||
|
__appname__,
|
||||||
|
__psutil_version__,
|
||||||
|
__version__
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GlancesMain(object):
|
class GlancesMain(object):
|
||||||
@ -76,7 +77,6 @@ class GlancesMain(object):
|
|||||||
output_file = None
|
output_file = None
|
||||||
output_folder = None
|
output_folder = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Init and manage command line arguments
|
# Init and manage command line arguments
|
||||||
self.init_arg()
|
self.init_arg()
|
||||||
@ -92,7 +92,6 @@ class GlancesMain(object):
|
|||||||
# Load the configuration file
|
# Load the configuration file
|
||||||
self.config.load()
|
self.config.load()
|
||||||
|
|
||||||
|
|
||||||
def init_arg(self):
|
def init_arg(self):
|
||||||
"""
|
"""
|
||||||
Init all the command line arguments
|
Init all the command line arguments
|
||||||
@ -106,7 +105,7 @@ class GlancesMain(object):
|
|||||||
self.parser.add_argument('-v', '--version',
|
self.parser.add_argument('-v', '--version',
|
||||||
action='version',
|
action='version',
|
||||||
version=_('%s v%s with PsUtil v%s')
|
version=_('%s v%s with PsUtil v%s')
|
||||||
% (__appname__.capitalize(), __version__, psutil_version))
|
% (__appname__.capitalize(), __version__, __psutil_version__))
|
||||||
# Client mode: set the client IP/name
|
# Client mode: set the client IP/name
|
||||||
self.parser.add_argument('-C', '--config',
|
self.parser.add_argument('-C', '--config',
|
||||||
help=_('path to the configuration file'))
|
help=_('path to the configuration file'))
|
||||||
@ -191,7 +190,6 @@ class GlancesMain(object):
|
|||||||
self.parser.add_argument('-f', '--file',
|
self.parser.add_argument('-f', '--file',
|
||||||
help=_('set the html output folder or csv file'))
|
help=_('set the html output folder or csv file'))
|
||||||
|
|
||||||
|
|
||||||
def parse_arg(self):
|
def parse_arg(self):
|
||||||
"""
|
"""
|
||||||
Parse command line argument
|
Parse command line argument
|
||||||
@ -266,7 +264,6 @@ class GlancesMain(object):
|
|||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def __get_password(self, description='', confirm=False):
|
def __get_password(self, description='', confirm=False):
|
||||||
"""
|
"""
|
||||||
Read a password from the command line (with confirmation if confirm = True)
|
Read a password from the command line (with confirmation if confirm = True)
|
||||||
@ -288,21 +285,18 @@ class GlancesMain(object):
|
|||||||
sys.stdout.write(_("[Warning] Passwords did not match, please try again...\n"))
|
sys.stdout.write(_("[Warning] Passwords did not match, please try again...\n"))
|
||||||
return self.__get_password(description=description, confirm=confirm)
|
return self.__get_password(description=description, confirm=confirm)
|
||||||
|
|
||||||
|
|
||||||
def is_standalone(self):
|
def is_standalone(self):
|
||||||
"""
|
"""
|
||||||
Return True if Glances is running in standalone mode
|
Return True if Glances is running in standalone mode
|
||||||
"""
|
"""
|
||||||
return not self.client_tag and not self.server_tag and not self.webserver_tag
|
return not self.client_tag and not self.server_tag and not self.webserver_tag
|
||||||
|
|
||||||
|
|
||||||
def is_client(self):
|
def is_client(self):
|
||||||
"""
|
"""
|
||||||
Return True if Glances is running in client mode
|
Return True if Glances is running in client mode
|
||||||
"""
|
"""
|
||||||
return self.client_tag and not self.server_tag
|
return self.client_tag and not self.server_tag
|
||||||
|
|
||||||
|
|
||||||
def is_server(self):
|
def is_server(self):
|
||||||
"""
|
"""
|
||||||
Return True if Glances is running in server mode
|
Return True if Glances is running in server mode
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system lib
|
import psutil
|
||||||
from psutil import process_iter, AccessDenied, NoSuchProcess
|
|
||||||
|
|
||||||
# Import Glances lib
|
# Import Glances lib
|
||||||
from glances.core.glances_globals import is_BSD, is_Mac, is_Windows
|
from glances.core.glances_globals import is_BSD, is_Mac, is_Windows
|
||||||
@ -136,7 +135,7 @@ class glancesProcesses:
|
|||||||
# Get the process IO counters
|
# Get the process IO counters
|
||||||
proc_io = proc.io_counters()
|
proc_io = proc.io_counters()
|
||||||
io_new = [proc_io.read_bytes, proc_io.write_bytes]
|
io_new = [proc_io.read_bytes, proc_io.write_bytes]
|
||||||
except AccessDenied:
|
except psutil.AccessDenied:
|
||||||
# Access denied to process IO (no root account)
|
# Access denied to process IO (no root account)
|
||||||
# Put 0 in all values (for sort) and io_tag = 0 (for display)
|
# Put 0 in all values (for sort) and io_tag = 0 (for display)
|
||||||
procstat['io_counters'] = [0, 0] + [0, 0]
|
procstat['io_counters'] = [0, 0] + [0, 0]
|
||||||
@ -174,7 +173,7 @@ class glancesProcesses:
|
|||||||
time_since_update = getTimeSinceLastUpdate('process_disk')
|
time_since_update = getTimeSinceLastUpdate('process_disk')
|
||||||
|
|
||||||
# For each existing process...
|
# For each existing process...
|
||||||
for proc in process_iter():
|
for proc in psutil.process_iter():
|
||||||
try:
|
try:
|
||||||
# Get stats using the PSUtil
|
# Get stats using the PSUtil
|
||||||
procstat = self.__get_process_stats(proc)
|
procstat = self.__get_process_stats(proc)
|
||||||
@ -200,7 +199,7 @@ class glancesProcesses:
|
|||||||
self.processcount['thread'] += proc.num_threads()
|
self.processcount['thread'] += proc.num_threads()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
except (NoSuchProcess, AccessDenied):
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# Update processlist
|
# Update processlist
|
||||||
|
@ -18,34 +18,23 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import json
|
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
import json
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
|
from xmlrpc.server import SimpleXMLRPCRequestHandler
|
||||||
|
from xmlrpc.server import SimpleXMLRPCServer
|
||||||
|
except ImportError: # Python 2
|
||||||
|
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
|
||||||
|
from SimpleXMLRPCServer import SimpleXMLRPCServer
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.core.glances_globals import __version__
|
from glances.core.glances_globals import __version__
|
||||||
from glances.core.glances_stats import GlancesStatsServer
|
from glances.core.glances_stats import GlancesStatsServer
|
||||||
from glances.core.glances_timer import Timer
|
from glances.core.glances_timer import Timer
|
||||||
|
|
||||||
# Other imports
|
|
||||||
try:
|
|
||||||
# Python 2
|
|
||||||
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
|
|
||||||
from SimpleXMLRPCServer import SimpleXMLRPCServer
|
|
||||||
except ImportError:
|
|
||||||
# Python 3
|
|
||||||
from xmlrpc.server import SimpleXMLRPCRequestHandler
|
|
||||||
from xmlrpc.server import SimpleXMLRPCServer
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Python 2
|
|
||||||
from xmlrpclib import ServerProxy, ProtocolError
|
|
||||||
except ImportError:
|
|
||||||
# Python 3
|
|
||||||
from xmlrpc.client import ServerProxy, ProtocolError
|
|
||||||
|
|
||||||
|
|
||||||
class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler):
|
class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler):
|
||||||
"""
|
"""
|
||||||
|
@ -17,13 +17,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
import collections
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import collections
|
|
||||||
|
|
||||||
# Import Glances libs
|
|
||||||
from glances.core.glances_globals import *
|
|
||||||
|
|
||||||
|
|
||||||
class GlancesStats(object):
|
class GlancesStats(object):
|
||||||
|
@ -17,19 +17,15 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system lib
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from bottle import Bottle, template, static_file, TEMPLATE_PATH
|
from bottle import Bottle, template, static_file, TEMPLATE_PATH
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('Bottle module not found. Glances cannot start in web server mode.')
|
print('Bottle module not found. Glances cannot start in web server mode.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Import Glances lib
|
|
||||||
from glances.core.glances_timer import Timer
|
|
||||||
from glances.core.glances_globals import glances_logs, glances_processes
|
|
||||||
|
|
||||||
|
|
||||||
class glancesBottle:
|
class glancesBottle:
|
||||||
"""
|
"""
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system lib
|
|
||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
|
import msvcrt
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import colorconsole
|
import colorconsole
|
||||||
import colorconsole.terminal
|
import colorconsole.terminal
|
||||||
@ -26,12 +28,10 @@ except ImportError:
|
|||||||
print('Colorconsole module not found. Glances cannot start in standalone mode.')
|
print('Colorconsole module not found. Glances cannot start in standalone mode.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import msvcrt
|
|
||||||
import threading
|
|
||||||
try:
|
try:
|
||||||
import Queue as queue
|
|
||||||
except ImportError:
|
|
||||||
import queue
|
import queue
|
||||||
|
except ImportError: # Python 2
|
||||||
|
import Queue as queue
|
||||||
|
|
||||||
|
|
||||||
class ListenGetch(threading.Thread):
|
class ListenGetch(threading.Thread):
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Import Glances lib
|
# Import Glances lib
|
||||||
from glances.core.glances_timer import Timer
|
|
||||||
from glances.core.glances_globals import glances_logs, glances_processes, is_Windows
|
from glances.core.glances_globals import glances_logs, glances_processes, is_Windows
|
||||||
|
from glances.core.glances_timer import Timer
|
||||||
|
|
||||||
# Import curses lib for "normal" operating system and consolelog for Windows
|
# Import curses lib for "normal" operating system and consolelog for Windows
|
||||||
if (not is_Windows):
|
if not is_Windows:
|
||||||
try:
|
try:
|
||||||
import curses
|
import curses
|
||||||
import curses.panel
|
import curses.panel
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_globals import glances_logs
|
from glances.core.glances_globals import glances_logs
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
Batinfo (batterie) plugin
|
Batinfo (batterie) plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Batinfo library (optional; Linux-only)
|
||||||
# batinfo library (optional; Linux-only)
|
|
||||||
try:
|
try:
|
||||||
import batinfo
|
import batinfo
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -17,11 +17,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
import psutil
|
||||||
# Check for PSUtil already done in the glances_core script
|
|
||||||
from psutil import cpu_count
|
|
||||||
|
|
||||||
# Import Glances libs
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -55,8 +52,8 @@ class Plugin(GlancesPlugin):
|
|||||||
# Return None if undefine
|
# Return None if undefine
|
||||||
core_stats = {}
|
core_stats = {}
|
||||||
try:
|
try:
|
||||||
core_stats["phys"] = cpu_count(logical=False)
|
core_stats["phys"] = psutil.cpu_count(logical=False)
|
||||||
core_stats["log"] = cpu_count()
|
core_stats["log"] = psutil.cpu_count()
|
||||||
except NameError:
|
except NameError:
|
||||||
core_stats = None
|
core_stats = None
|
||||||
|
|
||||||
|
@ -20,11 +20,8 @@
|
|||||||
Glances CPU plugin
|
Glances CPU plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
import psutil
|
||||||
# Check for PSUtil already done in the glances_core script
|
|
||||||
from psutil import cpu_times_percent
|
|
||||||
|
|
||||||
# Import Glances libs
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +54,7 @@ class Plugin(GlancesPlugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Grab CPU using the PSUtil cpu_times_percent method
|
# Grab CPU using the PSUtil cpu_times_percent method
|
||||||
cputimespercent = cpu_times_percent(interval=0.0, percpu=False)
|
cputimespercent = psutil.cpu_times_percent(interval=0.0, percpu=False)
|
||||||
|
|
||||||
# Get all possible value for CPU stats
|
# Get all possible value for CPU stats
|
||||||
# user
|
# user
|
||||||
|
@ -20,12 +20,11 @@
|
|||||||
Glances CPU plugin
|
Glances CPU plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system lib
|
import psutil
|
||||||
from psutil import disk_io_counters
|
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_timer import getTimeSinceLastUpdate
|
from glances.core.glances_timer import getTimeSinceLastUpdate
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
@ -62,7 +61,7 @@ class Plugin(GlancesPlugin):
|
|||||||
# write_bytes: number of bytes written
|
# write_bytes: number of bytes written
|
||||||
# read_time: time spent reading from disk (in milliseconds)
|
# read_time: time spent reading from disk (in milliseconds)
|
||||||
# write_time: time spent writing to disk (in milliseconds)
|
# write_time: time spent writing to disk (in milliseconds)
|
||||||
diskiocounters = disk_io_counters(perdisk=True)
|
diskiocounters = psutil.disk_io_counters(perdisk=True)
|
||||||
|
|
||||||
# Previous disk IO stats are stored in the diskio_old variable
|
# Previous disk IO stats are stored in the diskio_old variable
|
||||||
diskio = []
|
diskio = []
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system lib
|
import psutil
|
||||||
from psutil import disk_partitions, disk_usage
|
|
||||||
|
|
||||||
# Import Glances libs
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -48,14 +46,14 @@ class glancesGrabFs:
|
|||||||
# Grab the stats using the PsUtil disk_partitions
|
# Grab the stats using the PsUtil disk_partitions
|
||||||
# If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)
|
# If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)
|
||||||
# and ignore all others (e.g. memory partitions such as /dev/shm)
|
# and ignore all others (e.g. memory partitions such as /dev/shm)
|
||||||
fs_stat = disk_partitions(all=False)
|
fs_stat = psutil.disk_partitions(all=False)
|
||||||
for fs in range(len(fs_stat)):
|
for fs in range(len(fs_stat)):
|
||||||
fs_current = {}
|
fs_current = {}
|
||||||
fs_current['device_name'] = fs_stat[fs].device
|
fs_current['device_name'] = fs_stat[fs].device
|
||||||
fs_current['fs_type'] = fs_stat[fs].fstype
|
fs_current['fs_type'] = fs_stat[fs].fstype
|
||||||
fs_current['mnt_point'] = fs_stat[fs].mountpoint
|
fs_current['mnt_point'] = fs_stat[fs].mountpoint
|
||||||
# Grab the disk usage
|
# Grab the disk usage
|
||||||
fs_usage = disk_usage(fs_current['mnt_point'])
|
fs_usage = psutil.disk_usage(fs_current['mnt_point'])
|
||||||
fs_current['size'] = fs_usage.total
|
fs_current['size'] = fs_usage.total
|
||||||
fs_current['used'] = fs_usage.used
|
fs_current['used'] = fs_usage.used
|
||||||
fs_current['avail'] = fs_usage.free
|
fs_current['avail'] = fs_usage.free
|
||||||
|
@ -22,8 +22,12 @@ Just a stupid plugin to display the help screen
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
|
from glances.core.glances_globals import (
|
||||||
|
__appname__,
|
||||||
|
__psutil_version__,
|
||||||
|
__version__
|
||||||
|
)
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
from glances.core.glances_globals import __appname__, __version__, __psutil_version__
|
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
|
@ -21,11 +21,11 @@ Glances load plugin
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
from os import getloadavg
|
import os
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.plugins.glances_core import Plugin as CorePlugin
|
from glances.plugins.glances_core import Plugin as CorePlugin
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
@ -60,7 +60,7 @@ class Plugin(GlancesPlugin):
|
|||||||
|
|
||||||
# Get the load using the os standard lib
|
# Get the load using the os standard lib
|
||||||
try:
|
try:
|
||||||
load = getloadavg()
|
load = os.getloadavg()
|
||||||
except OSError:
|
except OSError:
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
else:
|
else:
|
||||||
|
@ -20,11 +20,8 @@
|
|||||||
Glances virtual memory plugin
|
Glances virtual memory plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
import psutil
|
||||||
# Check for PSUtil already done in the glances_core script
|
|
||||||
from psutil import virtual_memory
|
|
||||||
|
|
||||||
# from ..plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +50,7 @@ class Plugin(GlancesPlugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Grab MEM using the PSUtil virtual_memory method
|
# Grab MEM using the PSUtil virtual_memory method
|
||||||
vm_stats = virtual_memory()
|
vm_stats = psutil.virtual_memory()
|
||||||
|
|
||||||
# Get all the memory stats (copy/paste of the PsUtil documentation)
|
# Get all the memory stats (copy/paste of the PsUtil documentation)
|
||||||
# total: total physical memory available.
|
# total: total physical memory available.
|
||||||
|
@ -20,11 +20,8 @@
|
|||||||
Glances swap memory plugin
|
Glances swap memory plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
import psutil
|
||||||
# Check for PSUtil already done in the glances_core script
|
|
||||||
from psutil import swap_memory
|
|
||||||
|
|
||||||
# from ..plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +50,7 @@ class Plugin(GlancesPlugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Grab SWAP using the PSUtil swap_memory method
|
# Grab SWAP using the PSUtil swap_memory method
|
||||||
sm_stats = swap_memory()
|
sm_stats = psutil.swap_memory()
|
||||||
|
|
||||||
# Get all the swap stats (copy/paste of the PsUtil documentation)
|
# Get all the swap stats (copy/paste of the PsUtil documentation)
|
||||||
# total: total swap memory in bytes
|
# total: total swap memory in bytes
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import Glances lib
|
# Import Glances lib
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_monitor_list import monitorList as glancesMonitorList
|
from glances.core.glances_monitor_list import monitorList as glancesMonitorList
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
|
@ -21,11 +21,11 @@ Glances Network interface plugin
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Import system libs
|
||||||
from psutil import net_io_counters
|
import psutil
|
||||||
|
|
||||||
# Import Glances lib
|
# Import Glances lib
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_timer import getTimeSinceLastUpdate
|
from glances.core.glances_timer import getTimeSinceLastUpdate
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
@ -50,7 +50,6 @@ class Plugin(GlancesPlugin):
|
|||||||
# Init stats
|
# Init stats
|
||||||
self.network_old = []
|
self.network_old = []
|
||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
Update network stats
|
Update network stats
|
||||||
@ -58,7 +57,7 @@ class Plugin(GlancesPlugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Grab network interface stat using the PsUtil net_io_counter method
|
# Grab network interface stat using the PsUtil net_io_counter method
|
||||||
netiocounters = net_io_counters(pernic=True)
|
netiocounters = psutil.net_io_counters(pernic=True)
|
||||||
|
|
||||||
# Previous network interface stats are stored in the network_old variable
|
# Previous network interface stats are stored in the network_old variable
|
||||||
network = []
|
network = []
|
||||||
|
@ -20,9 +20,8 @@
|
|||||||
CPU stats (per cpu)
|
CPU stats (per cpu)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system libs
|
# Check for psutil already done in the glances_core script
|
||||||
# Check for PSUtil already done in the glances_core script
|
import psutil
|
||||||
from psutil import cpu_times
|
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
@ -58,7 +57,7 @@ class Plugin(GlancesPlugin):
|
|||||||
"""
|
"""
|
||||||
# Grab CPU using the PSUtil cpu_times method
|
# Grab CPU using the PSUtil cpu_times method
|
||||||
# Per-CPU
|
# Per-CPU
|
||||||
percputime = cpu_times(percpu=True)
|
percputime = psutil.cpu_times(percpu=True)
|
||||||
percputime_total = []
|
percputime_total = []
|
||||||
for i in range(len(percputime)):
|
for i in range(len(percputime)):
|
||||||
percputime_total.append(percputime[i].user +
|
percputime_total.append(percputime[i].user +
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_globals import glances_processes
|
from glances.core.glances_globals import glances_processes
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
|
||||||
from glances.core.glances_globals import glances_processes
|
from glances.core.glances_globals import glances_processes
|
||||||
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(GlancesPlugin):
|
class Plugin(GlancesPlugin):
|
||||||
|
@ -17,11 +17,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
|
||||||
# Check for PSUtil already done in the glances_core script
|
|
||||||
from psutil import __version__ as __psutil_version__
|
from psutil import __version__ as __psutil_version__
|
||||||
|
|
||||||
# Import Glances libs
|
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Import system libs
|
# Sensors library (optional; Linux-only)
|
||||||
# sensors library (optional; Linux-only)
|
|
||||||
try:
|
try:
|
||||||
import sensors
|
import sensors
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -28,7 +27,6 @@ except ImportError:
|
|||||||
from glances.core.glances_globals import is_python3
|
from glances.core.glances_globals import is_python3
|
||||||
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
|
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
# from glances.core.glances_timer import getTimeSinceLastUpdate
|
|
||||||
|
|
||||||
|
|
||||||
class glancesGrabSensors:
|
class glancesGrabSensors:
|
||||||
|
Loading…
Reference in New Issue
Block a user