Commit 345a1113 authored by spla's avatar spla 💬

Added difference between values 24 hours before

parent 46ae3365
......@@ -276,28 +276,90 @@ write_evo(sqlquery, table)
######################################################
# Tooting
######################################################
total_size = remote_attach_size+local_attach_size+remote_emojis_size+local_emojis_size+total_preview_cards_size+remote_avatar_size+local_avatar_size+remote_header_size+local_header_size
total_size = total_size + float(backup_size) + imports_size + settings_size
total_size = size(total_size)
toot_text = "https://" + mastodon_hostname + " media usage: " + "\n"
toot_text +='\n'
toot_text += "Attachments: " + str(size(remote_attach_size)) + " (local: " + str(size(local_attach_size)) + ")\n"
toot_text += "Custom emoji: "+ str(size(remote_emojis_size)) + " (local: "+ str(size(local_emojis_size)) + ")\n"
toot_text += "Preview cards: "+ str(size(total_preview_cards_size)) + "\n"
toot_text += "Avatars: " + str(size(remote_avatar_size)) + " (local: " + str(size(local_avatar_size)) + ")\n"
toot_text += "Headers: " + str(size(remote_header_size)) + " (local: " + str(size(local_header_size)) + ")\n"
toot_text += "Backups: " + str(size(float(backup_size))) + "\n"
toot_text += "Imports: " + str(size(imports_size)) + "\n"
toot_text += "Settings: "+ str(size(settings_size)) + "\n"
toot_text += "\n"
toot_text += "Total: " + str(total_size) + "\n"
toot_text += "\n"
toot_text += "https://grafana.mastodont.cat/d/YApiNv3Wz/us-media-espai-ocupat-en-disc-dur?orgId=1&kiosk" + ")\n"
toot_text += "\n"
toot_text += "#Mastodon #mediausage"
print("Tooting...")
print(toot_text)
if hour_check.hour == '12':
try:
conn = None
conn = psycopg2.connect(database = media_db, user = media_db_user, password = "", host = "/var/run/postgresql", port = "5432")
cur = conn.cursor()
cur.execute("select * from data where datetime > now() - interval '24 hours' limit 1")
rows = cur.fetchall()
remote_attach_before = row[0]
local_attach_before = row[1]
remote_emoji_before = row[2]
local_emoji_before = row[3]
previewcards_before = row[4]
remote_avatar_before = row[5]
local_avatar_before = row[6]
remote_header_before = row[7]
local_header_before = row[8]
backup_before = row[9]
imports_before = row[10]
settings_before = row[11]
cur.close()
except (Exception, psycopg2.DatabaseError) as error:
print (error)
finally:
if conn is not None:
conn.close()
total_before = remote_attach_before + local_attach_before + remote_emoji_before+ local_emoji_before+previewcards_before+remote_avatar_before+local_avatar_before+remote_header_before
total_before = total_before + local_header_before+backup_before+imports_before+settings_before
toot_text = "https://" + mastodon_hostname + " media usage: " + "\n"
toot_text +='\n'
toot_text += "Attachments: " + str(size(remote_attach_size))+" ("+str(size(remote_attach_before))+") " + " (local: " + str(size(local_attach_size)) +" ("+str(size(local_attach_before))+") " + ")\n"
toot_text += "Custom emoji: "+ str(size(remote_emojis_size)) +" ("+str(size(remote_emoji_before))+") " + " (local: "+ str(size(local_emojis_size)) + " ("+str(size(local_emoji_before))+") " + ")\n"
toot_text += "Preview cards: "+ str(size(total_preview_cards_size)) +" ("+str(size(previewcards_before))+") "+ "\n"
toot_text += "Avatars: " + str(size(remote_avatar_size)) + " ("+str(size(remote_avatar_before))+") " + " (local: " + str(size(local_avatar_size)) +" ("+str(size(local_avatar_before))+") " + ")\n"
toot_text += "Headers: " + str(size(remote_header_size)) +" ("+str(size(remote_header_before))+") "+ " (local: " + str(size(local_header_size)) +" ("+str(size(local_header_before))+") " + ")\n"
toot_text += "Backups: " + str(size(float(backup_size))) +" ("+str(size(backup_before))+") "+ "\n"
toot_text += "Imports: " + str(size(imports_size)) +" ("+str(size(imports_before))+") " + "\n"
toot_text += "Settings: "+ str(size(settings_size)) +" ("+str(size(settings_before))+") "+ "\n"
toot_text += "\n"
toot_text += "Total: " + str(total_size) +" ("+str(size(total_before))+") " + "\n"
toot_text += "\n"
toot_text += "https://grafana.mastodont.cat/d/YApiNv3Wz/us-media-espai-ocupat-en-disc-dur?orgId=1&kiosk" + ")\n"
toot_text += "\n"
toot_text += "#Mastodon #mediausage"
print("Tooting...")
print(toot_text)
toot_id = mastodon.status_post(toot_text, in_reply_to_id=None,)
else:
total_size = remote_attach_size+local_attach_size+remote_emojis_size+local_emojis_size+total_preview_cards_size+remote_avatar_size+local_avatar_size+remote_header_size+local_header_size
total_size = total_size + float(backup_size) + imports_size + settings_size
total_size = size(total_size)
toot_text = "https://" + mastodon_hostname + " media usage: " + "\n"
toot_text +='\n'
toot_text += "Attachments: " + str(size(remote_attach_size)) + " (local: " + str(size(local_attach_size)) + ")\n"
toot_text += "Custom emoji: "+ str(size(remote_emojis_size)) + " (local: "+ str(size(local_emojis_size)) + ")\n"
toot_text += "Preview cards: "+ str(size(total_preview_cards_size)) + "\n"
toot_text += "Avatars: " + str(size(remote_avatar_size)) + " (local: " + str(size(local_avatar_size)) + ")\n"
toot_text += "Headers: " + str(size(remote_header_size)) + " (local: " + str(size(local_header_size)) + ")\n"
toot_text += "Backups: " + str(size(float(backup_size))) + "\n"
toot_text += "Imports: " + str(size(imports_size)) + "\n"
toot_text += "Settings: "+ str(size(settings_size)) + "\n"
toot_text += "\n"
toot_text += "Total: " + str(total_size) + "\n"
toot_text += "\n"
toot_text += "https://grafana.mastodont.cat/d/YApiNv3Wz/us-media-espai-ocupat-en-disc-dur?orgId=1&kiosk" + ")\n"
toot_text += "\n"
toot_text += "#Mastodon #mediausage"
print("Tooting...")
print(toot_text)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment