#!/usr/bin/perl # # File: ispman.sitereport # # Author: Wil Cooley # # Description: This script generates a full site report of # all domains and users. # # $Id$ BEGIN { use FindBin; unshift @INC, ($FindBin::Bin , "$FindBin::Bin/../lib", "$FindBin::Bin/../conf"); } use lib qw(%%installDir%%/lib); use ISPMan; use strict; my $cnt_dom = 0 ; my (%customers, %owners, %status, %types) ; my $ispman=ISPMan->new() || die "Unable to create ISPMan instance"; my $domains=$ispman->getDomains() ; foreach my $key (sort keys %{$domains}) { $cnt_dom++ ; my $entry = $ispman->getEntryAsHashRef($domains->{$key}) || print STDERR "Unable to get entry for $key!" ; $entry->{'ispmanDomainCustomer'} && $customers{$entry->{'ispmanDomainCustomer'}}++ ; $entry->{'ispmanDomainOwner'} && $owners{$entry->{'ispmanDomainOwner'}}++ ; $entry->{'ispmanDomainType'} && $types{$entry->{'ispmanDomainType'}}++ ; $entry->{'ispmanStatus'} && $status{$entry->{'ispmanStatus'}}++ ; print " *** $key ***\n" ; printf "Status: %s\n", $entry->{'ispmanStatus'} ; printf "Type: %s\n", $entry->{'ispmanDomainType'} ; printf "Customer: %s\n", $entry->{'ispmanDomainCustomer'} ; printf "Owner: %s\n", $entry->{'ispmanDomainOwner'} ; printf "Users: %s\n", $ispman->getUserCount($key) ; printf "Vhosts: %s\n", $ispman->getVhostCount($key) ; print "\n" ; } print "\n *** Site Totals ***\n" ; printf "Users: %4d\n", $ispman->getUsersCount() ; printf "Domains: %4d\n", $cnt_dom ; printf "Vhosts: %4d\n", $ispman->getVhostsCount() ; print "\n *** Customer Totals ***\n" ; foreach my $cust (sort keys %customers) { printf "%40s %4d\n", $cust, $customers{$cust}; } print "\n *** Owner Totals ***\n" ; foreach my $owner (sort keys %owners) { printf "%40s %4d\n", $owner, $owners{$owner}; } print "\n *** Status Totals ***\n" ; foreach my $status (sort keys %status) { printf "%40s %4d\n", $status, $status{$status}; } print "\n *** Type Totals ***\n" ; foreach my $type (sort keys %types) { printf "%40s %4d\n", $type, $types{$type}; } #vim:expandtab tabstop=4 shiftwidth=4