Useful SQL queries for Cisco Unity

Have you ever wonder how to determine how many voicemails an user may have? or maybe how much space those voicemails are consuming? Well, fear not! This is exactly what we are going to discuss in this short post.

Using the CLI of Unity it is pretty simple to obtain those details if we know the alias of a particular user, the same results can be obtained for ALL users and for that please refer to Cisco documentation.

### How many voicemails an user has? ###

run cuc dbquery unitymbxdb1 select count (*) as Messages from vw_message, unitydirdb:vw_mailbox, unitydirdb:vw_user where mailboxobjectid in (select mailboxid from vw_mailbox where unitydirdb:vw_user.objectid = unitydirdb: vw_mailbox.userobjectid and alias='42lb')

### How many deleted voicemails an user has? ###

run cuc dbquery unitymbxdb1 select alias as UserID, count (*) as deletedmessages from vw_message, unitydirdb:vw_mailbox, unitydirdb:vw_user where deleted='1' and mailboxobjectid in (select mailboxid from vw_mailbox where unitydirdb:vw_user.objectid = unitydirdb:vw_mailbox.userobjectid) and alias like '42lb' group by alias order by deletedmessages

### How much space are those voicemails using? ###

run cuc dbquery unitydirdb select alias as UserID,bytesize,send,receive, warning from vw_user,unitymbxdb1:vw_mailbox where vw_user.objectid in (select userobjectid from vw_usermailboxmap where vw_usermailboxmap.mailboxid=unitymbxdb1:vw_mailbox.mailboxobjectid and alias like '42lb') order by bytesize desc

Very simple but immensely helpful.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top