How can I get the SMS Notification profile IP address from script?

I have two SMS Notification profiles, and I want to use one as master and the second one as backup.

I was planning on creating a script in my notification pipeline that will ping the Notif_SMS_1 IP address and use it if the ping is sucessfull, otherwise use the Notif_SMS_2.

How can I get from a scripting function the IP address of the SMS notification profile defined in the gateway ?

The ping function
def ping(ip, timeout = 200):
	import os
	return os.system("ping -n 1 -w " + str(timeout) + " " + ip) == 0