Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Display Hostname

sreebarcl_36723
Nimbostratus
Nimbostratus

Is there a cli command by which we can display the hostname of the f5 Device using the cli?

 

4 REPLIES 4

Samir_Jha_52506
Noctilucent
Noctilucent

In F5 unix shell you can print hostname name by typing command hostname.

 

Python SDK

 

>>> settings = bigip.sys.global_settings.load() >>> print settings.hostname LAB1.mydomain.com >>>

OR

 

Alternatively you can refer this

 

set hostname [tmsh::get_config /sys global-settings hostname] puts [tmsh::get_field_value [lindex $hostname 0] hostname]

Satoshi_Toyosa1
F5 Employee
F5 Employee

tmsh

tmsh list sys global-settings hostname

iControl REST

curl -sku admin: https:///mgmt/tm/sys/global-settings?\$select=hostname 

Malware_Mike_37
Altocumulus
Altocumulus

I wasn't able to get the code from f5_rock to work (it's most likely my fault) but I did get the hostname with the code below. It's a little verbose because I had to run the tmsh command to show the settings and then I used .lstrip and .strip to clean the data up. Happy coding!

 

from f5.bigip import ManagementRoot
mgmt = ManagementRoot("your_f5_ip_address", 'username', 'password')
x = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tmsh list sys global-settings hostname | grep "hostname""')
hostname = str(x.commandResult)
hostname = hostname.strip().lstrip('hostname').strip()
print(hostname)

Peter_Z
Nimbostratus
Nimbostratus

- from TMSH:

   tmsh list sys global-settings hostname

- from Linux shell (run util bash):

       echo $HOSTNAME