mirror of https://github.com/nicolargo/glances.git
Add client/server managment from the command line
This commit is contained in:
parent
f5f3523109
commit
2316d8ebf4
|
|
@ -4270,6 +4270,7 @@ def printSyntax():
|
|||
print(_("\t-p PORT\t\tDefine the client/server TCP port (default: %d)" %
|
||||
server_port))
|
||||
print(_("\t-P password\tDefine a client/server password"))
|
||||
print(_("\tor --password\tEnter the password from the command line"))
|
||||
print(_("\t-r\t\tDisable process list"))
|
||||
print(_("\t-s\t\tRun Glances in server mode"))
|
||||
print(_("\t-t seconds\tSet refresh time in seconds (default: %d sec)" %
|
||||
|
|
@ -4303,6 +4304,28 @@ def signal_handler(signal, frame):
|
|||
end()
|
||||
|
||||
|
||||
def getpassword(description = "", confirm = False):
|
||||
"""
|
||||
Read a password from the command line (with confirmation if confirm = True)
|
||||
"""
|
||||
import getpass
|
||||
|
||||
if (description != ""):
|
||||
sys.stdout.write("%s\n" % description)
|
||||
|
||||
password1 = getpass.getpass(_("Password: "));
|
||||
if (confirm):
|
||||
password2 = getpass.getpass(_("Password (confirm): "))
|
||||
else:
|
||||
return password1
|
||||
|
||||
if (password1 == password2):
|
||||
return password1
|
||||
else:
|
||||
sys.stdout.write(_("[Warning] Passwords did not match, please try again...\n"))
|
||||
return getpassword(description = description, confirm = confirm)
|
||||
|
||||
|
||||
def main():
|
||||
# Glances - Init stuff
|
||||
######################
|
||||
|
|
@ -4459,6 +4482,8 @@ def main():
|
|||
if html_tag or csv_tag:
|
||||
print(_("Error: Cannot use both -s and -o flag"))
|
||||
sys.exit(2)
|
||||
if (password == ''):
|
||||
password = getpassword(description = _("Define the password for the Glances server"), confirm = True)
|
||||
|
||||
if client_tag:
|
||||
if html_tag or csv_tag:
|
||||
|
|
@ -4468,6 +4493,8 @@ def main():
|
|||
print(_("Error: Cannot use both -c and -C flag"))
|
||||
print(_(" Limits are set based on the server ones"))
|
||||
sys.exit(2)
|
||||
if (password == ''):
|
||||
password = getpassword(description = _("Enter the Glances server password"), confirm = False)
|
||||
|
||||
if html_tag:
|
||||
if not html_lib_tag:
|
||||
|
|
|
|||
Loading…
Reference in New Issue