I think your way of doing is just wrong.
When you can not gather that information by code, what purpose shall it have?
In my thinking, when I am not able to get information by code, I would simple display output of console in my app somewhere.
Thats the unix philosophy, instead of having to have one app with all the functionality, you have multiple specialized programs that do one thing very good and whose output can be reused by other programs. Just for comparison, the "ifconfig" program has 1000 lines of code. So when you need that functionality in your program, you can decide if you want to have a few lines of calling ifconfig, or you want to implement all of this yourself.
This is also very important for rights management. For example to send ICMP requests, you need root rights, but you might not want to give all applications that need this root rights. So they call the system applcations "ping", "traceroute", etc., which have the required rights, but are much easier to keep track of any security issues because these applications basically just do one thing. No use input or anything else.
Another example where this is useful is for things like reading out hardware information can be quite annoying. Linux systems usually provide pseudofiles for this, but every distro might choose to put the pseudo files into another directory. Using the system tools provided (like ip addr, netstat, ifconfig, etc.) can provide the information in a uniform manner.
And the main advantage of this is, that it is very simple to debug, as all of these programs give the data in both human and machine readable form, you can debug your APIs by simply looking at the program output.
So there are a lot of reasons to do this. It's one of the Windows deseases that Microsoft thought that everything must be accissable through code APIs and DLLs whose calls must be implemented in each program that tries to use them. By having different programs provide the data in both human and machine readable form, it is much easier to get access to that data and to learn how to use it.