This is something I have been wishing for a while and decided to put it together myself. It is ready to be used as a JSS Computer Extension Attribute if you want to automate Druva inSync re-install/re-activate via Smart Group or simply obtain a list of computers on which Druva inSync is currently Inactive.
Please note: the script is using jq JSON parser, which can be installed on each mac using only a script as I posted here: https://community.jamf.com/t5/jamf-pro/homebrew-and-js-deloyment-using-only-scripts/td-p/247472
You can get the script here on my gist: https://gist.github.com/shurkin18/2c0a1e454f5dbac8b91cfca5893e7722
Or from below:
#!/bin/bash
##########################################################################################################################################################################
##########################################################################################################################################################################
# This is a UAPI script which checks for Druva inSync client activation status based on the current mac name
# You need to first add Druva API credentials for this script, you can check that documentation here: https://developer.druva.com/docs/introduction
#
# It can be used on JSS as an Extension Attribute
#
# Please note: this script requires jq JSON parser to be installed on the mac, otherwise the script won't work
# If you are using JAMF JSS, you can read how jq can be pushed via homebrew using only scripts:
# https://community.jamf.com/t5/jamf-pro/homebrew-and-js-deloyment-using-only-scripts/td-p/247472
#
# Created by Aleksandr Kamenev / shurkin18@gmail.com
##########################################################################################################################################################################
##########################################################################################################################################################################
#Druva API credentials
druvaApiURL="https://apis.druva.com"
usernameclientID="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
passwordsecretKEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
################################################################
# DO NOT TOUCH BELOW UNLESS YOU KNOW WHAT YOU ARE DOING! #######
################################################################
# created base64-encoded credentials
encodedCredentials=$( printf "$usernameclientID:$passwordsecretKEY" | /usr/bin/iconv -t ISO-8859-1 | /usr/bin/base64 -i - )
# generate an auth token
authToken=$( /usr/bin/curl -X POST -H "authorization: Basic $encodedCredentials" -d "grant_type=client_credentials&scope=read" $druvaApiURL/token )
# parse authToken for token, omit expiration
token=$( /usr/bin/awk -F \\" '{ print $4 }' <<< "$authToken" | /usr/bin/xargs )
#Debugging
#echo "encodedCredentials are: $encodedCredentials"
#echo "authToken is: $authToken"
#echo "token is: $token"
#///////////////////////
#Start the UAPI scripts#
#Current machine name
currentmacname=$(hostname)
#echo $currentmacname
#Obtain the current device status based on the current machine name
insyncactivationstatus=`curl --request GET \\
--url "$druvaApiURL/insync/endpoints/v1/devices" \\
--header "Accept: application/json" \\
--header "Authorization: Bearer $token" | jq | grep '"deviceName": "'$currentmacname'"' -A 20 | grep "deviceMarkedInactive" | awk -F '"' '{ print $3 }' | sed 's/://g' | head -n 1`
echo "inSync activation status: $insyncactivationstatus"
#Check if Druva is activated and if so provide <result> for JSS extension attribute
if [ $insyncactivationstatus == "false" ];then
echo "<result>Activated</result>"
else
echo "<result>Not Activated</result>"
fi
#End of the UAPI scripts#
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
exit 0