-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrql-virtual-desktop-session-hosts.sh
More file actions
21 lines (19 loc) · 1 KB
/
rql-virtual-desktop-session-hosts.sh
File metadata and controls
21 lines (19 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# requires jq
# written by Teo De Las Heras
# shows all the policies mapped to alert rules in the Prisma Cloud Enterprise edition console for alert rule troubleshooting and routing
PC_APIURL="https://apix.prismacloud.io"
PC_ACCESSKEY=""
PC_SECRETKEY=""
export REPORT_LOCATION=Virtual_Desktop_Session_Hosts.csv
echo "Id, Name, Status, Status Time Stamp" > $REPORT_LOCATION
curl --url "$PC_APIURL/search/api/v2/config" \
--header "accept: application/json; charset=UTF-8" \
--header "content-type: application/json" \
--header "x-redlock-auth: $PC_JWT" \
--data-raw '{
"limit": 1000,
"withResourceJson": true,
"startTime": 1620226933,
"query": "config from cloud.resource where cloud.type = \"azure\" AND api.name = \"azure-virtual-desktop-session-host\" AND json.rule = session-hosts[?any( properties.status equals \"Unavailable\" )] exists"
}' | jq -r '.items[] | .data."session-hosts"[] | [.id, .name, .properties.status, .properties.statusTimestamp] | @csv' >> $REPORT_LOCATION