Example Code for 7SIGNAL's API
- https://start.7signal.com
- Click Users
- Click API Keys tab
- Click Add button
- Choose your Organization, Role, and Sapphire Group
- Add a description if needed
- Submit
-
Download python
-
Verify version
python --version
-
Install the Requests library
pip install requests
-
For examples/eyes/last_monitored_devices.py
pip install matplotlib
By default these scripts will print INFO statements and above.
To see DEBUG statements set the LOG_LEVEL=DEBUG
environment variable.
These files require 2 main environment variables:
set API_KEY=your_api_key_here
set API_SECRET=your_api_secret_here
These files require 2 main environment variables:
$env:API_KEY="your_api_key_here"
$env:API_SECRET="your_api_secret_here"
These files require 2 main environment variables:
export API_KEY=“your-client-id”
export API_SECRET=“your-client-secret”
Depending on the script you want to run, you will be asked to set a couple of additional variables:
Eyes Endpoint
Enter the Agent ID: "your-agent-id"
KPI Endpoint
Enter the KPI code: "your-kpi-code"
Packet Capture Endpoint
Enter the SENSOR ID: "your-sensor-id"
Time Series Endpoint
Enter from_time timestamp (milliseconds): "your-epoch-time-you’re-measuring-from-in-milliseconds"
Enter to_time timestamp (milliseconds): "your-current-epoch-time-in-milliseconds"
Getting current epoch time using Python:
import time
# Current time in milliseconds
current_time_ms = int(time.time() * 1000)
print("Current time:", current_time_ms)
# 1 hour ago
one_hour_ms = current_time_ms - (1 * 60 * 60 * 1000)
print("1 hour ago:", one_hour_ms)
# 24 hours ago
twenty_four_hours_ms = current_time_ms - (24 * 60 * 60 * 1000)
print("24 hours ago:", twenty_four_hours_ms)
ex: Time Series - Last Monitored Devices
cd examples/time_series
python last_monitored_devices.py
# For macOS
open sla_report.html
# For Windows
start sla_report.html
ex: Eyes - CSV Licensing
cd examples/eyes
python csv_licensing.py agents.csv
ex: Eyes - CSV Modifying Nickname
cd examples/eyes
python csv_nickname.py agents.csv
ex: API Keys
cd examples/api_keys
python get_apikeys.py
ex: Topologies
cd topologies
python topologyAgents.py