Collecting stats of all users

From Zarafa wiki

Jump to: navigation, search

The following bash script is a wrapper script around zarafa-stats and outputs user stats per user in csv format to stdout.

The following stats are collected for every user:

  • Company
  • Username
  • Full Name
  • Email Address
  • Warning Limit in kBytes
  • Soft Quota in kBytes
  • Hard Quota in kBytes
  • Store Size in kBytes

The csv can be imported into a spreadsheet program of any choice. From there it is able to sort on different fields.


The bash script:


#!/bin/bash
#

WARNLIMIT=0x67210003
SOFTQUOTA=0x67220003
HARDQUOTA=0x67230003
STORESIZE=0x0E080014
COMPANY=0x6748001E
USERNAME=0x6701001E
FULLNAME=0x3001001E
EMAIL=0x39FE001E

echo -n \"Company\",
echo -n \"Username\",
echo -n \"Full Name\",
echo -n \"Email Address\",
echo -n \"Warn Limit in kBytes\",
echo -n \"Soft Quota in kBytes\",
echo -n \"Hard Quota in kBytes\",
echo -n \"Store Size in kBytes\"
echo ""


zarafa-stats --users | while read LINE; do
  if [ ! -z "$LINE" ]; then
    HEXVAL=${LINE:0:10}
    VAL=${LINE:12}
    case $HEXVAL in
      $WARNLIMIT)
  	U_WARNLIMIT=$VAL
      ;;
      $SOFTQUOTA)
  	U_SOFTQUOTA=$VAL
      ;;
      $HARDQUOTA)
        U_HARDQUOTA=$VAL
      ;;
      $STORESIZE)
        U_STORESIZE=$(($VAL/1024))
      ;;
      $COMPANY)
        U_COMPANY=$VAL
      ;;
      $USERNAME)
        U_USERNAME=$VAL
      ;;
      $FULLNAME)
        U_FULLNAME=$VAL
      ;;
      $EMAIL)
        U_EMAIL=$VAL
      ;;
    esac
  else
    if [ ! -z "$U_USERNAME" ] && [ "$U_USERNAME" != "SYSTEM" ]; then
      echo -n \"$U_COMPANY\",
      echo -n \"$U_USERNAME\",
      echo -n \"$U_FULLNAME\",
      echo -n \"$U_EMAIL\",
      echo -n \"$U_WARNLIMIT\",
      echo -n \"$U_SOFTQUOTA\",
      echo -n \"$U_HARDQUOTA\",
      echo -n \"$U_STORESIZE\"
      echo ""
      U_COMPANY=""
      U_USERNAME=""
      U_FULLNAME=""
      U_EMAIL=""
      U_WARNLIMIT=""
      U_SOFTQUOTA=""
      U_HARDQUOTA=""
      U_STORESIZE=""
    fi
  fi
done
Personal tools