Added pip packaging

This commit is contained in:
Luca Deri 2022-12-04 12:41:22 +01:00
parent 52a4c1e369
commit d5d15aadfa
8 changed files with 66 additions and 42 deletions

View file

@ -6,10 +6,7 @@
# https://www.ntop.org/guides/ntopng/api/rest/api_v2.html
#
import requests
import json
from requests.auth import HTTPBasicAuth
from ntopng import ntopng
import ntopng
class host:
def __init__(self, ntopng_obj):
@ -18,19 +15,19 @@ class host:
self.rest_pro_v2_url = "/lua/pro/rest/v2"
def get_active_hosts(self, ifid):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/active.lua", {"ifid": ifid}))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/active.lua", {"ifid": ifid}))
def get_active_hosts_paginated(self, ifid, currentPage, perPage):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/active.lua", {"ifid": ifid, "currentPage": currentPage, "perPage": perPage}))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/active.lua", {"ifid": ifid, "currentPage": currentPage, "perPage": perPage}))
def get_host_interfaces(self, host):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/interfaces.lua", { "host": host }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/interfaces.lua", { "host": host }))
def get_host_data(self, ifid, host):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/data.lua", { "ifid": ifid, "host": host }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/data.lua", { "ifid": ifid, "host": host }))
def get_host_l7_stats(self, ifid, host, vlan):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/l7/stats.lua", { "ifid": ifid, "host": host, "vlan": vlan, "breed": True, "ndpi_category": True, "collapse_stats": False }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/l7/stats.lua", { "ifid": ifid, "host": host, "vlan": vlan, "breed": True, "ndpi_category": True, "collapse_stats": False }))
def get_host_dscp_stats(self, ifid, host, vlan, direction_rcvd):
if(direction_rcvd):
@ -38,31 +35,31 @@ class host:
else:
direction = "sent"
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/host/dscp/stats.lua", { "ifid": ifid, "host": host, "vlan": vlan, "direction": direction }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/host/dscp/stats.lua", { "ifid": ifid, "host": host, "vlan": vlan, "direction": direction }))
def get_top_local_talkers(self, ifid):
return(ntopng.request(self.ntopng_obj, self.rest_pro_v2_url + "/get/interface/top/local/talkers.lua", { "ifid": ifid }))
return(self.ntopng_obj.request(self.rest_pro_v2_url + "/get/interface/top/local/talkers.lua", { "ifid": ifid }))
def get_top_remote_talkers(self, ifid):
return(ntopng.request(self.ntopng_obj, self.rest_pro_v2_url + "/get/interface/top/remote/talkers.lua", { "ifid": ifid }))
return(self.ntopng_obj.request(self.rest_pro_v2_url + "/get/interface/top/remote/talkers.lua", { "ifid": ifid }))
def get_alert_types(self):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/type/consts.lua", None))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/type/consts.lua", None))
def get_alert_severities(self):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/severity/consts.lua", None))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/severity/consts.lua", None))
def get_historical_alert_type_counters(self, ifid, epoch_begin, epoch_end):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/type/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/type/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
def get_historical_flows_type_counters(self, ifid, epoch_begin, epoch_end):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/type/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/type/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
def get_historical_alert_severity_counters(self, ifid, epoch_begin, epoch_end):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/severity/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/severity/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
def get_historical_flows_severity_counters(self, ifid, epoch_begin, epoch_end):
return(ntopng.request(self.ntopng_obj, self.rest_v2_url + "/get/alert/severity/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
return(self.ntopng_obj.request(self.rest_v2_url + "/get/alert/severity/counters.lua", { "ifid": ifid, "status": "historical", "epoch_begin": epoch_begin, "epoch_end": epoch_end }))
def self_test(self, ifid):