An agent to save incoming data from the satellite to a database and communicate with clients to receive that data.
git clone https://github.com/spjy/cosmos-mongodb.git # clone into cosmos/source/tools/
cd cosmos-mongodb
# Make build folder
mkdir build
cd build
# Compile
cmake ../source
make
You may need to change the IP and port of the MongoDB server. To do this, on lines 107 and 114, change server:27017
to the respective ip:port
.
After saving your changes, simply run make
in the build folder again and run.
./agent_mongo --database database_name
The websocket query listening port is 8080. These are socket requests are used to get data from the agent. The websocket live listening port is 8081. These socket requests are used to get data as it is coming in.
You may send a query string to this endpoint to query the MongoDB database.
Body: database=db?collection=coll?multiple=true?query={"key"}?options={"opt": "val"}
Options:
- database (the database name to query)
- collection (the collection name to query)
- multiple (whether to return an object or array
- query (the JSON to query the MongoDB database; see MongoDB docs for more complex queries)
- options (options provided by MongoDB)
Return: Rows from the database specified in the body in JSON format.
Initialize an agent request, e.g. agent list
. It runs the command in the command line and returns the output. Omit the agent
prefix and only include the command after that.
Body: command
Options: -
Return: The output of the agent request.
This is a listen-only endpoint. As data is flowing in from any node/process, it will be sent out on this endpoint.
Body: None
Options: None
Return: Data from every node/process in JSON format.
- --whitelist_file_path
- The file path to the JSON file for a list of whitelisted nodes.
- --include
- A comma delimited list of nodes as strings to not save data to the database or can contain a wildcard to include all nodes.
- --exclude
- A comma delimited list of nodes as strings to save data to the database.
- --database
- The database to save agent data to.
- Default:
db
- --file_walk_path
- The directory path containing the COSMOS nodes folder.
- Default: COSMOS Nodes folder specified by framework
- --agent_path
- The path where the generic agent executable is (e.g. the executable that you run
agent list
with). - Default:
~/cosmos/bin/agent
- The path where the generic agent executable is (e.g. the executable that you run
- --shell
- The location of the shell you would like to run agent commands with.
- Default:
/bin/bash
- --mongo_server
- The Mongo server URL (e.g.
mongodb://ip:port
) - Default:
mongodb://localhost:27017
- The Mongo server URL (e.g.
Examples:
Including and excluding certain nodes:
--include "cubesat1,hsflpc-03,neutron1" --exclude "node1,node-arduino" --database "agent_dump"
Including all and excluding certain nodes:
--include "*" --exclude "node1,node-arduino"
Specifying nodes from a file:
--whitelist_file_path "/home/usr/cosmos/source/projects/mongodb/source/nodes.json"
The whitelist file is a JSON file and will be imported using the command line option as demonstrated above.
Including and excluding certain nodes:
{
"include": ["cubesat1", "hsflpc-03", "neutron1"],
"exclude": ["node1", "node-arduino"]
}
Including all and excluding certain nodes:
{
"include": ["*"],
"exclude": ["node1", "node-arduino"]
}