A user asked about manually setting the Controlup EdgeX location. It is possible to override the location using the IP address and a script is provided to check the IP address against known subnets and their corresponding locations. Locations must be set on the tenant side and must be in valid JSON with the property "LocationsByIpRange". ControlUp does not offer specific documentation for this feature. The script and full JSON example are included in the discussion.
Read the entire ‘Overriding Controlup Edge DX Location Manually’ thread below:
Afternoon, trying to find some details on how to manually set the edgedx location. Our current issue at the moment is all our device’s sit on our sd-wan. So the location data is being determined by our companies out bound connection. We are running iGel devices and all are running on the corporate network.
It’s possible to override location using the IP address, in the custom agent settings. In your case would you have different IP’s for each location?
Yes different IP subnets at each location was working on the script below but to be honest wasnt sure how edgedx received its location.
“`#!/bin/bash
Define the known list of subnets and their corresponding locations
declare -A subnets=(
["192.168.1.0/24"]="Location A"
["10.0.0.0/8"]="Location B"
["172.16.0.0/12"]="Location C"
# Add more subnets and corresponding locations as needed
)
Get the system’s IP address
ip_address=$(curl -s http://checkip.amazonaws.com)
Function to check if the IP address matches any subnet
function check_subnet() {
local ip=$1
for subnet in "${!subnets[@]}"; do
if [[ $(ipcalc -cs "$subnet" "$ip") -eq 0 ]]; then
echo "${subnets[$subnet]}"
return
fi
done
echo "Unknown Location"
}
Check the IP address against the known subnets
location=$(check_subnet "$ip_address")
Set the location accordingly
echo "Setting location to: $location"
Do whatever actions you need based on the location
For example, set environment variables, update configuration, etc.“`
You can’t set it on the client side. You set it on the tenant side
These are public IP addresses, which may make your efforts a bit harder.
Oh nice, does controlup have write up on this functionality? Just so I can reference it in or kb
I don’t think so. Typically settings on the agent settings section are meant to quickly address some use case.
If you need help around this, feel free to discuss it here
Sounds good, initial question is there anything appending the "LOCATIONSBYIPRANGE". My custom agent settings does not have this entry. Just want to make sure I dont miss anything that is needed.
The IP range might actually be internal. Stand by while I confirm that.
The custom agent settings need to be valid JSON. The locationsbyiprange property is a JSON array.
“`{
"ProcessExcludeList": "RuntimeBroker|ApplicationFrameHost|browser_broker|ctfmon|sppsvc|sihost|taskhostw|conhost",
"RecordProcsWithCpuOverThreshold": 2,
"RecordProcsWithMemoryOverThreshold": 2,
"ConvertLfToCrlfForWindowsScripts": true,
"LocationsByIpRange": [
{
"iprange": "192.168.8.0/24",
"city": "Groningen",
"latlon": "53.1, 6.5"
},
{
"iprange": "192.168.214.0/24",
"city": "Hollywood, FL",
"latlon": "26.0130991, -80.1536618"
},
{
"iprange": "192.168.188.0/24",
"city": "The Keys, FL",
"latlon": "24.6135186,-81.4735408"
},
{
"iprange": "192.168.212.0/24",
"city": "Fort Lauderdale, FL",
"latlon": "26.1179994, -80.1377305"
},
{
"iprange": "67.191.36.145/32",
"city": "MiamiPub",
"latlon": "25.7968774, -80.2789186"
},
{
"iprange": "31.168.39.90/32",
"city": "Düsseldorf",
"latlon": "51.2383712, 6.6742687"
},
{
"iprange": "10.20.30.0/24",
"city": "Düsseldorf",
"latlon": "51.2383712, 6.6742687"
},
{
"iprange": "10.21.30.0/24",
"city": "Düsseldorf",
"latlon": "51.2383712, 6.6742687"
},
{
"iprange": "10.100.1.126/32",
"city": "Lincoln, NE",
"latlon": "40.8136704, -96.7052787"
},
{
"iprange": "172.20.20.0/24",
"city": "Lincoln, NE",
"latlon": "40.8136704, -96.7052787"
},
{
"iprange": "192.168.88.5/32",
"city": "New Orleans, LA",
"latlon": "29.957609, -90.066292"
},
{
"iprange": "10.100.1.144/32",
"city": "Yellow Stone, WY",
"latlon": "44.4283314,-110.5905142"
}
]
}“`
Continue reading and comment on the thread ‘How to Set / Override the Controlup Edge DX Location Manually’. Not a member? Join Here!
Categories: All Archives, ControlUp Edge DX, ControlUp Scripts & Triggers