Bendihlala ndizibuza malunga nobushushu be-HDDs kwi-NAS yam. Ndine-NAS kwigumbi elivaliweyo ngaphandle kwe-airco. Ngaphezu koko, ndaqhawula i-NAS kwixesha elidlulileyo, kwaye iidiski zazishushu ngokwenene ... andizange ndilinganise ubushushu ngelo xesha, kodwa ndaqala ukuba nexhala. Unokufumana iingxoxo ezininzi kwi-NAS yobushushu bokuqhuba kwaye uyibeke esweni kwindawo yeLinux/Python. Kodwa akukho nasinye sezicombululo esandincedayo!
Into ebendiyifuna:
Siza kuqokelela idatha nge -SNMP protocol ngephakheji ye-pysnmp .
Ukuqonda i-SNMP kunye ne-MIBs
I-SNMP (iProtocol yoLawulo lweNethiwekhi elula) yinkqubo esetyenziswa ngokubanzi yokubeka iliso kwimpilo kunye nokusebenza kwezixhobo zenethiwekhi. Ivumela ukuqokelelwa kwedatha efana namaqondo obushushu, ukusetyenziswa kwe-CPU, kunye nesimo sediski.
Ii-MIBs (iZiseko zoLawulo lweeNkcukacha) ziinkcukacha zolwazi ezinokubuzwa ngeSNMP. Inxalenye nganye yedatha ichongiwe yi-OID (Isichongi seNto), echonga ngokukodwa ukuguquguquka okunokufundwa okanye ukusetwa nge-SNMP.
Kufuneka uchaze amaxabiso e-MIB oza kuwaqokelela. NdineSynology NAS. Bapapasha ifayile ye-MIB kumaphepha abo. Kufuneka siqokelele:
Kukho i -chatbot ebalaseleyo kwiphepha le-pysnmp. Yabhala umzimba weskripthi sePython kum, iphatha bonke ubunzima ngeSNMP API kunye nokusingatha iifowuni ze-async. Icandelo eliphambili lilandelayo:
async def run(server_name, ipaddress, username, passwd, outinfo): # SNMP walk for disk name, model, and temperature oids = [ ObjectType(ObjectIdentity('1.3.6.1.4.1.6574.2.1.1.2')), # Disk name (diskID) ObjectType(ObjectIdentity('1.3.6.1.4.1.6574.2.1.1.3')), # Disk model (diskModel) ObjectType(ObjectIdentity('1.3.6.1.4.1.6574.2.1.1.6')) # Disk temperature (diskTemperature) ] errorIndication, errorStatus, errorIndex, varBinds = await bulkCmd( SnmpEngine(), UsmUserData(username, passwd, authProtocol=usmHMACSHAAuthProtocol), # Use the appropriate auth protocol await UdpTransportTarget.create((ipaddress, 161)), ContextData(), 0, 10, # Increase the max-repetitions to get more results in one request *oids # Query disk name, model, and temperature ) if errorIndication: print(f"Error: {errorIndication}") elif errorStatus: print(f"Error Status: {errorStatus.prettyPrint()} at {errorIndex and varBinds[int(errorIndex) - 1] or '?'}") else: disk_data = {} for varBind in varBinds: oid, value = varBind oid_str = str(oid) # Disk name if oid_str.startswith('1.3.6.1.4.1.6574.2.1.1.2'): index = oid_str.split('.')[-1] if index not in disk_data: disk_data[index] = {} disk_data[index]['name'] = value # Disk model elif oid_str.startswith('1.3.6.1.4.1.6574.2.1.1.3'): index = oid_str.split('.')[-1] if index not in disk_data: disk_data[index] = {} disk_data[index]['model'] = value # Disk temperature elif oid_str.startswith('1.3.6.1.4.1.6574.2.1.1.6'): index = oid_str.split('.')[-1] if index not in disk_data: disk_data[index] = {} disk_data[index]['temperature'] = value # Print out the disk information for index, info in disk_data.items(): name = info.get('name', 'Unknown') model = info.get('model', 'Unknown') temperature = info.get('temperature', 'Unknown') name = str(name) model = str(model) temperature = str(temperature) print(f"IP Address {ipaddress}, Disk {index}: Name: {name}, Model: {model}, Temperature: {temperature} °C") outinfo.append({'server_name': server_name, 'ip': ipaddress, 'disk': index, 'name': name, 'model': model, 'temperature': temperature})
Kufuneka wenze iprotocol yeSNMP kwiSynology NAS useto:
Ndithumele iskripthi ngokuthe ngqo kwi-NAS kwindawo yeDocker. Kuya kufuneka uqinisekise ukuba isikhongozeli seDocker siqala kwakhona emva kokuba uqalise kwakhona. Ndisete ifayile ye-docker-compose.yaml elula ngenxa yeso sizathu:
version: '3.8' services: pingchart: build: . restart: always container_name: synology-temperature
Emva koko qala iDocker nge docker-compose up -d
.
Ndidibene ne -2minlog -inkqubo elula yokuqokelela, inkqubo, kunye nombono wedatha. Uthumela idatha apho ngezicelo ze-HTTPS (ezifakwe kwi-URL okanye emzimbeni) kwaye umise iskripthi sokubonwayo apho. Iigrafu ke zifumaneka ngokulula naphi na apho ufuna khona.
Ungasebenzisa i-2minlog. Kungenjalo, ungathumela idatha kwisiseko sedatha okanye inkqubo yefayile yendawo.
Ndiseta iskripthi esilula seMatplotlib ukubonisa igrafu. Ngokwenyani, ndicele i-ChatGPT (o1-preview) ukuba iyenze, kwaye yenze kakuhle kakhulu. Umbhalo wePython wawungafezekanga, kodwa wawulungile ngokwaneleyo ukugqiba umsebenzi ngokukhawuleza. I-prompt ingezantsi.
Here is a csv file. Can you write a code: Split data into different graphs by combining the server name and name (eg, DS920+ / Disk 1). Each graph will show the temperature. There will be a title in each graph (eg, DS920+ / Disk 1) The graphs will have the same temperature range. The background will be black, graph background will be also black, the graph color will be from dark green (low temperatures) to light green (high temperatures). There will be two thin lines - 20 °C (blue) and 45 °C (red). Trim the data for last week with tickmarks at midnight of every day. The data are in UTC time. Convert it to Europe/Berlin time zone. The resolution of the total image is hxw 600 x 1024 pixels. Save the image to PNG. disk,ip,model,name,server_name,temperature,timestamp 0,10.0.0.9,ST4000VN008-2DR166,Disk 3,DS920+,38,2024-09-19T20:19:48.723761 1,10.0.0.9,ST16000NM000J-2TW103,Disk 4,DS920+,42,2024-09-19T20:19:49.253975 2,10.0.0.9,ST4000VX007-2DT166,Disk 1,DS920+,38,2024-09-19T20:19:49.818734 3,10.0.0.9,ST4000VX007-2DT166,Disk 2,DS920+,39,2024-09-19T20:19:50.393793 0,10.0.2.9,ST12000NM001G-2MV103,Disk 1,DS220j,28,2024-09-19T20:19:50.873142 0,10.0.0.9,ST4000VN008-2DR166,Disk 3,DS920+,38,2024-09-19T20:20:02.119583 1,10.0.0.9,ST16000NM000J-2TW103,Disk 4,DS920+,42,2024-09-19T20:20:02.596654 2,10.0.0.9,ST4000VX007-2DT166,Disk 1,DS920+,38,2024-09-19T20:20:03.101480 3,10.0.0.9,ST4000VX007-2DT166,Disk 2,DS920+,39,2024-09-19T20:20:03.697423 0,10.0.2.9,ST12000NM001G-2MV103,Disk 1,DS220j,28,2024-09-19T20:20:04.221348 0,10.0.0.9,ST4000VN008-2DR166,Disk 3,DS920+,38,2024-09-19T20:25:02.254611 1,10.0.0.9,ST16000NM000J-2TW103,Disk 4,DS920+,42,2024-09-19T20:25:02.714633 2,10.0.0.9,ST4000VX007-2DT166,Disk 1,DS920+,38,2024-09-19T20:25:03.295622 3,10.0.0.9,ST4000VX007-2DT166,Disk 2,DS920+,39,2024-09-19T20:25:03.780728 ...
Iskripthi sokubonwayo sisetyenziswe ngaphakathi kweqonga le-2minlog. Ungayiqhuba nalapha ekhaya.
Iskripthi siyafumaneka kwi -GitHub .
Ungasebenzisa i -2minlog elawulwa ngokupheleleyo ukuqokelela, inkqubo, kunye nombono wedatha. Jonga uxwebhu . Ndibonisa iziphumo kwithebhulethi ye-Android ehleli etafileni yam kwaye ndijikeleze ngeegrafu ezahlukeneyo ngeTuner yoMfanekiso . Unako kwakhona ukugcina idatha kwinkqubo yakho yefayile yendawo kwaye wenze okufanayo.
Isisombululo sivavanywa kwi-Synology NAS, kodwa sinokuhlengahlengiswa kwabanye.
#Synology #SynologyNAS #Temperature #Monitoring #DataVisualization #Matplotlib #SNMP #2minlog #Python #Docker