Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
BIG-IQ full JSON + Sw on Hw added
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziofiorucci committed May 19, 2022
1 parent 2693d3e commit 2c590bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
26 changes: 14 additions & 12 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ To get instance statistics in JSON format:

the `type` query string parameter can be used to retrieve a logical view of the full JSON file:

- Browser mode: `http://f5tt.ff.lan` and `http://f5tt.ff.lan?type=CVE`
- Retrieve the full JSON: `curl -s http://f5tt.ff.lan/instances | jq`
- Retrieve the CVE-centric JSON: `curl -s http://f5tt.ff.lan/instances?type=CVE | jq`
- Retrieve the time-based usage JSON: `curl -s http://f5tt.ff.lan/instances?type=timebased&month=M&slot=N | jq`
```
M = 0 to get time-based usage for the current month, -1 for previous month (defaults to -1 if not specified)
N = Aggregation based on N-hours timeslot (defaults to 4 if not specified)
```
| Output type | URI | Description |
|---|:---|:---|
| HTML | / | Full data visualization |
| HTML | /?type=CVE | CVE data visualization |
| JSON | /instances | NGINX instances inventory and CVE details |
| JSON | /instances?type=CVE | NGINX instances CVE details |
| JSON | /instances?type=timebased&month=M&slot=N |M = 0 to get time-based usage for the current month, -1 for previous month (defaults to -1 if not specified) - N = Aggregation based on N-hours timeslot (defaults to 4 if not specified) |

### NGINX Controller

Expand All @@ -43,10 +42,13 @@ N = Aggregation based on N-hours timeslot (defaults to 4 if not specified)

the `type` query string parameter can be used to retrieve a logical view of the full JSON file:

- Retrieve the standard full JSON: `curl -s http://f5tt.ff.lan/instances | jq`
- Retrieve a CVE-centric JSON summarized by CVE: `curl -s http://f5tt.ff.lan/instances?type=CVE | jq`
- Retrieve a CVE-centric JSON summarized by device: `curl -s http://f5tt.ff.lan/instances?type=CVEbyDevice | jq`
- Retrieve the "Software on Hardware" JSON: `curl -s http://f5tt.ff.lan/instances?type=SwOnHw | jq`
| Output type | URI | Description |
|---|:---|:---|
| JSON | /instances | TMOS devices inventory and CVE details |
| JSON | /instances?type=CVE | CVE details summarized by CVE |
| JSON | /instances?type=CVEbyDevice | CVE details summarized by device |
| JSON | /instances?type=SwOnHw | "Software on Hardware" report |
| JSON | /instances?type=fullSwOnHw | TMOS devices inventory, CVE details and "Software on Hardware" report |

- All JSON can be accessed with a browser omitting the `/instances` portion of the URI (ie. `http://f5tt.ff.lan?type=CVE`)

Expand Down
2 changes: 2 additions & 0 deletions f5tt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def getInstances(request: Request,type: Optional[str] = None,month: Optional[int
reply,code = bigiq.bigIqCVEbyDevicejson()
elif type.lower() == 'swonhw':
reply,code = bigiq.bigIqSwOnHwjson()
elif type.lower() == 'fullswonhw':
reply,code = bigiq.bigIqFullSwOnHwjson()
else:
reply = {}
code = 404
Expand Down
12 changes: 11 additions & 1 deletion f5tt/bigiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def bigIqCVEbyDevicejson():
for d in fullJSON['details']:
thisDevice = {}
thisDevice['hostname'] = d['hostname']
thisDevice['chassisSerialNumber'] = d['chassisSerialNumber']
thisDevice['chassisSerialNumber'] = d['chassisSerialNumber'] if 'chassisSerialNumber' in d else ''
thisDevice['version'] = d['version']
thisDevice['CVE'] = []

Expand Down Expand Up @@ -683,6 +683,16 @@ def bigIqSwOnHwjson():
return wholeJSON,200


# Returns a full JSON that includes the software on hardware JSON
def bigIqFullSwOnHwjson():
fullJson,code = bigIqInventory(mode='JSON')
swonhw,code = bigIqSwOnHwjson()

fullJson['swonhw'] = swonhw

return fullJson,200


# Builds BIG-IQ telemetry request body by entities
def _getTelemetryRequestBodyByEntities(module,metricSet,metric,timeRange,granDuration,granUnit):

Expand Down

0 comments on commit 2c590bd

Please sign in to comment.