yeni
This commit is contained in:
24
ssh_manager/apps.py
Normal file
24
ssh_manager/apps.py
Normal file
@ -0,0 +1,24 @@
|
||||
from django.apps import AppConfig
|
||||
from django.conf import settings
|
||||
|
||||
def check_server_connection():
|
||||
from .ssh_client import SSHManager # utils yerine ssh_client'dan import et
|
||||
from .models import SSHCredential
|
||||
|
||||
# Tüm SSH bağlantılarını kontrol et
|
||||
for credential in SSHCredential.objects.all():
|
||||
ssh_manager = SSHManager(credential)
|
||||
is_online = ssh_manager.check_connection()
|
||||
|
||||
# Bağlantı durumunu güncelle
|
||||
credential.is_online = is_online
|
||||
credential.save(update_fields=['is_online', 'last_check'])
|
||||
|
||||
ssh_manager.close()
|
||||
|
||||
class SshManagerConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'ssh_manager'
|
||||
|
||||
def ready(self):
|
||||
import ssh_manager.signals # signals'ı import et
|
||||
Reference in New Issue
Block a user