Skip to main content
Question

API script help - how to prevent overwrite of EA value if Jamf Pro not responding


donmontalvo
Forum|alt.badge.img+36

We are using an API script to get the Site a computer is in. That works fine. When Jamf Pro is working.

What blob of code are you using in your script that exits out if Jamf Pro is not responding.

By "not responding" we don't mean using ping, we mean Jamf Pro is not responding.

healthCheck.html value doesn't seem to do the trick, since [] shows even if API calls fail.

Basically if API call is successful, populate EA, else leave EA value alone.

5 replies

Forum|alt.badge.img+17
  • Contributor
  • 881 replies
  • February 7, 2018

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.


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • February 7, 2018

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.


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Legendary Contributor
  • 4293 replies
  • February 7, 2018

@mm2270 that makes sense. So basically...

  1. API script > /tmp/apiTempFile.txt
  2. cat /tmp/apiTempFile.txt for the three possible values X|Y|Z
  3. If value matches one of the three, then overwrite the /Library/Company/APIscripts/apiResult.txt (which is what EA reads).

Testing...


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • February 7, 2018

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?


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Legendary Contributor
  • 4293 replies
  • March 12, 2018

@mm2270 sorry for the late response. This can happen if the computer is in the DMZ (we cripple API).


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings