What Is My IP as found from a Google search

Recommended Posts

  • LogicMonitor Staff

This is just another Google results scrape like my exchange rate tracker (https://communities.logicmonitor.com/topic/1624-ridiculously-simple-currency-exchange-rate-monitor/), so it's more a couple of examples of how that can be done, than a particularly useful set of metrics for enterprises with fixed IPs.

I only built these because my home very-nearly-static IP changed the other day after my ISP did some work locally, so my carefully-selected whitelisting to access another cloud service from home failed. Boo hiss.

Note that these LogicModules will always be run by the collector, so the result will be whatever Google determine's your collector's public IP to be, regardless of which device you associate the LogicModules with.

For this reason they both have AppliesTo of hasCategory("collector") which I recommend you don't change.

Anyway... there's a straight and simple Webpage collection DataSource:

v1.0.0: KTFNWP

This calls "https://www.google.com/search?q=what+is+my+ip" and has four datapoints, each of which pulls one octet via a regex of the resultant page body, using e.g.:

(\d+)\.\d+\.\d+\.\d+.*Your public IP address

This is possible because Google will do the lookup for you and present the data in a consistent format; a brief check of the page source code and a visit to regex101.com is all that's then needed to determine suitable regexes:

IP address is not model's own.

This gives you one metric and one graph line per octet and you can set delta alerting thresholds if you wish.


Additionally, if you have LM Config, there's a ConfigSource that does much the same but (obviously) writes the result to a config, with the single line output "Google says my public IP address is", the IP again be regexed out of the Google response.

This will alert on any change.

ConfigSource v1.0.0: 3G9C63


Link to post
Share on other sites
  • 1 year later...

Hey Antony, this is great however for some reason no matter what host\customer I point this DataSource to I get the same IP address. Do you know if there has been any change in how google returns the values?

Also, turns out the configsource is under review too, any ideas when it will be approved?

Thank you!

Edited by wanabeninja@helient
Link to post
Share on other sites
  • LogicMonitor Staff

@wanabeninja@helient it should be out out of the review holding cell now.

I can't imagine Google would have done anything to break this. It works for me. Those hosts/customers aren't behind the same NAT gateway, are they? Or using a shared proxy?

Have they tried other sites that do this to see if they get the same result? I was always partial to ifconfig.me, and ipchicken.com, though please don't take that as an official LM endorsement :).

Link to post
Share on other sites

Thank you Michael for taking interest into this post.

As for the configsource, yes I just tried again and it's working, great success!

As for the getting the same Ip address for different host/customer, I've simply been staring at this far too long trying to get it to poll a non-collector. I've also tried https://bot.whatismyipaddress.com/ thinking maybe it was google end but nope, it's simply how this module is built and will ALWAYS look at the collector. 

I suppose the next request if possible is if we can allow this same code to point to any host and not just a collector, fingers crossed. 

Link to post
Share on other sites
  • LogicMonitor Staff

Hi, as you've found (and as commented in the original post), DataSource scripts are run by the collector so you'll always get the collector's (or its network's) external IP.

For a per-device result you could create a remote Powershell script for Windows devices and an SSH script for Linux devices that connected to the device assigned, and ran a suitable http request on the device, and grabbed that output. At that point the result would be for the monitored device rather than the collector, although of course if all the devices were on one network that only had one public-facing IP, that IP will still be the value returned from a Google search.

Link to post
Share on other sites

Bingo! Thanks Antony after a lot of egg on my face and the patience of an angel a LM Support Engineer I have all the pieces of the puzzle 

Step 1."PowerShell Remoting – Initial Setup" https://www.logicmonitor.com/support/terminology-syntax/scripting-support/powershell-tips-tricks/

Step 2. Invoke-RestMethod -Uri  http://ipinfo.io/json | Select -exp ip 


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.