Collecting stats of all users

From Zarafa wiki

(Difference between revisions)
Jump to: navigation, search
m
(Corrected quota IDs (warn limit was missing, soft+hard quota had IDs "off by one") and units)
 
Line 6: Line 6:
* Full Name
* Full Name
* Email Address
* Email Address
-
* Soft Quota in KBytes
+
* Warning Limit in kBytes
-
* Hard Quota in KBytes
+
* Soft Quota in kBytes
-
* Store Size in Bytes
+
* 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 csv can be imported into  a spreadsheet program of any choice. From there it is able to sort on different fields.
Line 19: Line 20:
#
#
-
SOFTQUOTA=0x67210003
+
WARNLIMIT=0x67210003
-
HARDQUOTA=0x67220003
+
SOFTQUOTA=0x67220003
 +
HARDQUOTA=0x67230003
STORESIZE=0x0E080014
STORESIZE=0x0E080014
COMPANY=0x6748001E
COMPANY=0x6748001E
Line 31: Line 33:
echo -n \"Full Name\",
echo -n \"Full Name\",
echo -n \"Email Address\",
echo -n \"Email Address\",
-
echo -n \"Soft Quota in KBytes\",
+
echo -n \"Warn Limit in kBytes\",
-
echo -n \"Hard Quota in KBytes\",
+
echo -n \"Soft Quota in kBytes\",
-
echo -n \"Store Size in KBytes\"
+
echo -n \"Hard Quota in kBytes\",
 +
echo -n \"Store Size in kBytes\"
echo ""
echo ""
Line 42: Line 45:
     VAL=${LINE:12}
     VAL=${LINE:12}
     case $HEXVAL in
     case $HEXVAL in
 +
      $WARNLIMIT)
 +
  U_WARNLIMIT=$VAL
 +
      ;;
       $SOFTQUOTA)
       $SOFTQUOTA)
   U_SOFTQUOTA=$VAL
   U_SOFTQUOTA=$VAL
Line 70: Line 76:
       echo -n \"$U_FULLNAME\",
       echo -n \"$U_FULLNAME\",
       echo -n \"$U_EMAIL\",
       echo -n \"$U_EMAIL\",
 +
      echo -n \"$U_WARNLIMIT\",
       echo -n \"$U_SOFTQUOTA\",
       echo -n \"$U_SOFTQUOTA\",
       echo -n \"$U_HARDQUOTA\",
       echo -n \"$U_HARDQUOTA\",
Line 78: Line 85:
       U_FULLNAME=""
       U_FULLNAME=""
       U_EMAIL=""
       U_EMAIL=""
 +
      U_WARNLIMIT=""
       U_SOFTQUOTA=""
       U_SOFTQUOTA=""
       U_HARDQUOTA=""
       U_HARDQUOTA=""

Latest revision as of 13:05, 18 November 2011

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