Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
cc986977
Commit
cc986977
authored
Aug 21, 2017
by
syed-awais-ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script to make API call to get cache hit rate
parent
34c2441d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
util/jenkins/cloudflare-hit-rate.py
+31
-0
No files found.
util/jenkins/cloudflare-hit-rate.py
0 → 100644
View file @
cc986977
import
requests
import
argparse
CLOUDFLARE_API_ENDPOINT
=
"https://api.cloudflare.com/client/v4/"
def
calcualte_cache_hit_rate
(
zone_id
,
auth_key
,
email
):
HEADERS
=
{
"Accept"
:
"application/json"
,
"X-Auth-Key"
:
auth_key
,
"X-Auth-Email"
:
email
}
res
=
requests
.
get
(
CLOUDFLARE_API_ENDPOINT
+
"zones/"
+
zone_id
+
"/analytics/dashboard?since=-419&continuous=true"
,
headers
=
HEADERS
)
data
=
res
.
json
()
all_req
=
float
(
data
[
"result"
][
"timeseries"
][
0
][
"requests"
][
"all"
])
cached_req
=
float
(
data
[
"result"
][
"timeseries"
][
0
][
"requests"
][
"cached"
])
threshold_limit
=
cached_req
*
100.0
/
all_req
# Add threshold for alerts/alarms
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-z'
,
'--zone'
,
required
=
True
,
help
=
"Cloudflare's Zone ID"
)
parser
.
add_argument
(
'-k'
,
'--auth_key'
,
required
=
True
,
help
=
"Authentication Key"
)
parser
.
add_argument
(
'-e'
,
'--email'
,
required
=
True
,
help
=
"email to use for authentication for CloudFlare API"
)
args
=
parser
.
parse_args
()
calcualte_cache_hit_rate
(
args
.
zone
,
args
.
auth_key
,
args
.
email
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment