show users
show users
import requests
import json
"""
Modify these please
"""
url='http://<ip_address>:<port_number>/ins'
switchuser='<user_id>'
switchpassword='<password>'
myheaders={'content-type':'application/json'}
payload={
"ins_api":{
"version": "1.0",
"type": "cli_show",
"chunk": "0",
"sid": "1",
"input": "show users",
"output_format": "json"
}
}
response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)
json_output = json.loads(output)["ins_api"]["outputs"]["output"]["body"]
print(json.dumps(json_output, indent=4, sort_keys=True))
{
"TABLE_sessions": {
"ROW_sessions": {
"comment": "(173.39.55.43)",
"idle": ".",
"line": "pts/0",
"name": "admin",
"pid": 8946,
"time": "Jun 22 23:25"
}
}
}
<TABLE_sessions>
<ROW_sessions>
<name>admin</name>
<line>pts/0</line>
<time>Jun 22 23:25</time>
<idle>.</idle>
<pid>8946</pid>
<comment>(173.39.55.43)</comment>
</ROW_sessions>
</TABLE_sessions>
The show users command displays all CLI users currently accessing the switch.
For command descriptions, see the Cisco MDS 9000 Series Switches Command References.
Note: This sample output is generated for Cisco MDS 9000 Series NX-OS Release 8.4(2a) or later.
| CLI Output |
|---|
|
| Parameter | Description | Type |
|---|---|---|
| comment | System from which the user has logged in | String |
| idle | Time since when the user has been idle | String |
| line | Terminal through which the user has logged in | String |
| time | Timestamp when the user logged in the format ( ddd dd hh:mm ) | String |
| pid | Process ID | Integer |
| name | User name | String |