Page 1 of 2

M365 monitoring

Posted: Fri Apr 09, 2021 12:26 pm
by hbouma
We are trying to monitor the total number of M365 licenses to alert our team if we have too many users in M365. I have made it though the monitoring wizard, but when I run the checks, I get a 403 Forbidden error.

We are running Nagios XI 5.8.1 on RHEL 7 VM's.


Service check is :
/usr/local/nagios/libexec/check_microsoft_365.php --tenant 'SUPER_SECRET_TENANT_ID' --appid 'SECRET_APP_ID' --secret 'SECRET_VALUD' --mode 'o365activationsbyproduct' --warning ':2180' --critical ':2189' --filter ''

Attached is our permissions (User.Read has been updated to User.Read.All) and the error message.
2021-04-09 13_22_33-Window.png
Is there anything I am missing?

Re: M365 monitoring

Posted: Fri Apr 09, 2021 4:58 pm
by dchurch
Others with similar issues say this is because the permissions are marked as "Delegated" permissions.

Change them to "Application" permissions instead.

Re: M365 monitoring

Posted: Tue Apr 13, 2021 8:48 am
by hbouma
Thank you, that did fix our connection issue.

However, I don't think I have the correct monitoring option selected.

We have been asked to monitor the number of M365 licenses in use and alert when we are close the the critical threshold. When I select the O365 Activations, it only grabs the office instances, not the M365 info.

Re: M365 monitoring

Posted: Tue Apr 13, 2021 2:03 pm
by dchurch
To monitor the number of active users for each product, use this command:

Code: Select all

/usr/local/nagios/libexec/check_microsoft_365.php --tenant 'SUPER_SECRET_TENANT_ID' --appid 'SECRET_APP_ID' --secret 'SECRET_VALUD' --mode 'o365productusage' --warning ':2180' --critical ':2189' --filter ''
You may want to open up /usr/local/nagios/libexec/check_microsoft_365.php in a text editor to around line 465 to get a better idea how to monitor licenses.

Re: M365 monitoring

Posted: Tue Apr 13, 2021 3:27 pm
by hbouma
Thank you.

However, this really doesn't seem to fit what I need it to do.

What I have been asked to do is alert if the total number of M365 Exchangelicenses exceeds 2189. The closest I found was the User Service Usage, however that splits based on active or inactive.
2021-04-13 15_34_49-Greenshot image editor.png

Re: M365 monitoring

Posted: Wed Apr 14, 2021 12:23 pm
by dchurch
The number of licenses "in use" in this case is the number of active licenses.

Re: M365 monitoring

Posted: Mon Apr 19, 2021 3:18 pm
by hbouma
So, this is odd. According to our Exchange team, they have had issues where we are "out" of M365 licenses, but the checks show inactive licenses available.

Is there any check currently available using the M365 Nagios integration to pull in the total number of Exchange licenses (Active and Inactive) to alert when that passes a specific level?

Re: M365 monitoring

Posted: Tue Apr 20, 2021 1:26 pm
by ssax
Does the active count match your license count or does the active+inactive match your license count?

Re: M365 monitoring

Posted: Wed Apr 21, 2021 11:53 am
by hbouma
The active + inactive matches our exchange license count.

Re: M365 monitoring

Posted: Wed Apr 21, 2021 5:53 pm
by ssax
I'll need to talk with development about this but they've already left for the day.

Run this command from the CLI and send the full output (including the performance data that is output after the | character so I can see how the warning/critical affect the output)

Code: Select all

/usr/local/nagios/libexec/check_microsoft_365.php --tenant 'SUPER_SECRET_TENANT_ID' --appid 'SECRET_APP_ID' --secret 'SECRET_VALUD' --mode 'o365productusage' --warning ':2180' --critical ':2189' --filter ''