Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i know the actual geographical location of a database?

I am tasked to get the location where our SQL Server database is geographically located via C# code because it may vary time to time due to frequent relocation of our database to protect it from physical and cyber harm. Is this possible or another dream of my boss thanks in advance.

like image 524
Allan Chua Avatar asked Oct 28 '11 06:10

Allan Chua


4 Answers

1 - Buy somethihng like this. It's a UPS GPS receiver.

2 - Connect it to the server machine.

3 - Write a batch or shell script that will call the GPS software and return the current position.

4 - Use xp_cmdshell to call this script and return the current position via SQL Server query.

like image 86
JNK Avatar answered Nov 10 '22 21:11

JNK


Buy an iPhone/Android phone and have it sellotaped to the top of the machine that has the database on it. Write a quick app to have it look at the GPS API and post it's position to the database the phone is connected on using some kind of JSON/SOAP API over HTTPS (for security purposes).

You can then access the GPS information from where you are using C#.

Edit

Working with the GPS on Mono/iPhone: http://drdobbs.com/mobility/222600599

Example code, GPS on Mono/Android: https://github.com/gshackles/Sample-Projects/blob/master/MonoDroid/MonoDroidSamples/MonoDroidSamples/DemoActivities/LocationDemo/LocationActivity.cs

like image 32
Moo-Juice Avatar answered Nov 10 '22 22:11

Moo-Juice


The simplest solution is to do a DNS lookup, then use an IP location service as Cody suggested. Try this:

var foo = Dns.GetHostEntry("database.windows.net");

Once you've got your IP address, you'll need to load something like http://www.iplocationfinder.com/65.55.23.107 using an HttpWebRequest, unless you want to pay for an IP location database. Once you've got the response to the HttpWebRequest, you can use a regular expression to parse the location name, or latitude and longitude if you need that instead.

like image 21
Ade Stringer Avatar answered Nov 10 '22 23:11

Ade Stringer


Do you have so many servers which are moved around overnight in your company or is this for a cloud db setup? the IP address is probably a basic inaccurate-better than nothing starting point.

like image 4
Davide Piras Avatar answered Nov 10 '22 21:11

Davide Piras