fix up metrics

master
Volkor 7 months ago
parent 5663cbf9d5
commit d8047d8b74
No known key found for this signature in database
GPG Key ID: BAD7CA8A81CC2DA5
  1. 36
      run.py

@ -134,9 +134,9 @@ def generateMetrics():
for size in db.list_sizes(extension):
if not size: # Return 0 instead of NoneType
filesize = 0
metrics = metrics + "filesize_live{type=" + extension + "} " + str(filesize) + "\n"
metrics = metrics + 'filesize_live{type="' + extension + '"} ' + str(filesize) + '\n'
else:
metrics = metrics + "filesize_live{type=" + extension + "} " + str(size) + "\n"
metrics = metrics + 'filesize_live{type="' + extension + '"} ' + str(size) + '\n'
metrics = metrics + "\n"
# Total File Sizes by Type
@ -145,29 +145,29 @@ def generateMetrics():
for size in db.list_totalsizes(extension):
if not size: # Return 0 instead of NoneType
filesize = 0
metrics = metrics + "filesize_total{type=" + extension + "} " + str(filesize) + "\n"
metrics = metrics + 'filesize_total{type="' + extension + '"} ' + str(filesize) + '\n'
else:
metrics = metrics + "filesize_total{type=" + extension + "} " + str(size[0]) + "\n"
metrics = metrics + 'filesize_total{type="' + extension + '"} ' + str(size[0]) + '\n'
metrics = metrics + "\n"
# Live Files by Type
filenames = db.list_filetypes()
for extension in filenames:
for count in db.live_typecount(extension):
metrics = metrics + "filecount_live{type=" + extension + "} " + str(count[0]) + "\n"
metrics = metrics + 'filecount_live{type="' + extension + '"} ' + str(count[0]) + '\n'
metrics = metrics + "\n"
# Total Files by Type
total_filetypes = db.total_filetype()
for filetypes in total_filetypes:
metrics = metrics + "filecount_total{type=" + filetypes[0] + "} " + str(filetypes[1]) + "\n"
metrics = metrics + 'filecount_total{type="' + filetypes[0] + '"} ' + str(filetypes[1]) + '\n'
metrics = metrics + "\n"
# Total Views per Type
filenames = db.list_totalfiletypes()
for extension in filenames:
for size in db.total_fileview(extension):
metrics = metrics + "filetype_views{type=" + extension + "} " + str(size[0]) + "\n"
metrics = metrics + 'filetype_views_total{type="' + extension + '"} ' + str(size[0]) + '\n'
metrics = metrics + "\n"
# File Deletion
@ -182,21 +182,21 @@ def generateMetrics():
# Page Errors
metrics = metrics + "# Total Page Errors\n"
metrics = metrics + "errors{code=403} " + str(db.read_stat(403)) + "\n"
metrics = metrics + "errors{code=404} " + str(db.read_stat(404)) + "\n"
metrics = metrics + "errors{code=413} " + str(db.read_stat(413)) + "\n"
metrics = metrics + "errors{code=418} " + str(db.read_stat(418)) + "\n"
metrics = metrics + "errors{code=500} " + str(db.read_stat(500)) + "\n"
metrics = metrics + 'errors{code="403"} ' + str(db.read_stat(403)) + "\n"
metrics = metrics + 'errors{code="404"} ' + str(db.read_stat(404)) + "\n"
metrics = metrics + 'errors{code="413"} ' + str(db.read_stat(413)) + "\n"
metrics = metrics + 'errors{code="418"} ' + str(db.read_stat(418)) + "\n"
metrics = metrics + 'errors{code="500"} ' + str(db.read_stat(500)) + "\n"
metrics = metrics + "total_invalid_deletion_key " + str(db.read_stat('invaliddeletionkey')) + "\n\n"
# Page Views
metrics = metrics + "# Total Page Views\n"
metrics = metrics + "views{page=about} " + str(db.read_stat('aboutviews')) + "\n"
metrics = metrics + "views{page=faq} " + str(db.read_stat('faqviews')) + "\n"
metrics = metrics + "views{page=ervices} " + str(db.read_stat('servicesviews')) + "\n"
metrics = metrics + "views{page=welcome} " + str(db.read_stat('welcomeviews')) + "\n"
metrics = metrics + "views{page=dmca} " + str(db.read_stat('dmcaviews')) + "\n"
metrics = metrics + "views{page=czb} " + str(db.read_stat('czb')) + "\n\n"
metrics = metrics + 'views{page="about"} ' + str(db.read_stat('aboutviews')) + "\n"
metrics = metrics + 'views{page="faq"} ' + str(db.read_stat('faqviews')) + "\n"
metrics = metrics + 'views{page="services"} ' + str(db.read_stat('servicesviews')) + "\n"
metrics = metrics + 'views{page="welcome"} ' + str(db.read_stat('welcomeviews')) + "\n"
metrics = metrics + 'views{page="dmca"} ' + str(db.read_stat('dmcaviews')) + "\n"
metrics = metrics + 'views{page="czb"} ' + str(db.read_stat('czb')) + "\n\n"
return metrics

Loading…
Cancel
Save