Linux ve Sistem
1 dakika okuma
Raspberry Pi ile Network Monitor
Raspberry Pi ve Python ile ev agini izleyen basit bir network monitor uygulamasi.
E
Emre Cihan Proje Hedefi
Ev agindaki cihazlari izleyen, yeni cihaz baglandiginda bildirim gonderen hafif bir sistem.
Kurulum
sudo apt install nmap python3-pip sqlite3 -y
pip3 install python-nmap schedule
Ana Script
import nmap, sqlite3, schedule, time
from datetime import datetime
def scan_network(subnet='192.168.1.0/24'):
nm = nmap.PortScanner()
nm.scan(hosts=subnet, arguments='-sn')
return [{'ip': h, 'mac': nm[h]['addresses'].get('mac','?')} for h in nm.all_hosts()]
def job():
devices = scan_network()
print(f'{datetime.now()}: {len(devices)} cihaz')
schedule.every(5).minutes.do(job)
while True:
schedule.run_pending()
time.sleep(1)
Systemd Servisi
[Unit]
Description=Network Monitor
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/monitor.py
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl enable --now network-monitor
Paylaş:
Twitter / X
E
Emre Cihan
Sistem Yöneticisi · Maker · Elektronik Meraklısı
İlgili yazılar
Linux ve Sistem
Nginx Nedir? Web Sunucusu ve Reverse Proxy Olarak Kullanımı
3 dk
Linux ve Sistem
VMware ESXi Nedir? Kurulum, Yönetim ve Sanallaştırma Mimarisi
3 dk
Linux ve Sistem
Proxmox VE Nedir? ESXi'ye Ücretsiz Alternatif mi?
3 dk
Linux ve Sistem
Reverse Proxy Nedir? Nginx ile Kurulum ve Kullanım Senaryoları
3 dk