Am lipsit un an si ceva, am fost ocupat cu altele. Am vreo doua postari de scris, nimic deosebit, ceva cu Zabbix, Telegram, Uptime Kuma.
Intre timp puteti sa va uitati la ce am lucrat anul trecut: vechea mea pasiune, fotografia. Imi puteti gasi galeria foto pe Instagram direct sau pe pagina embedded din blog.
In orice caz, sper ca v-ati vaccinat si n-ati murit de la Covid (sigur cei care citesc n-au murit) si sper sa va paca contentul ce urmeaza. (Vorbesc cu voi, cei din robots.txt, ca nu stiu cine ma mai citeste)
Voiam sa fac de mai mult chestia asta (am vazut-o acum cativa ani pe undeva si mi-a placut), dar ori nu am avut timp si cand am avut timp nu am reusit(voiam alta abordare), ori nu mi s-a mai parut interesanta ideea, dar azi am facut-o.
Ce este? Htop “in timp real” (in urma cu cateva secunde, dar heh, who cares). Comanda htop rulata pe server si pusa “imaginea” intr-un html, apoi servit via Apache.
Daca va uitati la cod, vedeti ca e un simplu export intr-un fisier. Un “snapshot” al htop-ului asa cum e cand a fost rulat. Acum vine intrebarea de 1000 de puncte: cum am facut sa se actualizeze in timp real? Raspunsul este: systemd.
Trecand peste titlul de tabloid, am stocat 3TB in 120GB cu btrfs, snapshots si compresie.
Ce vedeti mai sus este serverul meu de backup. Un VM care trage in fiecare seara schimbarile de pe serverele la care fac backup. Am backup-uri zilnice de la inceputul anului pana in ziua de azi. De pe 29.12.2019 pana pe 3.10.2020. 10 luni de backup in 120GB (~90GB, dar 120GB este dimensiunea HDD-ului pe care se fac backup-urile).
Cum e posibila chestia asta? Snapshots si compresie. Compsize arata practic cat spatiu ar trebui sa am pe un sistem de fisiere “normal” daca as avea aceeasi politica de backup.
Compresia banuiesc ca stiti cum functioneaza. Pe filesystem este transparenta si e exact ca si cum ai arhiva cu 7zip un fisier, doar ca asta se intampla automat pe btrfs cand un fisier se creeaza pe disk. (e de discutat si pe tema asta, dar just go with it. Pe scurt: unele fisiere se comprima mai bine decat altele)
Snapshot-urile sunt insa ceva mai interesant. Sa zicem ca ai fisierul A de 1MB si vrei sa-i faci snapshot din 10 in 10 minute, timp de o ora. La finalul orei o sa ai 6 snapshot-uri ale fisierului A. Teoretic, ai fisierul A de 6 ori, practic ai 5 referinte catre fisierul A original, de 1MB. Compsize calculeaza chestia asta insa ca avand fisierul A de 6 ori (in coloana Referenced), adica un total de 6MB, nu de 1MB. Fake? Nu chiar. Clickbait worthy? Poate. Daca tu la minutul 35 modifici fisierul A si ii cresti dimensiunea la 2MB, o sa ai primele snapshots de 1MB, apoi urmatoarele de 2MB, in total insumand 3MB. Compsize calculeaza asta in coloana de referenced ca 1MB+1MB+1MB+2MB+2MB+2MB = 9MB.
That’s it. Asta e marea smecherie. Asa bagi 3TB in 120GB.
PS: cele mai mari snapshot-uri sunt cele ale bazelor de date. Am ales optiunea sa fac compresie la nivel de filesystem si nu in timpul backup-ului. Scriptul de backup pentru mysql este o combinatie intre ce am avut eu nevoie si alte exemple gasite pe stackoverflow/github, dar pe scurt asta e linia care face tot: $MYSQLDUMP -h $MyHOST -u $MyUSER -p$MyPASS $db > $FILE
Nu recomand daca vreti ceva mai serios. Scriptul de backup mysql este locking. La baze de date mai mari (sunt multumit de cat de repede se face backup un DB de 2GB) e naspa ca iti pune productia pe jos. Se poate tuna si se mai pot adauga optiuni la backup, dar pentru ce am eu nevoie e destul.
nut-influxdb-exporter – exporter de metrici pentru NUT. Metricile se citesc dintr-un server de NUT si se trimit in InfluxDB, apoi din InfluxDB le vad in Grafana cu dashboard-ul asta.
kanboard – kanban board. Eu l-am setat ca un TODO board cu trei coloane: to do, in progress si done. Imbatranesc si ma lasa memoria.
observium_db – mariadb pentru observium (vezi mai jos)
grafana – Grafana. Metrici. Grafice. Chestii. O sa fac o gluma si o sa zic “lasati Grafana si invatati Cacti!” (cine stie cunoaste)
prometheus – time series database. Data source pentru Grafana. (vezi mai jos)
influxdb – time series database. Data source pentru Grafana. Colectez datele cu telegraf si le salvez in influx.
chronograf – dashboard pentru Influx dar poate fi folosit ca un client de Influx de unde poti gestiona datele. (eu pentru asta l-am instalat)
observium_app – Observium. Se conecteaza la observium_db si salveaza datele acolo. Grafice. Metrici. Niciodata nu sunt destule. Daca Grafana este utila si personalizabila dupa bunul plac, Observium e mai mult indreptat catre retelari.
portainer_agent – agentul de Portainer.io, pentru ca lene si pentru ca imi place docker dar nu prea. Nu am chef sa stau sa invat si sa fac retete de docker cand pot sa dau 3 click-uri si sa am un container.
mikrotik-exporter – exporter de metrici pentru device-urile Mikrotik. Datele se scriu in Prometheus si le vad in Grafana cu dashboard-ul asta.
pihole-exporter – exporter de metrici pentru PiHole. Datele se scriu in Prometheus si le vad in Grafana cu dashboard-ul asta.
cerebro – web admin tool pentru Elasticsearch.
watchtower – autoupdater pentru imaginile de docker.
Bonus:
bitwarden – self hosted password manager, because I don’t trust anybody.
jitsi – Jitsi Meet – self hosted chat/video room. Conferinte video open-source, nu trebuie sa te inregistrezi nicaieri, ai camere private, it just works. Asta e remasita din pandemie, cred ca l-am folosit de vreo 3-4 ori si am uitat de el.
portainer – masterul pentru portainer.io
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-advertisement
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category .
cookielawinfo-checkbox-analytics
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Analytics" category .
cookielawinfo-checkbox-necessary
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Necessary" category .
cookielawinfo-checkbox-others
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to store the user consent for cookies in the category "Others".
cookielawinfo-checkbox-performance
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to store the user consent for cookies in the category "Performance".
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Cookie
Duration
Description
__cf_bm
30 minutes
This cookie, set by Cloudflare, is used to support Cloudflare Bot Management.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Cookie
Duration
Description
_gat
1 minute
This cookie is installed by Google Universal Analytics to restrain request rate and thus limit the collection of data on high traffic sites.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Cookie
Duration
Description
_ga
2 years
The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors.
_gid
1 day
Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously.
CONSENT
16 years 2 months 21 days 13 hours
YouTube sets this cookie via embedded youtube-videos and registers anonymous statistical data.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Cookie
Duration
Description
IDE
1 year 24 days
Google DoubleClick IDE cookies are used to store information about how the user uses the website to present them with relevant ads and according to the user profile.
test_cookie
15 minutes
The test_cookie is set by doubleclick.net and is used to determine if the user's browser supports cookies.
VISITOR_INFO1_LIVE
5 months 27 days
A cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.
YSC
session
YSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.
yt-remote-connected-devices
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
yt-remote-device-id
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.