Page 1 of 1

[RESOLVED] Package installation logs

Published: Dec 2, 2024 - 4:38 PM
by Emeric
Hello,

I would like to retrieve the logs from the "Installation Logs for package ***" to more easily audit my infrastructure. The goal is to create a CSV file named "Machine;Installation Logs for package ***".

I have tried to perform this operation via a query in the reporting system as well as through the API, but I haven't found a solution.

I am currently using Enterprise version 2.2.0.11720.

Thank you in advance for your help.

Re: Package installation logs

Published: Dec 2, 2024 - 5:27 PM
by Jarnaud
Good morning,

I can offer you this:

Code: Select all

SELECT
    h.computer_name AS Machine,
    h.computer_fqdn AS FQDN,
    p.name AS Package_Name,
    p.install_status AS Installation_Status,
    p.install_date AS Installation_Date,
    p.install_output AS Installation_Logs
FROM
    hostpackagesstatus p
JOIN
    hosts h
ON
    p.host_id = h.uuid
WHERE
    p.install_status IS NOT NULL
ORDER BY
    h.computer_name, p.install_date;
Would that suit you?

Yours sincerely

Re: Package installation logs

Published: Dec 3, 2024 - 09:17
by Emeric
Hello Jarnaud,

Great, that's perfect! 🙂

Is it possible to retrieve this request via the API? (I haven't seen this feature).

Something like this: https://wapt.myserveur.local/api/v3/reporting?id=3

Re: Package installation logs

Published: Dec 3, 2024 - 10:44 AM
by Jarnaud
Hello Emeric,

Of course, it's possible.
https://www.wapt.fr/fr/doc/wapt-api.htm ... rting-exec

Code: Select all

import os
import json
import logging
import waptlicences
import requests
import sys
sys.path.append('/opt/wapt')
from common import get_requests_client_cert_session
from common import Wapt



WAPT = Wapt()
ini_wapt_path = WAPT.config_filename
w = Wapt(config_filename=ini_wapt_path)

# WAPT Conf
wapt_url = w.waptserver.server_url

user = "reporting"
password = "password"


def run_report():

    t = waptlicences.waptserver_login(ini_wapt_path,user,password)
    session = get_requests_client_cert_session(wapt_url,
    cert=(t['client_certificate'],t['client_private_key'],t['client_private_key_password']),
    verify=w.waptserver.verify_cert
    )
    session.cookies.set(t['session_cookies'][0]['Name'], t['session_cookies'][0]['Value'], domain=t['session_cookies'][0]['Domain'])
    t= None


    url = f'{wapt_url}/api/v3/reporting_exec?id=19'
    response = session.get(url)
    data = response.json()

    return data['result']



print(run_report())

I'll let you customize the username and password of a WAPT server user.
And you need to replace 2 with your SQL query number (you can see the SQL query IDs in the reporting tab in the left panel), for example:

Code: Select all

url = f'{wapt_url}/api/v3/reporting_exec?id=2
Best regards

[RESOLVED] Package installation logs

Published: Dec 3, 2024 - 11:10
by Emeric
Thank you very much, everything is fine, I'm closing this ticket ;)

Re: [SOLVED] Package installation logs

Published: Dec 3, 2024 - 11:50 AM
by dcardon
Hello Emeric,

regarding your WAPT version, version 2.2 is no longer supported and it would be best to upgrade to 2.5 or even 2.6. :-)

Regards,

Denis