Here be dragons:
This software has the ability to modify all your data through the CopperEgg API.
Make sure you have read and understood the code before using it for any purpose.
- Listing, updating, adding and deleting probes.
- Set stations, tags and more.
- Enable stations by region
- Backup and restore functionality.
- Search for probes by name using case-insensitive regexp, substring search.
- Search for probes by destination using case-insensitive regexp, substring search.
- A CopperEgg account and API token.
- Python 2.7+, 3.3+
- Requests (http://docs.python-requests.org/)
sudo python setup.py install
OR
sudo python3 setup.py install
Append this to ~/.netrc to enable automatic authentication with your API token:
machine api.copperegg.com login [your token] password U
import copperegg
api = copperegg.CopperEgg()
api.list_probes()
api.get_probe(probe_id)
Set the check interval to 15 seconds for probe_id:
api.update_probe(probe_id, {"frequency": 15})
Note the --noop argument which should make this utility quite safe. Adding --noop will just print what would be done without actually making any changes via the CopperEgg API. Pay close attention to your CLI arguments and when in doubt create a backup of your data with --backup.
copperegg-cli --help
By default copperegg-cli will print log messages to stdout and to ~/.copperegg-cli.log. There are a few ways to change this behavior:
copperegg-cli --silent
copperegg-cli --log-level DEBUG
copperegg-cli --log-level WARNING
copperegg-cli --get-probes all
Or for more verbose output:
copperegg-cli --get-probes all --log-level DEBUG | less
CopperEgg-CLI can now backup all probe data to stdout. The output is JSON directly from the CopperEgg API, so you can do your own operations to it or redirect it to a file.
When restoring data it will by default ignore existing probes, using the URL as primary key, and log an error message. If you pass it the --force argument it will restore all possible data.
copperegg-cli --backup > /path/to/file.json
copperegg-cli --restore /path/to/file.json
copperegg-cli --force --restore /path/to/file.json
You may supply multiple filters for the --get- arguments.
copperegg-cli --get-names test
copperegg-cli --get-names '^production' --get-tags production
copperegg-cli --get-tags dev test
copperegg-cli --get-tags demo
Tip: Add the --noop argument to see changes without actually applying them.
copperegg-cli --get-names '^dev' --set-tags dev --set-frequency 300
copperegg-cli --get-probes [probe id] --set-state enabled
copperegg-cli --get-probes [probe id] --set-state disabled
Disable all probes tagged "dev":
copperegg-cli --get-tags dev --set-state disabled
copperegg-cli --get-tags demo --set-stations all
copperegg-cli --help-stations
copperegg-cli --get-tags dev --set-stations lon amd nrk --replace-stations
New: You can now use region names too. Here's how to enable EU, APAC and Newark:
copperegg-cli --get-tags dev --set-stations eu apac nrk
If you want to enable stations in EU only:
copperegg-cli --get-tags dev --set-stations eu --replace-stations
I am in no way affiliated with CopperEgg.
- This software is provided as is.
- It should be safe, but don't blame me if something breaks.
- It is written and tested for use on GNU/Linux with Python 2.7+, 3.3+.