cachingServer reporting testing
| #!/usr/bin/python | |
| import os, subprocess | |
| from time import strftime | |
| today = strftime("%Y-%m-%d %H:%M") | |
| log_lines_list = [] | |
| f = open('/Library/Server/Caching/Logs/Debug.log', 'rU') | |
| for line in f: | |
| if 'start:' in line: | |
| log_lines_list.append(line.split()) | |
| f.close() | |
| logged_gb_returns = [] | |
| logged_gb_origins = [] | |
| for each in log_lines_list: | |
| logged_gb_returns.append(float(each[5])) | |
| logged_gb_origins.append(float(each[10])) | |
| daily_total_from_cache = max(logged_gb_returns) - min(logged_gb_returns) | |
| daily_total_from_apple = max(logged_gb_origins) - min(logged_gb_origins) | |
| message = ["Bandwidth served from cache: ", str(daily_total_from_cache * 1024), " MB", '\n', | |
| "Amount fetched from Apple: ", str(daily_total_from_apple * 1024), " MB"] | |
| print message | |
| subprocess.call('/Applications/Server.app/Contents/ServerRoot/usr/sbin/server postAlert CustomAlert Common subject "Caching Server Data: Today" message "' + ' '.join(message) + '" <<<""', shell=True) |
| sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/server postAlert CustomAlert Common subject "Caching Server Data: 2015-06-29 15:33" message "Bandwidth served from cache: 1945.6 MB\n Amount fetched from Apple: 614.4 MB" <<<"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment