There is a fuzzy area between the count of managed machines in a Notification Server and the count of active machines.
First when is a managed machine considered as active or inactive? This can be defined and interpreted in many different ways based on the nature of one's business, whether it is fast changing or strictly controlled etc.
The SQL query below is not going to answer this question, but can serve as a starting point (you could add event request on the filter such as last basic inventory received or last client policy request etc):
select count (*), ((DATENAME(Year,DataLastChangedDate)) + ' ' + (DATENAME(Month,DataLastChangedDate))) as 'Month'
select ResourceGuid, Max(DataLastChangedDate) as 'DataLastChangedDate'
from ItemResource ir
join ResourceUpdateSummary rus
on ir.guid = rus.resourceguid
where IsManaged = 1
group by resourceguid
where datalastchangeddate > DATEADD(Month,- 3,GETDATE...