How to check if Zoom is running a meeting?

howie_isaacks
Valued Contributor II

I use a script to update Zoom to what ever version the app owners at my company say we are allowed to install. The script runs a curl command to download the installer for the version we want, then it installs the package. It first checks if Zoom is running. If it's not, it runs the install. If it is, it does not install the newer version of Zoom. The policy runs at check-in scoped to all comptuers with an exclusion for computers already running the version of Zoom we want to install. I have been trying to figure out how to detect if Zoom is running a meeting or not. Somoene may simply have Zoom launched, but not have a meeting running. I know a lot of my users just keep Zoom running. This results in the update taking longer to get done on all of my Macs. Does anyone know what process to look for if Zoom is in a meeting?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Found this when searching around on the web.

[OneLiner] Detect active Zoom meeting : r/PowerShell (reddit.com)

Although the title of the post is for PowerShell, someone posted a MacOS one liner to check. Basically, you need to see how many open ports there are for zoom.

lsof -i 4UDP | grep zoom | awk 'END{print NR}'

When Zoom is connected or hosting a meeting, that number will be higher than 1. I'm getting the number 6 consistently, but I haven't yet tested if just connected to a meeting versus hosting one myself.

If the Zoom app is only running, it shows "1"

Maybe you can use something like this.

 

View solution in original post

8 REPLIES 8

MatthewGC
Contributor

Put a deferral in the process that allows users to select a time frame to complete the task. You may want to allow say 1-3 deferrals then after that force kill zoom and install the update. This is really the only way you’re going to get consistent results and updates. I use Installomator and the swift script to give it a nice UI for users to see what’s happening. Since going this route patching is happening a lot faster and users have some control over when updates happen so they’re not inconvenienced more than necessary. 

howie_isaacks
Valued Contributor II

I like this idea. One of the versions of my update script uses Jamf Helper to let the user know that an update is required. They can click buttons for "install now", or "later". There's a 2 minute countdown. If they don't respond, the script quits Zoom and then runs the install. I think a deferral would be a good idea.

mm2270
Legendary Contributor III

Found this when searching around on the web.

[OneLiner] Detect active Zoom meeting : r/PowerShell (reddit.com)

Although the title of the post is for PowerShell, someone posted a MacOS one liner to check. Basically, you need to see how many open ports there are for zoom.

lsof -i 4UDP | grep zoom | awk 'END{print NR}'

When Zoom is connected or hosting a meeting, that number will be higher than 1. I'm getting the number 6 consistently, but I haven't yet tested if just connected to a meeting versus hosting one myself.

If the Zoom app is only running, it shows "1"

Maybe you can use something like this.

 

howie_isaacks
Valued Contributor II

Thanks for this! I looked this up myself but didn't find what I need. Here's what I came up with that I could add to my script. I was in a meeting when I tested this in CodeRunner.

 

zoomInMeeting=$(lsof -i 4UDP | grep zoom | awk 'END{print NR}')

if [ "$zoomInMeeting" -gt 1 ]; then
	echo "Zoom is in a meeting"
elif [ "$zoomInMeeting" = 1 ]; then
	echo "Zoom is not in a meeting"
fi

 

My result was "Zoom is in a meeting". Right after the meeting ended, I ran this again and the result was "Zoom is not in a meeting". Just to see what the results are without awk simplifying the result from the command, I left that part out. I saw four processes running. 

mm2270
Legendary Contributor III

Looks good. The only thing I might account for is if Zoom is not running at all. You might already be doing that in another part of said script based on your post, but in case it wasn't obvious, if the Zoom app is not running at all, the results come back as "0".

So, 0 if not running, 1 if running but not in a meeting, and some other number > 1 if in a meeting, seems to be how it works.

howie_isaacks
Valued Contributor II

Before this, I had a script that checks if Zoom is running. If it is, the script would do nothing. The policy was setup to run at check-in, ongoing with an exclusion for Macs running the version of Zoom or higher that we are installing. An inventory is ran after the script runs. This will give me the ability to update Zoom whether the app is running or not. All I care about is if Zoom is in a meeting. The script will quit Zoom if it is running. I am about to test the full script. I plan to share it here if it works 😊

howie_isaacks
Valued Contributor II

Here's the final version of the script. I say "final" but I know I will probably go back and add in more "echo" steps. I like having a lot of echos saying what is happening so that if there are problems it's easier to follow the flow of events. At my company, the "app owners" tell me what version of Zoom I can distribute. I get the download URL for that specific version and add it to the parameter in the policy that the script is added to.

#!/bin/zsh

# Parameters for Jamf Pro
downloadURL="$4" # Download URL
zoomVersion="$5" # Zoom Version

# Zoom processes
zoomProc=$(ps axc | grep "zoom.us" | /usr/bin/awk {'print $1'})
meetingCheck=$(lsof -i 4UDP | grep zoom | awk 'END{print NR}')

# Download destination
pathToInstaller="/private/tmp/Zoom_$zoomVersion.pkg"

# Functions
function checkforMeeting (){
	if [ "$meetingCheck" -gt 1 ]; then
	echo "Zoom is in a meeting."
	inMeeting=yes
	elif [ "$meetingCheck" -le 1 ]; then
	echo "Zoom is not in a meeting."
	inMeeting=no
	else echo "Zoom is not in a meeting."
	inMeeting=no
	fi
}

function installZoom (){
	### Quitting Zoom if running
	echo "Quitting Zoom if it's running.'"
	osascript -e 'quit app "zoom.us.app"'
	### Download the Zoom installer.
	echo "Downloading Zoom installer package"
	curl -o $pathToInstaller $downloadURL
	### Run the Zoom installer
	echo "Installing Zoom"
	installer -pkg $pathToInstaller -target /
	### Delete the installer package to free up space
	rm $pathToInstaller
}
#####

# Run the update
if [ -z "$zoomProc" ]; then
	echo "Zoom is not running. Installing the update."
	# Running Install Zoom function
	installZoom 
	# Running check for meeting function
else checkforMeeting
	if [ "$inMeeting" = no ]; then
	installZoom
	elif [ "$inMeeting" = yes ]; then
	echo "Zoom is running with PID "$zoomProc" and is in a meeting. Will try again at next check-in."
	fi
fi

exit 0

howie_isaacks
Valued Contributor II

I found that we can use the same method to detect if Teams is in a meeting.

teamsMeeting=$(lsof -i 4UDP | grep "Teams" | awk 'END{print NR}')'

I tried this out yesterday while I was on some calls and when I was not. I'm about to upgrade Global Protect. Since the install process will briefly disconnect the Mac from the internet, I didn't want the install to run if either Teams or Zoom was in a meeting. I created a script that will first check if these apps are in a meeting. If neither are, it will run the policy to upgrade Global Protect. If either are in a meeting, it keeps that Mac in the queue for the upgrade.