-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmdblookup usability #135
Comments
That sounds like a useful tool, but a different tool than The use case for Also, |
Hmm. So it's just a debugging tool. At least this makes some of these things understandable, but it's hardly satisfying. And the documentation doesn't quite advertise it as such. It shouldn't be too hard to write something a little more specialised as a sample app, would it? |
This is how one gets the AS number:
|
I'm not even sure the default usage works. When I run
I get the error: In the unfiltered output the keys "names" are there, "en" as well. Anyone with more experience? At any rate, I absolutely second @fstirlitz's idea for HR output and parseable JSON. |
Giving a statc path See the docs! |
Thank you, though for that I'd also have to install
Don't know if it'll work with every record. (?) |
You can loop through all 2^32 IP addresses and see. (maybe python is more manageable) |
I am having the same issue as @JayBrown where I specify:
In this case, I get the If I execute the command without specifying 'iso_code' then I get the following output:
So I am able to narrow down the results to just the "country" JSON record, but I cannot specify anything else contained within that record. Thoughts? |
@macvelli, the following works fine for me:
Could you provide the full command you are using, the version of |
Thanks for the feedback @oschwald, I appreciate it. Your example worked for me as well. I am executing mmdblookup in a Bash script and it turns out the problem has something to do with Bash. The following fails for me when there are more than one [DATA PATH] arguments specified on the command-line:
If I remove the double-quotes around $dataPath, it suddenly works. |
This is how I hacked it in NodeJS, hehe
|
Users without nodejs may use sed to restore valid JSON and jq to parse it: $ mmdblookup --file /var/lib/GeoIP/GeoLite2-ASN.mmdb --ip 1.1.1.1 \
| sed -e ':a;N;$!ba;s/\n/ /g' -e 's/ <[a-z0-9_]\+>/,/g' -e 's/,\s\+}/}/g' \
| jq '"AS\(.autonomous_system_number) \(.autonomous_system_organization)"'
"AS13335 Cloudflare, Inc." |
@szepeviktor - I am trying to get your example to work. I'd rather do it the right way, that dirty-json library is a quick fix for nodeJs. what am i doing wrong?
|
:-)
is the output! |
Right, I did figure that.. when I run this:
I get....
|
Yes, the pipe sign is missing between Try |
Now I get the following error...
|
Now the ending quotes are missing: |
...and these sed expressions are for GeoLite2-ASN.mmdb, not for city database. |
Here is another NodeJS code I did for everyone's reference, lot slower because I have to run mulitple commands.
|
What I'd like to have is something that replicates the functionality of the old geoiplookup and geoiplooku6 commands: pass IP address as the only argument, get information from all available databases in human-readable format. |
e.g. https://github.com/szepeviktor/debian-server-tools/blob/master/tools/geoiplookup-as |
For macOS it would be: Use GNU sed to parse. |
Another shell wrapper (above sed foo did not work for me, some commas were missing from output)
PS: sed foo nicked from @fstirlitz ? https://wiki.archlinux.org/index.php/User:Fstirlitz/quick_and_dirty_geoip_lookup_script |
Until we have a usable output format from mmdblookup, I use this perl pipe alternative to just get the country name:
|
I'd like it to be parseable JSON, wasted a lot of time with it 👎 |
advertisment begin
and it can also use DB-IP.com MMDB instead (or as fallback)... |
As it stands this tool is very unfriendly to the UNIX philosophy of having commands always output a format thats parseable by later commands. When the JSON output isn't valid JSON every user who has to use this tool ends up wasting hours having to hack around it. Please at least add a flag like OP said it eloquently enough already, and that was almost 8 months ago!
Another note to add aside from the type annotations, why does the query output come wrapped with quotes and two unneeded newlines? It adds another layer of parsing difficulty: $ mmdblookup --file /usr/local/var/GeoIP/GeoLite2-City.mmdb --ip 75.37.71.246 city names en
"Oakland" <utf8_string>
Should just be: $ mmdblookup --file /usr/local/var/GeoIP/GeoLite2-City.mmdb --ip 75.37.71.246 city names en
Oakland If scripts later on down the line need quotes, they can add it themselves.
(Note text streams, not custom "JSON-like" streams) |
I am going to close this issue. It has become a collection of unrelated feature requests. Some of them may be appropriate enhancements to |
Opened a new ticket for two specific feature requests with a smaller scope than this issue: a |
Hopefully this isn't off topic but wireshark comes with |
We have recently released While the intent of It's in beta. We would welcome you to try it and provide any feedback you may have on its issues page. |
The link may need a correction: https://github.com/maxmind/mmdbinspect |
I've got several small issues with the
mmdblookup
command-line utility.First of all, its output format is type-annotated pseudo-JSON, which on one hand is too verbose to display in a console (for manual use), and on the other cannot be parsed with existing tools. Ideally, I'd like it to be actual parseable JSON, with an option to display something human-readable, like:
The utility also follows the Simon Says school of command-line parsing: it requires me each time to type both
--ip
and--file
options. I'd much rather simply typemmdblookup 108.168.255.243
; the program should take any 'unprefixed' command-line arguments as IP addresses, and by default use a database from a well-known location in the file system (somewhere in/var/lib
). Even better, DNS resolution could be implemented in the utility, so that you could simply runmmdblookup maxmind.com
without invoking a separate program to resolve the hostname.Lastly, error messages from the utility contain gratuitous whitespace. The utility also spews the entirety of the built-in help text when it doesn't like the used command-line syntax; I think a 'Run "mmdblookup --help" for usage' message would suffice here. It's what most other command-line programs do.
I can work around all of these deficiencies by wrapping
mmdblookup
in a shell script, but... well, why should I have to?The text was updated successfully, but these errors were encountered: