Fix git safe directory issue
()
| 10269 | lost_days = float(lost_days) |
| 10270 | except (TypeError, ValueError): |
| 10271 | lost_days = 8 |
| 10272 | |
| 10273 | offline_cutoff = datetime.now() - timedelta(hours=offline_hours) |
| 10274 | lost_cutoff = datetime.now() - timedelta(days=lost_days) |
| 10275 | hosts_lost = [] |
| 10276 | hosts_offline = [] |
| 10277 | |
| 10278 | for ip, data in existing_data.items(): |
| 10279 | status = 'Online' |
| 10280 | last_seen_str = data.get('last_seen') or current_time |
| 10281 | try: |
| 10282 | last_seen_dt = datetime.fromisoformat(last_seen_str) |
| 10283 | except Exception: |
| 10284 | last_seen_dt = datetime.now() |
| 10285 | |
| 10286 | if last_seen_dt < lost_cutoff: |
| 10287 | status = 'Lost' |
| 10288 | data['alive'] = False |
| 10289 | hosts_lost.append(ip) |
| 10290 | elif last_seen_dt < offline_cutoff: |
| 10291 | status = 'Offline' |
| 10292 | data['alive'] = False |
| 10293 | hosts_offline.append(ip) |
| 10294 | else: |
| 10295 | status = 'Online' if data.get('alive', True) else 'Offline' |
| 10296 | |
| 10297 | data['status'] = status |
| 10298 | |
| 10299 | # Resolve findings for lost/offline hosts (network intelligence) |
| 10300 | if hasattr(shared_data, 'network_intelligence') and shared_data.network_intelligence: |
| 10301 | for ip in hosts_lost: |
| 10302 | try: |
| 10303 | shared_data.network_intelligence.resolve_host_findings(ip, reason="host_lost_timeout") |
| 10304 | except Exception as e: |
| 10305 | logger.error(f"Failed to resolve findings for lost host {ip}: {e}") |
| 10306 | for ip in hosts_offline: |