Created
October 19, 2022 20:37
-
-
Save jasonrahm/ef740a79359774aabadd0a9f6f092513 to your computer and use it in GitHub Desktop.
updating system syslog parameters on BIG-IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from urllib3.exceptions import InsecureRequestWarning | |
from urllib3 import disable_warnings | |
disable_warnings(InsecureRequestWarning) | |
from bigrest.bigip import BIGIP | |
syslog_include = """ | |
filter f_remote_loghost { | |
level(warn..emerg); | |
}; | |
destination d_remote_loghost { | |
tcp("10.7.3.11" port(1468)); | |
udp("10.7.3.11" port(514)); | |
}; | |
log { | |
source(s_syslog_pipe); | |
filter(f_remote_loghost); | |
destination(d_remote_loghost); | |
}; | |
""" | |
def instantiate_bigip(host, user, password): | |
try: | |
obj = BIGIP(host, user, password, session_verify=False) | |
except Exception as e: | |
print(f"Failed to connect to {host} due to {type(e).__name__}:\n") | |
print(f"{e}") | |
sys.exit() | |
return obj | |
def update_syslog(obj, syslog_include): | |
try: | |
sl = obj.load("/mgmt/tm/sys/syslog") | |
sl.properties["include"] = syslog_include | |
obj.save(sl) | |
except Exception as e: | |
print(f"Failed to update syslog due to {type(e).__name__}:\n") | |
print(f"{e}") | |
sys.exit() | |
if __name__ == "__main__": | |
hosts = ['ltm3.test.local'] | |
user = 'admin' | |
pw = 'admin' | |
for host in hosts: | |
print(f"\nInstantiating {host}") | |
bigip = instantiate_bigip(host, user, pw) | |
print(f"\n\tUpdating {host} syslog details") | |
update_syslog(bigip, syslog_include) | |
print("\n\n---syslog update complete---\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pip install requests and then you should be good to go. The bigrest module isn't handling dependencies properly, I'll talk to the author about that.