Extension Attribute redux...

donmontalvo
Esteemed Contributor III

There were some previous threads regarding an Extension Attribute for checking Microsoft User Data folder sizes that for whatever reason fizzled...I was hoping I could revive.

We want to get database sizes for all users on the target computers.

We want to avoid getting data on any backups which look like this:

"/Users/test1/Documents/Microsoft User Data/Office 2008 Identities/Main Identity [Backed up X-XX-XXXX XX.XX]"

In a twist of previously posted scripts, here's what we are working on:

#!/bin/bash

echo "<result>"

UserList=dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'

for u in $UserList ; do results=du -sh /Users/$u/Documents/Microsoft User Data/Office 2008 Identities/*/Database echo $u $results

done

echo "</result>"

exit 0

The result is a blob of data:

admin 95M /Users/admin/Documents/Microsoft User Data/Office 2008 Identities/Main Identity/Database<BR>test1 95M /Users/test1/Documents/Microsoft User Data/Office 2008 Identities/Main Identity/Database<BR>test2 95M /Users/test2/Documents/Microsoft User Data/Office 2008 Identities/Main Identity/Database<BR>test3 95M /Users/test3/ Documents/Microsoft User Data/Office 2008 Identities/Main Identity/Database<BR>test4 95M /Users/test4/Documents/Microsoft User Data/Office 2008 Identities/Main Identity/ Database<BR>test5 95M /Users/test5/Documents/Microsoft User Data/Office 2008 Identities/Main Identity/Database

Questions:

1. How do we get proper line return instead of <BR> in the result? 2. How do we exclude backup directories from our search (that show [Backed up X-XX-XXXX XX.XX])

Thanks in advance for any suggestions! :)

Don

--
https://donmontalvo.com
4 REPLIES 4

leslie
Contributor II
Contributor II

Don, I would think the <BR> would be desirable so that it lists one database per line. I added 'grep -v "Backed up" to exclude folders you're not interested in. i.e.

do results=du -sh /Users/$u/Documents/Microsoft User Data/Office 2008 Identities/*/Database | grep -v "Backed up"

I might also through an awk in there to only print the user and size. Let me know if you have any questions or other comments.

Thanks,
Leslie N. Helou
Senior Systems Engineer
Bell Techlogix
8888 Keystone Crossing, Suite 1700
Indianapolis, IN 46240
317.704.6408
lhelou at belltechlogix.com

donmontalvo
Esteemed Contributor III

Wow, Leslie, you rock!

I see what you mean about <BR> not being a bad thing, just makes the blob unreadable to mortal techs. However, maybe this would be less of an issue if we use your idea (show only user and size). Any hints for a sed/awk deficient mortal on how to add this...? :D

Thanks,
Don

--
https://donmontalvo.com

stevewood
Honored Contributor II
Honored Contributor II

awk '{ print $1,$2 }'
On Thu, Mar 31, 2011 at 1:00 PM, Don Montalvo <donmontalvo at gmail.com> wrote:

That should do the trick.

Steve Wood
Director of IT
swood at integer.com

The Integer Group | 1999 Bryan St. | Ste. 1700 | Dallas, TX 75201
T 214.758.6813 | F 214.758.6901 | C 940.312.2475

sean
Valued Contributor

Don,

I've put in a feature request for the stye sheet to be updated to respect <BR> on the main inventory page. You'll notice it is handled correctly when you look at the Extensions Attribute section within the details of a machine. Maybe you could put in the same request.

You could probably self hack the current style sheet on the server, but this would probably get overridden with updates.

When you say you are trying to avoid the Backed up data, do you mean you don't want it in the final report or you don't want du to even try and work it's way through the folders

If it's the former, then

du -sh /Users/$u/Documents/Microsoft User Data/Office 2008 Identities/*/Database | grep -v ']'

would do it.

If it is the later and you want your script to be more efficient, then there is a mask option in du you could maybe use, but I don't use Office here, so I don't know if the format in the [Backed up] section is always the same:

du -sh -I "Main Identity [Backed up *--* *.]" /Users/$u/Documents/Microsoft User Data/Office 2008 Identities/*

If there are other files in the directories you are looking in and you only want the Database, then you could change this to:

du -ah -I "Main Identity [Backed up *--* *.]" /Users/$u/Documents/Microsoft User Data/Office 2008 Identities/* | grep Database

but again, if there are lots of other files in here that you need to avoid the du command bothering with...!

Otherwise, you could ls the directories into a tmp file or array and grep out the lines with [,] or Backed up, then while read line or array, du the resulting directories with your original command

Sean