icinga2-checks/check_openwrt_bssid.py

29 lines
668 B
Python
Raw Normal View History

import paramiko
def check_bssid():
hostname = 'hostname'
username = 'username'
password = 'password'
specific_bssid = 'specific_bssid'
command = 'iw wlan0 scan | grep BSS'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname, username=username, password=password)
stdin, stdout, stderr = ssh.exec_command(command)
output = stdout.readlines()
for line in output:
if specific_bssid in line:
print(f'BSSID {specific_bssid} is present.')
return True
print(f'BSSID {specific_bssid} is not present.')
return False
check_bssid()