Pagina 1 di 1

Esempio di reporting SQL

Pubblicato: 28 febbraio 2019 - 15:34
di Mathieu
Salve,

dopo aver assistito alla presentazione della versione 1.7, sarebbe possibile avere alcuni esempi delle vostre query? Ne abbiamo viste alcune che potrebbero interessarci (non conosco affatto SQL).

Spero sia possibile.

Grazie.

Re: Esempio di report SQL

Pubblicato: 28 febbraio 2019 - 18:21
di kguerineau
Ciao Mathieu,

Ecco alcune query SQL che eseguiamo internamente.

Sinceramente,

Kevin



Numero di macchine:

Codice: Seleziona tutto

select count(*) as "Nb_Machines" from hosts


Stato delle installazioni WAPT

Codice: Seleziona tutto

SELECT h.uuid,h.computer_fqdn,install_date::date,version,h.listening_timestamp::timestamp from hostsoftwares s
left join hosts h on h.uuid=s.host_id
where
 s.key='WAPT_is1'
and
 h.listening_timestamp>='20190118'
Elenco delle macchine con sistema operativo Windows e chiave

Codice: Seleziona tutto

select computer_name,os_name,os_version,host_info->'windows_product_infos'->'product_key' as windows_product_key from hosts order by 3,1
Elenco dei pacchetti presenti nel repository WAPT locale

Codice: Seleziona tutto

select package,version,architecture,description,section,package_uuid,count(*)
from packages
group by 1,2,3,4,5,6   
Macchine in attesa di aggiornamento

Codice: Seleziona tutto

select
  computer_fqdn, host_status, last_seen_on::date,h.wapt_status,string_agg(distinct lower(s.package),' ')
from hosts h
left join hostpackagesstatus s on s.host_id=h.uuid and s.install_status != 'OK'
where (last_seen_on::date > (current_timestamp - interval '1 week')::date and host_status!='OK')
group by 1,2,3,4