summaryrefslogtreecommitdiffstats
path: root/glances/plugins/glances_uptime.py
diff options
context:
space:
mode:
Diffstat (limited to 'glances/plugins/glances_uptime.py')
-rw-r--r--glances/plugins/glances_uptime.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/glances/plugins/glances_uptime.py b/glances/plugins/glances_uptime.py
index 12e1c22b..17d7871c 100644
--- a/glances/plugins/glances_uptime.py
+++ b/glances/plugins/glances_uptime.py
@@ -22,19 +22,19 @@
# Import system libs
from datetime import datetime, timedelta
-# Import psutil
-import psutil
-
# Import Glances libs
from glances.plugins.glances_plugin import GlancesPlugin
+# Import psutil
+import psutil
+
# SNMP OID
snmp_oid = {'_uptime': '1.3.6.1.2.1.1.3.0'}
class Plugin(GlancesPlugin):
- """Glances' uptime plugin.
+ """Glances uptime plugin.
stats is date (string)
"""
@@ -47,7 +47,7 @@ class Plugin(GlancesPlugin):
self.display_curse = True
# Set the message position
- self.set_align('right')
+ self.align = 'right'
# Init the stats
self.reset()
@@ -61,16 +61,15 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
- if self.get_input() == 'local':
+ if self.input_method == 'local':
# Update stats using the standard system lib
- uptime = datetime.now() - \
- datetime.fromtimestamp(psutil.boot_time())
+ uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
# Convert uptime to string (because datetime is not JSONifi)
self.stats = str(uptime).split('.')[0]
- elif self.get_input() == 'snmp':
+ elif self.input_method == 'snmp':
# Update stats using SNMP
- uptime = self.set_stats_snmp(snmp_oid=snmp_oid)['_uptime']
+ uptime = self.get_stats_snmp(snmp_oid=snmp_oid)['_uptime']
try:
# In hundredths of seconds
self.stats = str(timedelta(seconds=int(uptime) / 100))
@@ -82,11 +81,4 @@ class Plugin(GlancesPlugin):
def msg_curse(self, args=None):
"""Return the string to display in the curse interface."""
- # Init the return message
- ret = []
-
- # Add the line with decoration
- ret.append(self.curse_add_line(_("Uptime: {0}").format(self.stats)))
-
- # Return the message with decoration
- return ret
+ return [self.curse_add_line('Uptime: {0}'.format(self.stats))]