pucherot / Pi.Alert

WIFI / LAN intruder detector. Check the devices connected and alert you with unknown devices. It also warns of the disconnection of "always connected" devices
GNU General Public License v3.0
2.02k stars 124 forks source link

sqlite3.IntegrityError: UNIQUE constraint failed: CurrentScan.cur_ScanCycle, CurrentScan.cur_MAC #5

Closed N0cky closed 3 years ago

N0cky commented 3 years ago

Hi, i am getting this error.

tobias@raspberrypi:~ $ python ~/pialert/back/pialert.py 1 

Pi.Alert 2.52 (2021-01-11)
---------------------------------------------------------
Scan Devices
    ScanCycle: 1
    Timestamp: 2021-01-12 16:20:00

Scanning...
    arp-scan Method...
    Pi-hole Method...
    DHCP Leases Method...

Procesising scan results...
Traceback (most recent call last):
  File "/home/tobias/pialert/back/pialert.py", line 1313, in <module>
    sys.exit(main())       
  File "/home/tobias/pialert/back/pialert.py", line 72, in main
    res = scan_network()
  File "/home/tobias/pialert/back/pialert.py", line 360, in scan_network
    save_scanned_devices (arpscan_devices, cycle_interval)
  File "/home/tobias/pialert/back/pialert.py", line 520, in save_scanned_devices
    p_arpscan_devices) 
sqlite3.IntegrityError: UNIQUE constraint failed: CurrentScan.cur_ScanCycle, CurrentScan.cur_MAC
pucherot commented 3 years ago

How curious, it seems as if you have 2 devices with the same MAC

can you run the following command and post the result?

sudo arp-scan --localnet --ignoredups --retry=9
N0cky commented 3 years ago
tobias@raspberrypi:~ $ sudo arp-scan --localnet --ignoredups --retry=9
[sudo] password for tobias: 
Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9.5 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.178.1   e0:28:6d:6e:53:d8       AVM Audiovisuelles Marketing und Computersysteme GmbH
192.168.178.2   9e:9b:cb:30:2d:cb       (Unknown)
192.168.178.29  00:11:32:30:6b:3f       Synology Incorporated
192.168.178.35  ce:0e:14:22:7e:73       (Unknown)
192.168.178.36  00:17:c8:7f:a4:2a       KYOCERA Display Corporation
192.168.178.37  70:4d:7b:88:0d:5b       ASUSTek COMPUTER INC.
192.168.178.41  70:85:c2:dd:5c:2e       ASRock Incorporation
192.168.178.42  d8:cb:8a:ca:a9:41       Micro-Star INTL CO., LTD.
192.168.178.24  94:65:2d:91:23:98       OnePlus Technology (Shenzhen) Co., Ltd
192.168.178.65  b4:2e:99:43:41:97       GIGA-BYTE TECHNOLOGY CO.,LTD.
192.168.178.20  14:d1:69:9a:9e:b1       HUAWEI TECHNOLOGIES CO.,LTD
192.168.178.43  38:f7:3d:3d:46:d9       Amazon Technologies Inc.
192.168.178.34  00:04:20:2c:2e:64       Slim Devices, Inc.
192.168.178.56  7c:a6:b0:00:65:44       (Unknown)
192.168.178.28  68:a0:f6:9e:0a:7c       HUAWEI TECHNOLOGIES CO.,LTD
192.168.178.64  80:7d:3a:fd:68:98       Espressif Inc.
192.168.178.40  38:a4:ed:b0:ec:47       Xiaomi Communications Co Ltd
192.168.178.203 e0:28:6d:6e:53:d8       AVM Audiovisuelles Marketing und Computersysteme GmbH
192.168.178.202 e0:28:6d:6e:53:d8       AVM Audiovisuelles Marketing und Computersysteme GmbH
192.168.178.84  64:90:c1:0a:65:5d       Beijing Xiaomi Mobile Software Co., Ltd
192.168.178.72  7c:a6:b0:04:71:76       (Unknown)
192.168.178.83  64:90:c1:a3:38:16       Beijing Xiaomi Mobile Software Co., Ltd
192.168.178.82  dc:b7:2e:56:00:a6       Xiaomi Communications Co Ltd
192.168.178.70  40:31:3c:a8:64:e7       XIAOMI Electronics,CO.,LTD
192.168.178.61  a8:db:03:4d:b2:99       SAMSUNG ELECTRO-MECHANICS(THAILAND)

37 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.5: 256 hosts scanned in 39.898 seconds (6.42 hosts/sec). 25 responded

This is the result. It seems like the problem is the VPN i have setup in my router to I have access to my homenetwork from the outside.

pucherot commented 3 years ago

There are one MAC with two IPs;

192.168.178.203 e0:28:6d:6e:53:d8 AVM Audiovisuelles Marketing und Computersysteme GmbH 192.168.178.202 e0:28:6d:6e:53:d8 AVM Audiovisuelles Marketing und Computersysteme GmbH

Is this a Balancer? I will, fix this problem

theniwo commented 3 years ago

Had the same error. When I removed all duplicate Devices I got:

pi@pi4:~$ python ~/pialert/back/pialert.py 1

Pi.Alert 2.52 (2021-01-11)
---------------------------------------------------------
Scan Devices
    ScanCycle: 1
    Timestamp: 2021-01-13 07:32:00

Scanning...
    arp-scan Method...
    Pi-hole Method...
    DHCP Leases Method...

Procesising scan results...
    Devices Detected.......: 9
        arp-scan Method....: 9
        Pi-hole Method.....: +0
        New Devices........: 9

    Devices in this cycle..: 0
        Down Alerts........: 0
        New Down Alerts....: 0
        New Connections....: 0
        Disconnections.....: 0
        IP Changes.........: 0

Updating DB Info...
    Sessions Events (connect / discconnect) ...
    Creating new devices...
Traceback (most recent call last):
  File "/home/pi/pialert/back/pialert.py", line 1313, in <module>
    sys.exit(main())
  File "/home/pi/pialert/back/pialert.py", line 72, in main
    res = scan_network()
  File "/home/pi/pialert/back/pialert.py", line 375, in scan_network
    create_new_devices ()
  File "/home/pi/pialert/back/pialert.py", line 696, in create_new_devices
    (startTime, startTime) )
sqlite3.IntegrityError: UNIQUE constraint failed: Devices.dev_MAC
pucherot commented 3 years ago

Solved in v2.53 (still not released) Please update the file "pialert/back/pialert.py" and test.

theniwo commented 3 years ago

no error for me, but database had to be started over.