remove cisco module and all refreneces
This commit is contained in:
parent
5ba5e6eda1
commit
9fbd9c1ca0
5 changed files with 4 additions and 101 deletions
|
@ -1,60 +0,0 @@
|
|||
from logging import getLogger
|
||||
from requests import Session, Request
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from varken.helpers import connection_handler
|
||||
|
||||
|
||||
class CiscoAPI(object):
|
||||
def __init__(self, firewall, dbmanager):
|
||||
self.dbmanager = dbmanager
|
||||
self.firewall = firewall
|
||||
# Create session to reduce server web thread load, and globally define pageSize for all requests
|
||||
self.session = Session()
|
||||
self.session.auth = (self.firewall.username, self.firewall.password)
|
||||
self.logger = getLogger()
|
||||
|
||||
self.get_token()
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ciscoasa-{self.firewall.id}>"
|
||||
|
||||
def get_token(self):
|
||||
endpoint = '/api/tokenservices'
|
||||
|
||||
req = self.session.prepare_request(Request('POST', self.firewall.url + endpoint))
|
||||
post = connection_handler(self.session, req, self.firewall.verify_ssl)
|
||||
|
||||
if not post:
|
||||
return
|
||||
|
||||
self.session.headers = {'X-Auth-Token': post}
|
||||
|
||||
def get_bandwidth(self):
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
endpoint = '/api/monitoring/device/interfaces/' + self.firewall.outside_interface
|
||||
|
||||
if not self.session.headers:
|
||||
return
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.firewall.url + endpoint))
|
||||
get = connection_handler(self.session, req, self.firewall.verify_ssl)
|
||||
|
||||
if not get:
|
||||
return
|
||||
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "Cisco ASA",
|
||||
"tags": {
|
||||
"interface": self.firewall.outside_interface
|
||||
},
|
||||
"time": now,
|
||||
"fields": {
|
||||
"upload_bitrate": get['outputBitRate'],
|
||||
"download_bitrate": get['inputBitRate']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
self.dbmanager.write_points(influx_payload)
|
|
@ -7,7 +7,7 @@ from configparser import ConfigParser, NoOptionError, NoSectionError
|
|||
from varken.varkenlogger import BlacklistFilter
|
||||
from varken.structures import SickChillServer, UniFiServer
|
||||
from varken.helpers import clean_sid_check, rfc1918_ip_check
|
||||
from varken.structures import SonarrServer, RadarrServer, OmbiServer, TautulliServer, InfluxServer, CiscoASAFirewall
|
||||
from varken.structures import SonarrServer, RadarrServer, OmbiServer, TautulliServer, InfluxServer
|
||||
|
||||
|
||||
class INIParser(object):
|
||||
|
@ -15,7 +15,7 @@ class INIParser(object):
|
|||
self.config = None
|
||||
self.data_folder = data_folder
|
||||
self.filtered_strings = None
|
||||
self.services = ['sonarr', 'radarr', 'ombi', 'tautulli', 'sickchill', 'ciscoasa', 'unifi']
|
||||
self.services = ['sonarr', 'radarr', 'ombi', 'tautulli', 'sickchill', 'unifi']
|
||||
|
||||
self.logger = getLogger()
|
||||
self.influx_server = InfluxServer()
|
||||
|
@ -248,20 +248,9 @@ class INIParser(object):
|
|||
verify_ssl=verify_ssl, get_missing=get_missing,
|
||||
get_missing_run_seconds=get_missing_run_seconds)
|
||||
|
||||
if service in ['ciscoasa', 'unifi']:
|
||||
if service == 'unifi':
|
||||
username = self.config.get(section, 'username')
|
||||
password = self.config.get(section, 'password')
|
||||
|
||||
if service == 'ciscoasa':
|
||||
outside_interface = self.config.get(section, 'outside_interface')
|
||||
get_bandwidth_run_seconds = self.config.getint(section, 'get_bandwidth_run_seconds')
|
||||
|
||||
server = CiscoASAFirewall(id=server_id, url=scheme + url, verify_ssl=verify_ssl,
|
||||
username=username, password=password,
|
||||
outside_interface=outside_interface,
|
||||
get_bandwidth_run_seconds=get_bandwidth_run_seconds)
|
||||
|
||||
if service == 'unifi':
|
||||
site = self.config.get(section, 'site').lower()
|
||||
usg_name = self.config.get(section, 'usg_name')
|
||||
get_usg_stats_run_seconds = self.config.getint(section, 'get_usg_stats_run_seconds')
|
||||
|
|
|
@ -76,16 +76,6 @@ class SickChillServer(NamedTuple):
|
|||
verify_ssl: bool = False
|
||||
|
||||
|
||||
class CiscoASAFirewall(NamedTuple):
|
||||
get_bandwidth_run_seconds: int = 30
|
||||
id: int = None
|
||||
outside_interface: str = None
|
||||
password: str = 'cisco'
|
||||
url: str = '192.168.1.1'
|
||||
username: str = 'cisco'
|
||||
verify_ssl: bool = False
|
||||
|
||||
|
||||
class UniFiServer(NamedTuple):
|
||||
get_usg_stats_run_seconds: int = 30
|
||||
id: int = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue