Posted on 05-30-2022 07:02 AM
Hi all...I'm trying to find a way to trigger a report of a few things from our Jamf Pro cloud and I'm not too sure what's the best way (or if it's possible) to do this. In short, the report should be gathering some info such...Total Macs, Total Macs with a specific app, Total Macs checked-in in the last month, etc...I know these reports can be triggered individually, via Advanced Search (we have already one scheduled like that), but I'm looking to compile these multiple reports in 1 and scheduled to be sent monthly...I also created a script to gather these things with via APIs (using curl), but I'm not sure if I can use it in the above scenario. Any thoughts?
Posted on 05-30-2022 07:27 PM
You definitely can. If you already are getting data from the Advanced Search API endpoint what's the specific issue you're having? Formatting? What's a bit counter-intuitive about Advanced Searches are the display options. You have to set those to get those attributes per device in your output.
Posted on 05-31-2022 03:56 AM
Hi @brockwalters , I think I'm not explaining myself correctly - I need to trigger a report customized in this way and to be sent to a specific mailbox:
Description | Number |
Total number of Macs in Jamf | |
Total number of Macs with agent installed | |
Total Unsupported Macs (older than 5 years - iMacs included) | |
Total number of Macs checked-in less than 30 days |
Is there a way to accomplish something like that with the Advanced Search options?
Thanks,
CC
Posted on 05-31-2022 10:34 AM
So, yes, but...
To accomplish this In my Jamf instance one of the searches you would need to build would look like this:
However, that is relying on a custom extension attribute I wrote to get the year from the Marketing Model name which I posted here... If you don't use that there isn't a good way to build a Smart Group that finds computers by model year (which is why I wrote it.😶 )
Another issue is "total number of Macs in Jamf." When you build a search that defines a criteria that some devices in your fleet match & some don't you are de facto creating a subset of your total number of devices.
So, you will need to create a 2nd search that just has everything, i.e., save it. just don't put any criteria in it.
So, what would have is 2 .csv files. 1 would basically be your "report" the other is simply a single-column list of all of your computers. If you remove the 1st line of that .csv (i.e., the header) & count the lines you could easily pop that value into your other .csv e.g.,
% sed '1d' Everything.csv | wc -l
912
% total="$(sed '1d' Everything.csv | wc -l)"
Description,Number
Total number of Macs in Jamf,"$total"
Total number of Macs with agent installed,1234
Total Unsupported Macs (older than 5 years - iMacs included),1234
Total number of Macs checked-in less than 30 days,1234
Your script would have 2 api calls to the 2 searches & a little computer magic to make a single .csv - then you need something to send the email. I have done this kind of thing with Python smtplib in the past. Let me know if you have other questions!
Posted on 05-31-2022 11:49 AM
Thanks for the info, but the problem will still be the "how-can-I-wrap-this-and-send-it-via-email", right? :)
Anyways, I built a script using APIs to get the info and formatted into a .csv, but it will save it somewhere on my Mac. The desired way is to get this .csv landed on a Sharepoint location, which I don't think I can spin this out somehow, because of the rights to that location (maybe!?).