If the API call fails, what data is returned? If it's null, that's easy, just exit out.
I think it comes down to how you are parsing the API response.
In my experience, simply exiting the EA script does not do the trick. The problem is in how the jamf binary gathers data during an inventory collection. I have some older EAs that I have deprecated but not deleted from my Jamf instance, and what I get is that the value gets blanked out. In the scripts themselves, there is an exit 0
right at the top, but the previous values don't remain, because when the jamf binary uploads it's data collection, it must put something in the value for each EA. If it doesn't get anything, it uploads a blank value, and overwrites what was there before with a null value.
So, I get where this post is going and the problem.
@donmontalvo What I would suggest is rewriting your EA to capture a value and send it to a local file or plist on each run (in addition to echoing it back in the result tags), if it came back with something. Within your EA script, if the JSS isn't responding, grab the value from the file/plist instead and use that within the <result></result>
tags. So that way, if it can't grab an updated string, it uses the previously gotten value stored on disk.
Hope that helps.
@mm2270 that makes sense. So basically...
- API script > /tmp/apiTempFile.txt
- cat /tmp/apiTempFile.txt for the three possible values X|Y|Z
- If value matches one of the three, then overwrite the /Library/Company/APIscripts/apiResult.txt (which is what EA reads).
Testing...
Yeah, pretty much. Sounds like you're already writing info into a local file. Maybe it can just pick up that value if it has trouble pulling something via the API.
Taking a step back a moment though, it just occurred to me, in what situation are you seeing a case where the EA script can't connect to your Jamf Pro instance, but it's still running a recon? Or do you have a separate ongoing policy calling a script to get those values? I guess what I'm asking is, if your JSS isn't available, how would EAs even be run in the first place?
@mm2270 sorry for the late response. This can happen if the computer is in the DMZ (we cripple API).