Difference between revisions of "Accounts created Report"
(New page: Script was written do Report on accounts created in a certain time period. #!/bin/bash # Zimbra reporting script for Accounts_created_in_Days # Fred Strauss and Deon Lottering # consulti...) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Archive}}{{Unsupported}} | ||
+ | |||
Script was written do Report on accounts created in a certain time period. | Script was written do Report on accounts created in a certain time period. | ||
− | #!/bin/bash | + | #!/bin/bash |
− | + | # Zimbra reporting script for Accounts_created_in_Days | |
− | # Zimbra reporting script for Accounts_created_in_Days | + | # Fred Strauss and Deon Lottering |
− | # Fred Strauss and Deon Lottering | + | # How far back to search for, in ldapsearch time format |
− | # | + | displaydate=`date -d "30 days ago" +%Y%m%d`"000000Z" |
− | + | # Get ldap password from zimbra config | |
− | + | ldappass=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_password` | |
+ | # Get ldap dn from zimbra config | ||
+ | ldapdn=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_userdn` | ||
+ | # Get ldap URL from zimbra config | ||
+ | ldapurl=`/opt/zimbra/bin/zmlocalconfig -s -m nokey ldap_url` | ||
+ | # ldapsearch and arguments | ||
+ | ldapsearch='/opt/zimbra/bin/ldapsearch' | ||
+ | ldapargs="-LLL -x -H $ldapurl -w $ldappass -D $ldapdn " | ||
+ | # We're only interested in the e-mail address and creation time | ||
+ | ldapattrs="zimbraMailDeliveryAddress createTimestamp" | ||
+ | # ldapsearch for all zimbra accounts that are active, created on or after $displaydate | ||
+ | $ldapsearch $ldapargs -b '' "(&(objectclass=zimbraAccount)(!(objectclass=zimbraCalendarResource))(zimbraAccountStatus=Active)(createTimestamp>=$displaydate))" $ldapattrs \ | ||
+ | | awk ' | ||
+ | # Set Field Seperator to : and initialise our variables | ||
+ | BEGIN {FS=": ";email=0;timestamp=0} | ||
+ | # If line contains the email address, store it | ||
+ | /zimbraMailDeliveryAddress/ {email=$2} | ||
+ | # If line contains the create time, store it in a more readable format | ||
+ | /createTimestamp/ {timestamp=substr($2,0,4) "-" substr($2,5,2) "-" substr($2,7,2)} | ||
+ | # If the line contains dn: we know we are starting with a new entry, print our | ||
+ | # previous data and reset variables | ||
+ | /dn:/ {if (email) print email "," timestamp; email=0; timestamp=0} | ||
+ | # If we reach the end of input, print the last entry | ||
+ | END {if (email) print email "," timestamp}' > /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv | ||
− | + | mutt -s "Accounts created in last 30 Days from `date +%F`" -a /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv admin@domain.com < /usr/local/bin/accounts-30days | |
− | |||
− | + | The file /usr/local/bin/accounts-30days will insert text into the body of your email | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {{Article Footer|unknown|8/19/2009}} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | / | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | [[Category:Administration]] | |
+ | [[Category:Customizing ZCS]] |
Latest revision as of 13:19, 24 March 2015
- This is archive documentation, which means it is not supported or valid for recent versions of Zimbra Collaboration.
- This article is a Community contribution and may include unsupported customizations.
Script was written do Report on accounts created in a certain time period.
#!/bin/bash # Zimbra reporting script for Accounts_created_in_Days # Fred Strauss and Deon Lottering # How far back to search for, in ldapsearch time format displaydate=`date -d "30 days ago" +%Y%m%d`"000000Z" # Get ldap password from zimbra config ldappass=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_password` # Get ldap dn from zimbra config ldapdn=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_userdn` # Get ldap URL from zimbra config ldapurl=`/opt/zimbra/bin/zmlocalconfig -s -m nokey ldap_url` # ldapsearch and arguments ldapsearch='/opt/zimbra/bin/ldapsearch' ldapargs="-LLL -x -H $ldapurl -w $ldappass -D $ldapdn " # We're only interested in the e-mail address and creation time ldapattrs="zimbraMailDeliveryAddress createTimestamp" # ldapsearch for all zimbra accounts that are active, created on or after $displaydate $ldapsearch $ldapargs -b "(&(objectclass=zimbraAccount)(!(objectclass=zimbraCalendarResource))(zimbraAccountStatus=Active)(createTimestamp>=$displaydate))" $ldapattrs \ | awk ' # Set Field Seperator to : and initialise our variables BEGIN {FS=": ";email=0;timestamp=0} # If line contains the email address, store it /zimbraMailDeliveryAddress/ {email=$2} # If line contains the create time, store it in a more readable format /createTimestamp/ {timestamp=substr($2,0,4) "-" substr($2,5,2) "-" substr($2,7,2)} # If the line contains dn: we know we are starting with a new entry, print our # previous data and reset variables /dn:/ {if (email) print email "," timestamp; email=0; timestamp=0} # If we reach the end of input, print the last entry END {if (email) print email "," timestamp}' > /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv
mutt -s "Accounts created in last 30 Days from `date +%F`" -a /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv admin@domain.com < /usr/local/bin/accounts-30days
The file /usr/local/bin/accounts-30days will insert text into the body of your email