I figured it out!
The offending SQL statement is:
Code:
DELETE FROM other WHERE other_linked_pc = ''
This is coming from delete_systems.php
Since networked "other" items are stand-alone and not linked to a PC, they will all have blank "other_linked_pc" fields. The non-networked "other" items have something in that field, so they are unaffected.
What I believe is happening is this: occasionally a failed attempt at an audit will produce some garbage data. I can only speculate how this happens, maybe audit.vbs is starting to run on a system, but the system being audited shuts down before it finishes. Or something like that. Then I end up occasionally with "system" records that have maybe an IP address and nothing else, and in particular, a blank "system_uuid". When I see these I say "oh, some garbage, lets delete it." So I go to delete_systems.php, select the garbage record and delete. The junk record vanishes and I'm happy (or so I think). Later I notice that all my networked "other" items are gone.
That's because deleting a system with a blank "system_uuid" ends up issuing the query listed above.
I don't think this had anything to do with my running of the script that scans the network. That was probably coincidence (other than the fact that it is when the script runs that once in a while I get the junk entries).
I think I'm going edit delete_systems.php so that the part that does all the delete queries is wrapped in an "if" statement that won't run the queries if "$id" is empty.