Monthly bandwidth on per app basis
It would be great to see what app consumes most of the bandwidth.

4 comments
-
Russell commented
I wrote a Python script that grabs and charts this info for me. At the center of the script is the following.
grep = 'grep -I' # -I ignores .gz and other binary files # use grep = 'zgrep' for older dates to search through the gzipped files
daystr = day.strftime('%d/%b/%Y')
app_dir = str(site.app_dir).replace('~','$HOME') # It doesn't expand ~ by itself for whatever reason.
search_command = (
'| cut -d[ -f2 ' # split each line into fields, using [ as the deliminator, and grab the second field
'| awk '
'-F: ' # The -F option speficies a separator. We want to get the hour -- the second item of the timestamp -- and so we use a colon as a delimiter
'\'{ split($4, A, " "); ' # Create the array A that will contain the results of splitting $4 (everything after the timestamp) with a space character
'h[$2]+=A[7]; } ' # Create or add to the array h. The key is the hour and the value are the bytes (7th column in our splitted array)
'END ' # What comes next will be processed after running through all of the data
'{ for (i in h) print h[i], i":00"}\' ' # for each hour output the hour followed by how many bytes where recorded for that time
)ssh.check_output(
f'cd "{app_dir}/logs"; '
'LC_ALL=C; ' # Speed things up by using ASCII instead of UTF-8
f'{grep} "{daystr}" *.access.log* ' # search for lines of text containing our date
# hint: for debugging you can use the tail command for quicker searches
+ search_command
) -
chris commented
When?
-
Soso Janashvili commented
A Must! +1 for it
-
Clark Stiles commented
yes please.