Add a disable HDD temperature option on the command line (issue #515)

pull/532/head^2
nicolargo 2015-02-20 22:45:20 +01:00
parent 183cbce7aa
commit 0a99b139b6
5 changed files with 50 additions and 6 deletions

1
NEWS
View File

@ -9,6 +9,7 @@ Enhancements and news features:
* Grab FAN speed in the Glances sensors plugin (issue #501)
* Allow logical mounts points in the FS plugin (issue #448)
* Add a --disable-hddtemp to disable HDD temperature module at startup (issue #515)
Bugs corrected:

View File

@ -143,6 +143,7 @@ Command-Line Options
--disable-fs disable filesystem module
--disable-network disable network module
--disable-sensors disable sensors module
--disable-hddtemp disable HDDTemp module
--disable-left-sidebar
disable left sidebar
--disable-process disable process module

View File

@ -110,6 +110,8 @@ Start the client browser (browser mode):\n\
dest='disable_fs', help=_('disable filesystem module'))
parser.add_argument('--disable-sensors', action='store_true', default=False,
dest='disable_sensors', help=_('disable sensors module'))
parser.add_argument('--disable-hddtemp', action='store_true', default=False,
dest='disable_hddtemp', help=_('disable HD Temperature module'))
parser.add_argument('--disable-raid', action='store_true', default=False,
dest='disable_raid', help=_('disable RAID module'))
parser.add_argument('--disable-docker', action='store_true', default=False,
@ -264,6 +266,11 @@ Start the client browser (browser mode):\n\
sys.exit(2)
logger.debug("History output path is set to {0}".format(args.path_history))
# Disable HDDTemp if sensors are disabled
if args.disable_sensors:
args.disable_hddtemp = True
logger.debug("Sensors and HDDTemp are disabled")
return args
def __hash_password(self, plain_password):

View File

@ -25,6 +25,7 @@ import socket
# Import Glances libs
from glances.plugins.glances_plugin import GlancesPlugin
from glances.core.glances_logging import logger
class Plugin(GlancesPlugin):
@ -39,7 +40,7 @@ class Plugin(GlancesPlugin):
GlancesPlugin.__init__(self, args=args)
# Init the sensor class
self.glancesgrabhddtemp = GlancesGrabHDDTemp()
self.glancesgrabhddtemp = GlancesGrabHDDTemp(args=args)
# We do not want to display the stat in a dedicated area
# The HDD temp is displayed within the sensors plugin
@ -73,8 +74,9 @@ class GlancesGrabHDDTemp(object):
"""Get hddtemp stats using a socket connection."""
def __init__(self, host='127.0.0.1', port=7634):
def __init__(self, host='127.0.0.1', port=7634, args=None):
"""Init hddtemp stats."""
self.args = args
self.host = host
self.port = port
self.cache = ""
@ -89,6 +91,10 @@ class GlancesGrabHDDTemp(object):
# Reset the list
self.reset()
# Only update if --disable-hddtemp is not set
if self.args.disable_hddtemp:
return
# Fetch the data
data = self.fetch()
@ -125,7 +131,10 @@ class GlancesGrabHDDTemp(object):
sck.connect((self.host, self.port))
data = sck.recv(4096)
sck.close()
except socket.error:
except socket.error as e:
logger.warning("Can not connect to an HDDtemp server ({0}:{1} => {2})".format(self.host, self.port, e))
logger.debug("Disable the HDDtemp module. Use the --disable-hddtemp to hide the previous message.")
self.args.disable_hddtemp = True
data = ""
return data

View File

@ -49,6 +49,10 @@ disable network module
.B \-\-disable-sensors
disable sensors module
.TP
.B \-\-disable-hddtemp
disable HDDTemp module
.TP
.TP
.B \-\-disable-left-sidebar
disable network, disk IO, FS and sensors modules
.TP
@ -210,9 +214,31 @@ Show/hide processes list (for low CPU consumption)
Switch between global CPU and per-CPU stats
.SH EXAMPLES
.TP
Refresh information every 5 seconds:
.B glances
\-t 5
Monitor local machine (standalone mode):
.B $ glances
.PP
Monitor local machine with the Web interface (Web UI):
.B $ glances -w
.PP
Glances web server started on http://0.0.0.0:61208/
.PP
Monitor local machine and export stats to a CSV file (standalone mode):
.B $ glances --export-csv
.PP
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
.B $ glances -t 5 --export-influxdb
.PP
Start a Glances server (server mode):
.B $ glances -s
.PP
Connect Glances to a Glances server (client mode):
.B $ glances -c <ip_server>
.PP
Connect Glances to a Glances server and export stats to a StatsD server (client mode):
.B $ glances -c <ip_server> --export-statsd
.PP
Start the client browser (browser mode):
.B $ glances --browser
.PP
.SH EXIT STATUS
Glances returns a zero exit status if it succeeds to print/grab information.