Cov txheej txheem:

Pi Health Dashboard: 3 Kauj Ruam
Pi Health Dashboard: 3 Kauj Ruam

Video: Pi Health Dashboard: 3 Kauj Ruam

Video: Pi Health Dashboard: 3 Kauj Ruam
Video: Zoo Siab Nrog Koj - Paj Tsua Thoj [ Official MV ] Nkauj Tawm Tshiab 2022 2024, Hlis ntuj nqeg
Anonim
Image
Image

Raspberry Pi's tau siv los tsav ntau txoj haujlwm. Pi thawj zaug tau txais los ntawm cov kws qhia ntawv thiab cov nyiam ua haujlwm, tab sis tam sim no kev tsim khoom thiab kev lag luam tau ua rau lub zog zoo ntawm Pi. Txawm hais tias me me, siv tau yooj yim, thiab pheej yig, koj Pi muaj tus lej zoo kawg ntawm cov txheej txheem nyuaj uas yuav tsum ua haujlwm kom ua kom koj txoj haujlwm tiav. Qhov no ua rau muaj peev xwm los saib xyuas kev noj qab haus huv ntawm koj Pi tseem ceeb hauv ntau daim ntawv thov los ntawm kev saib xyuas tas li ntawm txoj haujlwm mus sij hawm ntev kom nthuav qhia qhov ua tau zoo ntawm tus qauv tshiab.

Peb tab tom tsim peb tus kheej lub browser-based dashboard los saib xyuas kev noj qab haus huv thiab kev ua tau zoo ntawm lub vev xaib txuas nrog Raspberry Pi. Txhawm rau ua tiav txoj haujlwm no, peb yuav ua cov ntawv Python yooj yim uas yuav sau cov ntaub ntawv cov ntaub ntawv los ntawm Pi thiab xa nws mus rau lub platform huab uas tshwj xeeb hauv dashboards, tshuaj xyuas, thiab pom kev.

Hauv qhov kev qhia ib qib zuj zus, koj yuav:

  • kawm paub yuav sau cov ntaub ntawv li cas los ntawm koj Pi ntawm tsab ntawv Python yooj yim
  • kawm paub yuav siv Lub Xeev Pib li cas los tsim koj tus kheej kev noj qab haus huv/kev ua haujlwm zoo rau koj li Pi

Kauj Ruam 1: Thawj Xeev

Customize Koj Dashboard
Customize Koj Dashboard

Peb xav kom tshaj tawm tag nrho peb Pi kev siv cov ntaub ntawv mus rau huab kev pabcuam thiab muaj qhov kev pabcuam ntawd tig peb cov ntaub ntawv mus rau hauv lub dashboard. Peb cov ntaub ntawv xav tau lub hom phiaj yog li yuav siv Lub Xeev Pib ua qhov chaw ntawd.

Sau npe rau Lub Xeev Thawj Tus Kheej

Mus rau https://iot.app.initialstate.com thiab tsim tus as khauj tshiab. Koj tau txais 14 hnub kev sim pub dawb thiab txhua tus neeg nrog edu email chaw nyob tuaj yeem tso npe rau txoj kev npaj kawm dawb.

Nruab ISStreamer

Txhim Kho Thawj Lub Xeev Python module rau koj li Raspberry Pi. Hauv qhov hais kom ua, khiav cov lus txib hauv qab no:

$ cd/tsev/pi/

$ / curl -sSL https://get.initialstate.com/python -o -| sudo tsoo

Ua Qee Yam Automagic

Tom qab Kauj Ruam 2 koj yuav pom qee yam zoo ib yam li cov hauv qab no tso rau ntawm qhov screen:

pi@raspberrypi ~ $ / curl -sSL https://get.initialstate.com/python -o -| sudo tsoo

Lo lus zais: Pib ISStreamer Python Kev teeb tsa yooj yim! Qhov no yuav siv ob peb feeb los teeb tsa, rub qee lub kas fes:) Tab sis tsis txhob hnov qab rov qab los, Kuv yuav muaj lus nug tom qab! Pom yooj yim_install: setuptools 1.1.6 Pom pip: pip 1.5.6 los ntawm /Library/Python/2.7/site-packages/pip-1.5.6- py2.7.egg (sej 2.7) pip loj version: 1 pip me me version: 5 ISStreamer pom, hloov kho… Yuav tsum tau hloov kho tshiab: ISStreamer hauv /Library/Python/2.7/site-packages Tu tu… Koj puas xav tau automagically tau txais cov piv txwv ntawv? [y/N] Koj xav khaws qhov piv txwv nyob qhov twg? [lub neej ntawd:./is_example.py] Thov xaiv qhov Xeev Lub Xeev app uas koj siv: 1. app.initialstate.com 2. [TSHIAB!] iot.app.initialstate.com Nkag mus xaiv 1 lossis 2: Nkag mus rau iot.app.initialstate.com tus neeg siv lub npe: Nkag mus rau iot.app.initialstate.com lo lus zais:

Thaum nug yog tias koj xav tau automagically tau txais ib qho piv txwv tsab ntawv muab "y" rau yog thiab nias sau kom txuag tau koj cov ntawv hauv qhov chaw nyob. Txog cov lus nug txog app twg koj tab tom siv, xaiv 2 (tshwj tsis yog koj tau kos npe ua ntej lub Kaum Ib Hlis 2018) thiab sau koj lub npe siv thiab tus password.

Khiav Qhov Piv Txwv

Khiav cov ntawv xeem kom paub tseeb tias peb tuaj yeem tsim cov ntaub ntawv xa mus rau koj Tus Thawj Xeev tus as khauj. Sau cov lus txib hauv qab no:

$ python is_example.py

Piv txwv Cov Ntaub Ntawv

Rov qab mus rau koj lub Xeev Thawj tus lej hauv koj lub vev xaib. Ib lub thoob cov ntaub ntawv tshiab hu ua "Python Stream Piv txwv" yuav tsum tau tshwm nyob rau sab laug hauv koj lub txee rau khoom (koj yuav tau rov ua nplooj ntawv tshiab). Nyem rau ntawm lub thoob no txhawm rau saib koj cov ntaub ntawv.

Kauj ruam 2: Psutil

Peb yuav siv psutil kom nkag tau yooj yim rau feem ntau ntawm cov ntaub ntawv txheej txheem peb yuav siv los tsim peb lub dashboard. Txhawm rau teeb tsa lub tsev qiv ntawv psutil Python, mus rau lub davhlau ya nyob twg ntawm koj Pi thiab ntaus:

$ sudo pip nruab psutil

Tom qab kev teeb tsa ua tiav, peb tsuas xav tau los ua tsab ntawv Python los pib sau cov ntaub ntawv. Cia peb muab cov ntawv no tso rau hauv nws phau ntawv teev npe raws li hauv qab no:

$ cd/tsev/pi/

$ mkdir pihealth $ cd pihealth

Ib zaug hauv phau ntawv teev npe tshiab, tsim ib tsab ntawv los ntawm kev ua cov hauv qab no:

$ nano pihealth.py

Qhov no yuav qhib cov ntawv nyeem. Luam thiab paste cov cai los ntawm Github qhov chaw cia rau hauv cov ntawv sau.

Ntawm kab 8, koj yuav pom Tus Neeg Siv Nqis ntu:

# --------- Neeg Siv Chaw ---------

# Thawj lub xeev teeb tsa BUCKET_NAME = ": computer: Pi3 Performance" BUCKET_KEY = "pi0708" ACCESS_KEY = "PUT YOUR INITIAL STATE ACCESS_KEY HERE" # Teem lub sijhawm nruab nrab ntawm cov tshev MINUTES_BETWEEN_READS = 1 METRIC_UNITS = Cuav # --------- ------------------------------ ua tsaug

Koj yuav tsum tso koj Tus Thawj Xibfwb nkag mus rau qhov tseem ceeb hauv ACCESS_KEY kev hloov pauv. Txhawm rau nrhiav qhov no mus rau koj Lub Xeev Thawj lub vev xaib, nyem koj lub npe siv nyob rau sab saum toj sab xis, mus rau kuv qhov chaw thiab pom cov ntsiab lus nkag mus rau qhov ntawd. Yog tias koj tsis ua qhov no, koj cov ntaub ntawv yuav tsis ntws mus rau hauv koj tus as khauj Thawj Lub Xeev, ua rau koj tu siab thiab ntxhov siab heev.

MINUTES_BETWEEN_READS qhov sib txawv yog qhov tseem ceeb los teeb tsa raws li koj daim ntawv thov. Yog tias koj yuav sau tsab ntawv no ntau hnub/lub lis piam/hli, koj yuav xav ua qhov no ntau dua li txhua 2-5 feeb. Yog tias koj tab tom khiav tsab ntawv no los tshuaj xyuas qhov ua tau zoo ntawm daim ntawv thov luv, koj yuav xav tau hloov kho tshiab txhua ob peb feeb.

Thaum koj tau hloov kho cov ntawv, txuag thiab tawm ntawm cov ntawv sau. Peb npaj txhij pib sau cov ntaub ntawv system. Txhawm rau khiav cov ntaub ntawv sej hom cov lus txib hauv qab no:

$ nab hab sej pihealth.py

Tswv yim: Yog tias koj xav khiav tsab ntawv no hauv keeb kwm yav dhau thiab nco ntsoov tias nws tsis tawm yog tias koj qhov kev sib txuas SSH tau tawg lossis lub davhlau ya nyob twg raug kaw, koj tuaj yeem siv cov lus txib hauv qab no:

$ nohup nab hab sej pihealth.py &

python.h yuam kev: Yog tias koj tau txais qhov yuam kev hais txog sej py.h thaum twg koj sim siv psutil hauv kab ntawv, txhim kho cov tsev qiv ntawv txhim kho nab hab sej tuaj yeem daws qhov yuam kev:

$ sudo apt-tau nruab gcc sej-dev

$ sudo pip nruab psutil

Kauj ruam 3: Customize Koj Dashboard

Customize Koj Dashboard
Customize Koj Dashboard
Customize Koj Dashboard
Customize Koj Dashboard

Mus rau koj Tus Thawj Xibfwb Lub Xeev thiab nyem rau ntawm lub thoob cov ntaub ntawv tshiab hu ua Pi3 Performance. Nov yog koj lub dashboard. Cia peb hloov kho thiab teeb tsa cov ntaub ntawv ntawm lub dashboard no mus rau qee yam muaj txiaj ntsig.

Muaj ntau ntau Pobzeb thiab cov ntaub ntawv ntws hauv cov dashboard no. Cia peb ua cov Vuas me dua thiab tau txais txhua cov ntaub ntawv mus rau ib qho screen. Nyem rau ntawm Kho kom raug Pobzeb khawm nyob rau sab saum toj sab laug thiab tshem tawm "Ib txwm Haum Pobzeb". Qhov no tso peb dashboard teeb tsa rau hauv hom ntawv. Tom ntej no, hloov kho txhua pobzeb rau 1/4 nws qhov loj me los ntawm kev nyem thiab rub lub ces kaum ntawm txhua Pobzeb thaum nyob hauv kev hloov kho hom. Koj tuaj yeem rub txhua Pobzeb mus rau txoj haujlwm twg uas koj nyiam ntawm qhov screen.

Ib qho ntawm ntau yam zoo uas koj tuaj yeem ua nrog lub dashboard no yog tsim ntau Vuas thiab cov ntaub ntawv pom ntawm cov ntaub ntawv kwj. Piv txwv li, koj tuaj yeem tsim Cov Vuas kom pom kab kab rau CPU Kub ntxiv nrog rau cov kab ntsuas thiab ntsuas tus nqi kawg. Txhawm rau ntxiv cov pobzeb tshiab, nyem rau Kho Cov Vuas ces +Ntxiv Pobzeb. Lub Vuas tshiab lub thawv teeb tsa yuav tshwm sim. Xaiv cov ntaub ntawv kwj uas yuav tsav Pobzeb no hauv lub npov SignalKey, tom qab ntawd xaiv Hom Pobzeb, thiab tsim lub npe rau cov pobzeb no.

Hauv kuv lub dashboard, Kuv tau tso peb Pi's rau hauv ib lub dashboard los sib piv CPU siv thiab ntsuas kub.

Cov kab ntsuas ntsuas yog qhov muaj txiaj ntsig zoo rau cov ntaub ntawv ntws xws li Kev Siv Disk (%) thiab CPU Siv (%). Thaum koj xaiv qhov ntsuas kab pom, koj tuaj yeem teev tus min thiab tus nqi siab tshaj plaws rau qhov ntsuas hauv Pob Zeb Kho Kho. Nws yog ib qho tseem ceeb los teeb tsa min/max rau 0/100 rau Kev Siv Disk (%) thiab Kev Siv CPU (%) ntsuas kom cov vuas ua kom nkag siab.

Koj tuaj yeem ntxiv cov duab keeb kwm yav dhau los rau koj lub dashboard kom muab cov ntaub ntawv ntau ntxiv rau koj.

Nov yog kev tshaj tawm pej xeem ntawm ob lub dashboards kuv tau tsim:

  1. https://go.init.st/6g3spq4
  2. https://go.init.st/ynkuqxv

Pom zoo: