Fix pdf generation

This commit is contained in:
Alfredo Cardigliano 2023-01-25 16:02:25 +01:00
parent ca1bcc5ee2
commit 01bf5dc0ef

View file

@ -19,7 +19,7 @@ from ntopng.ntopng import Ntopng
### NTOPNG API SETUP
username = "admin"
password = "admin"
password = "admin1"
ntopng_url = "http://localhost:3000"
iface_id = 0
auth_token = None
@ -32,6 +32,8 @@ yesterday = (actual_ts - 86400)
######### DATA COLLECTOR #########
##################################
print("Connecting to ntopng...")
try:
my_ntopng = Ntopng(username, password, auth_token, ntopng_url)
@ -41,6 +43,8 @@ except ValueError as e:
print(e)
os._exit(-1)
print("Collecting data...")
try:
my_interface = my_ntopng.get_interface(iface_id)
my_historical = my_ntopng.get_historical_interface(iface_id)
@ -268,11 +272,12 @@ pdf.image("hosts_table.png", x=10, y=135, w=190, h=65)
plot_up_down()
pdf.image("series.png", x=10, y=210, w=190, h=85)
created_files.append("report.pdf")
created_files.append("series.png")
print("Generating PDF...")
pdf.output(f"./report.pdf", "F")
for file in created_files:
delete_file(file)