Category expression is an expression of host groups (see above)
with + (inclusion) and - (exclusion) operations (each inclusive
group is an exclusion from all preceeding exclusive groups, and each exclusive
group is an exclusion from all preceeding inclusive groups).
Accounting is done for hosts belonging to any inclusive group and not
belonging to any following exclusive group. If it's hard to understand, look
at the following example of category expression:
"?mydomain.com-sub1.mydomain.com+*sub2.sub1.mydomain.com"
It covers all hosts that belong to domain sub2.sub1.mydomain.com and hosts
that belong to domain mydomain.com but not belong to domain sub1.mydomain.com.
('?' and '*' symbols are used according to host group definition syntax).
A table's category expression defines hosts for which the traffic is
counted. Column's category expression defines the "opposite end" hosts
and so limits the category of the counted traffic.
If the example above is used as a table's category expression, then
traffic will be counted separately for each host in domain sub2.sub1.mydomain.com
(because it is marked with '*'), and in summary for each of subdomains of
mydomain.com (because it's marked with '?') - expect sub1.mydomain.com, of course.
Although this example includes only host groups specified as domains, you
can use host groups of any type in the same category expression.
Except host groups you can use two special words in category expressions
- total and each. They imply all possible hosts, but when used in
a table's category expression, total provides accounting for
all hosts in total, while each makes traffic to be counted for each host
separately.
In a few words, in general you can define a category expression like so:
"total-Backbone+*Foreign Tunnels-192.168.1.0/22+192.168.1.0/21+*backbone.mydomain.com"
Remember that whitespaces are not allowed between signs and operands, but
they are allowed in list names.
If this still seems complicated, use only single-operand
category expressions, like
"*Clients"
or
"?mydomain.com"
or
"*192.168.1.0/21"
or so forth. This might limit flexibility, but enhance simplicity. After all,
you can achieve the same results either using complex category expressions
or using complex group lists and category expressions consisting of only
a single host group (a list name prefixed with '*').
Please also note the following. In the database hosts are stored either as
ip addresses or as domain names, depending on traffic type and resolution
possibility (for ip traffic hosts are stored as ip addresses only, for other
traffic types they are stored in the form they were obtained from applications).
So you should care when to specify hosts groups as ip addresses or subnets
and when as domains, because although ip addresses obtained from a database
are then resolved into names (if they belong to @local_nets of course)
for comparison against a category expression, they are first selected from a database
according to that category expression (this behavior is used since v1.2;
in earlier versions AcctLog iterated through all of the database records
which might consume a huge amount of time for large databases, but let to use
domain-only based category expressions even for hosts stored in database
as ip-addresses).
This means that if you wish to group your hosts in domains in a report table
for ip traffic (i.e., summarize traffic by domains, or by list names
of group lists that contain only host groups specified as domains, not
ip subnets), then you should ensure that inclusive host groups of your
table's category expression specify both domains and ip addresses/subnets
for the hosts you intend to count traffic for (of course, in this case the
groups specified as ip addresses/subnets will also be included into the report
table, so it is advised not to prefix them with '*' - then they will
occupy only a few table rows).
This is not the case for exclusive host groups - they may specify hosts
as domains for ip traffic (if those hosts belong to @local_nets, else
they won't be resolved), because exclusive host groups are used to match
hosts already selected from a database according to inclusive host groups.