Skip to content

Conversation

@garbled1
Copy link
Contributor

Patch 4/4: Create a CSV output report with the addition of bugfix and security patches needed broken out.

Add files via upload No \n at end no \n Add call to list_hosts if -lhc remove stray @models thing
@furlongm
Copy link
Owner

What is the use-case for this PR?

@garbled1
Copy link
Contributor Author

Current report format is not easily machine parsable. I need to be able to archive reports for audit purposes. Current report also does not separate out bugfix/security whereas the web interface does. The web interface is useful for quick looks, but I need reporting features and the ability to parse the data.

@furlongm
Copy link
Owner

However, there is a REST API that could be used to produce machine-parsable output.

@dandunckelman
Copy link

However, there is a REST API that could be used to produce machine-parsable output.

When calling /api/hosts, can it return the list of updates into separate sections?

For example:

{ "updates": { "bugfix": [ "http://localhost/patchman/api/package-update/173/" ], "security": [ "http://localhost/patchman/api/package-update/182/" ] ] } 

Otherwise, I'll have to do something like this (psuedo-code), which I expect to take much longer (at least, I assume...this is untested):

hosts = get "/api/hosts" for host in hosts: updates = { "bugfix": [], "security": [] } for update_url in host.updates update = get "update_url" if update.security: updates['security'].append( update ) else updates['bugfix'].append( update ) host['updates'] = updates # overwrite flat list with more detailed dict 

For me, I want to be alerted only when there are security updates available. And right now, my script only alerts me when the list of updates is not empty since I don't have the knowledge of update "type".

@BuJo
Copy link

BuJo commented Oct 12, 2020

Hi,

just to reinforce that this in general would be nice to have.

My usecase is that I have multiple Patchman instances, and I want to create a basic dashboard for those.

I'd love to have basically a summary for the hosts (at least hostname, additional host information, number of critical updates, updates).

The current API would require me to crawl all the update-URLs, which is prohibitively expensive.

CSV is good common format, however I'd prefer it to be JSON like the rest of the API. Another API approach would be to allow 'joining' Models before serializing them, however that'd make the API-Responses even more heavyweight.

@furlongm
Copy link
Owner

Hi,

just to reinforce that this in general would be nice to have.

My usecase is that I have multiple Patchman instances, and I want to create a basic dashboard for those.

I'd love to have basically a summary for the hosts (at least hostname, additional host information, number of critical updates, updates).

The current API would require me to crawl all the update-URLs, which is prohibitively expensive.

CSV is good common format, however I'd prefer it to be JSON like the rest of the API. Another API approach would be to allow 'joining' Models before serializing them, however that'd make the API-Responses even more heavyweight.

I am looking at updating the API to give the info requested.

This script might be useful for anyone who wants to test: https://gist.github.com/furlongm/a194697b7aa171411b7fffe2a64b06cc

Crawling the update urls is expensive so trying to think of the best way of representing the updates in the current API? I think the API could probably give info about the number of security and bugfix updates per host, and that might be enough, or maybe just a list of package names that are out of date?

@BuJo
Copy link

BuJo commented Oct 15, 2020

I'd think the backwards compatibility of the current API should largely be retained. I'd avoid removing the current fields, however adding fields shouldn't be a problem.

I would be happy with just new count fields as a kind of 'summary'. I think the OP only needed the counts as well?

@furlongm
Copy link
Owner

c9f29f1 adds the counts for security and bugfix updates to the API. Let me know if that works

@BuJo
Copy link

BuJo commented Feb 19, 2021

Very cool, I will try it out, thank you @furlongm

@BuJo
Copy link

BuJo commented Feb 26, 2021

@furlongm I rolled out the newest Version, it works perfectly for my usecase. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants