Find Total Attachment Size

Run a script to find the total size of all the attachments in your ServiceNow database.  With some new ServiceNow contracts requiring the ServiceNow database to be under 4TB, this is something you may need to inspect before your contract renewal.

Total Attachments Size Script

1. Elevate your privileges to security admin 
2. In scripts - background run this script

function findAttachmentsSize(){ 
    var size_compressed = 0;
    var size_bytes = 0;
    grAttachment = new GlideRecord('sys_attachment'); 
    gs.print('Total Number of Attachments: ' + grAttachment.getRowCount()); 
    while ({ 
        size_compressed += grAttachment.size_compressed;
        size_bytes += grAttachment.size_bytes;
    gs.print('Total Size Compressed (bytes): ' + size_compressed);
    gs.print('Total Size Bytes (bytes): ' + size_bytes);

If you haven't setup the max attachment size, you may want to do so as well.

ServiceNow Wiki - Set Max Attachment Size

You may be surprised at some of the file sizes of attachments that users have uploaded!