Provides IP location information for clients, including geographical and organizational data. The module collects location data when the client's WAN IP address changes and displays it in a user-friendly format with relative timestamps showing how long ago the IP address last changed.
Data can be viewed under the IP Location tab on the client details page or using the IP Location list view.
-
Copy the module to your MunkiReport modules directory:
cp -r ip_location /path/to/munkireport/local/modules/
-
Run the database migration:
php /path/to/munkireport/index.php migrate
This module uses the ipinfo.io API to gather location data. You will need to:
-
Register for an API token at https://ipinfo.io/
-
Create a plist file at
/Library/Preferences/com.gal.iplocation.plist
with your token:sudo defaults write /Library/Preferences/com.gal.iplocation.plist Token "your_token_here"
-
Deploy the script to your managed clients:
# Copy the script to your Munki repository cp ip_location.sh /path/to/munki/repo/scripts/
-
Add the script to your Munki manifests or use a management tool to deploy it.
The module works by:
- IP Detection: The script detects the client's current WAN IP address
- Change Detection: Only fetches new location data when the IP address changes
- Data Collection: Uses the ipinfo.io API to get geographical and organizational data
- Caching: Stores the last known IP to avoid unnecessary API calls
- Reporting: Sends the data to MunkiReport for display
The script includes intelligent caching to minimize API calls and only updates location data when the client's IP address actually changes.
- id - int - Primary key
- serial_number - varchar(255) - Unique client identifier
- ip - varchar(255) - IP address
- hostname - varchar(255) - Hostname
- city - varchar(255) - City
- region - varchar(255) - Region/State/Province
- country - varchar(255) - Country
- location - varchar(255) - Geographical location coordinates
- organization - varchar(255) - Organization/ISP
- postal_code - varchar(255) - Postal/ZIP code
- timezone - varchar(255) - Timezone
- last_update - bigInteger - Unix timestamp showing when the IP address last changed (formatted as relative time in listings)
- Smart Caching: Only updates when IP address changes
- Error Handling: Robust error handling for network issues
- Data Validation: Validates IP addresses and API responses
- Relative Timestamps: Displays "time since last IP change" in listing views
- Comprehensive Data: Includes geographical, organizational, and timezone information
This module provides the following widgets:
- IP Location City
- IP Location Region
- IP Location Country
- IP Location Organization
- IP Location Postal Code
- IP Location Timezone
The module will automatically collect data when:
- The script runs and detects a new IP address
- Force refresh is enabled via
FORCE_REFRESH=1
environment variable - The client's WAN IP address changes
Data is displayed in the MunkiReport interface with:
- Relative timestamps showing how long ago the IP address last changed (e.g., "2 hours ago", "3 days ago")
- Full date/time available as tooltips
- Organized geographical and organizational information
Script not running: Ensure the script has execute permissions and is properly deployed to clients.
No data appearing: Check that the API token is correctly configured and the script has network access.
API errors: Verify your ipinfo.io token is valid and has sufficient quota.
Permission errors: The script needs to write to /Library/Preferences/com.gal.iplocation.plist
for caching.
You can test the script manually:
# Test with a specific IP
FORCE_REFRESH=1 wanIP=8.8.8.8 ./ip_location.sh
# Check the output
cat cache/ip_location.txt
The script will output location data in the format expected by MunkiReport.