Add a list hosts CSV output with security/bugfix broken out.
Patch 4/4: Create a CSV output report with the addition of bugfix and security patches needed broken out.
What is the use-case for this PR?
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.
However, there is a REST API that could be used to produce machine-parsable output.
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".
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.
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?
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?
c9f29f1af835ffe794fdfc5c5dcf2926d61724e9 adds the counts for security and bugfix updates to the API. Let me know if that works
Very cool, I will try it out, thank you @furlongm
@furlongm I rolled out the newest Version, it works perfectly for my usecase. Thank you so much!