1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-07 01:40:10 +02:00

Option to push stats to graphite

This commit is contained in:
Ciaran Gultnieks 2013-05-23 11:04:57 +01:00
parent a61083b71b
commit dc789a7ac9
2 changed files with 21 additions and 2 deletions

View File

@ -76,6 +76,11 @@ wiki_password = "1234"
#machine.
update_stats = False
#Use the following to push stats to a Carbon instance:
stats_to_carbon = False
carbon_host = '0.0.0.0'
carbon_port = 2003
#Set this to true to always use a build server. This saves specifying the
#--server option on dedicated secure build server hosts.

View File

@ -29,12 +29,24 @@ from optparse import OptionParser
import HTMLParser
import paramiko
import common
import socket
carbon_socket = None
def carbon_send(key, value):
global carbon_socket
if not carbon_socket:
carbon_socket = socket.socket()
carbon_socket = carbon_socket.connect((carbon_host, carbon_port))
msg = '%s %d 42 %d\n' % (key, value, int(time.time()))
carbon_socket.sendall(msg)
def main():
# Read configuration...
global update_stats
global update_stats, stats_to_carbon
update_stats = False
stats_to_carbon = False
execfile('config.py', globals())
if not update_stats:
@ -74,7 +86,7 @@ def main():
ssh.connect('f-droid.org', username='fdroid', timeout=10,
key_filename=webserver_keyfile)
ftp = ssh.open_sftp()
ftp.get_channel().settimeout(15)
ftp.get_channel().settimeout(60)
print "...connected"
ftp.chdir('logs')
@ -135,6 +147,8 @@ def main():
alldownloads = 0
for app, count in apps.iteritems():
lst.append(app + " " + str(count))
if stats_to_carbon:
carbon_send('fdroid.download.' + app.replace('.', '_'), count)
alldownloads += count
lst.append("ALL " + str(alldownloads))
f = open('stats/total_downloads_app.txt', 'w')