-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to fetch all Site Metrics as JSON. Creating charts as P…
…NG link for servers is not yet supported. Added many more options for adding a new site monitor: e.g. from which monitoring location to monitor, keyword alerts, different protocols and ports, ...
- Loading branch information
Jan Loeffler
committed
May 2, 2023
1 parent
0b53e4c
commit d15adfa
Showing
8 changed files
with
135 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
from datetime import datetime | ||
|
||
from .api import apiGet | ||
from .config import Config | ||
from .functions import printError, printWarn | ||
|
||
class SiteCharts(object): | ||
|
||
def __init__(self, config: Config): | ||
self.config = config | ||
|
||
def create(self, siteId: str, startTimestamp: float = 0, endTimestamp: float = 0): | ||
"""Create a site metrics chart for the specified site id""" | ||
|
||
if not siteId: | ||
printError('No site id specified') | ||
return '' | ||
|
||
params = self.config.params() | ||
params['output'] = 'png' | ||
if startTimestamp > 0: | ||
params['start'] = int(startTimestamp) | ||
if endTimestamp > 0: | ||
params['end'] = int(endTimestamp) | ||
|
||
response_json = apiGet('monitor/' + siteId + '/metrics', 200, self.config, params) | ||
if response_json: | ||
print(json.dumps(response_json, indent=4)) | ||
print() | ||
print('Only JSON output supported currently. PNG export not yet implemented.') | ||
''' | ||
if 'uri' in response_json: | ||
uri = response_json['uri'] | ||
print(uri) | ||
return uri | ||
else: | ||
printWarn('Site with id', siteId, 'not found') | ||
return '' | ||
''' | ||
else: | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters