well there are generally three ways to run osquery queries programatically:
- on the local host by execing osqueryi
- on the local host by using IPC with a running osqueryd
- via the API of a osquery management server which exposes an API for running queries