2 # Copyright (C) 2002 Stanislav Sinyagin
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 # $Id: configinfo.in,v 1.1 2010-12-27 00:04:03 ivan Exp $
19 # Stanislav Sinyagin <ssinyagin@yahoo.com>
21 BEGIN { require '@torrus_config_pl@'; }
26 use Torrus::ConfigTree;
27 use Torrus::TimeStamp;
28 use Torrus::SiteConfig;
31 exit(1) if not Torrus::SiteConfig::verify();
33 &Torrus::DB::setSafeSignalHandlers();
35 Torrus::TimeStamp::init();
37 my @tree_names = Torrus::SiteConfig::listTreeNames();
40 printf("Torrus version %s\n", '@VERSION@');
41 printf("%s\n", DB_VERSION_STRING);
42 printf("BerkeleyDB.pm version %s\n", $BerkeleyDB::VERSION);
45 printf("Datasource trees: %d\n", scalar( @tree_names ) );
46 printf("Tree names: %s\n", join(', ', @tree_names) );
49 foreach my $tree ( @tree_names )
51 &Torrus::DB::checkInterrupted();
53 printf("Tree: %s\n", $tree );
55 my $config_tree = new Torrus::ConfigTree( -TreeName => $tree );
56 if( not defined($config_tree) )
58 print("Configuration is not ready\n");
63 foreach my $name ( 'leaves', 'collectorLeaves', 'monitorLeaves',
64 'holtwintersLeaves', 'subtrees',
65 'maxSubtreePath', 'maxSubtreeSize', 'views',
66 'monitors', 'actions', 'compiled' )
71 collectStats( $config_tree, $stats );
72 collectOtherStats( $config_tree, $stats );
74 printf("Leaves: %d\n", $stats->{'leaves'} );
75 printf("Collector leaves: %d\n", $stats->{'collectorLeaves'} );
76 printf("Monitor leaves: %d\n", $stats->{'monitorLeaves'} );
77 printf("Holt-Winters leaves: %d\n", $stats->{'holtwintersLeaves'} );
78 printf("Subtrees: %d\n", $stats->{'subtrees'} );
79 printf("Largest subtree: %s\n", $stats->{'maxSubtreePath'} );
80 printf("Largest subtree size: %d\n", $stats->{'maxSubtreeSize'} );
81 printf("Views: %d\n", $stats->{'views'} );
82 printf("Monitors: %d\n", $stats->{'monitors'} );
83 printf("Actions: %d\n", $stats->{'actions'} );
84 printf("Last compiled: %s\n",
85 scalar(localtime($stats->{'compiled'})));
93 my $config_tree = shift;
97 &Torrus::DB::checkInterrupted();
99 if( not defined( $token ) )
101 $token = $config_tree->token('/');
104 my @children = $config_tree->getChildren( $token );
106 my $nChildren = scalar( @children );
107 if( not defined( $stats->{'maxSubtreeSize'} ) or
108 $stats->{'maxSubtreeSize'} < $nChildren )
110 $stats->{'maxSubtreeSize'} = $nChildren;
111 $stats->{'maxSubtreePath'} = $config_tree->path( $token );
114 foreach my $ctoken ( @children )
116 if( $config_tree->isSubtree( $ctoken ) )
118 $stats->{'subtrees'}++;
119 collectStats( $config_tree, $stats, $ctoken );
121 elsif( $config_tree->isLeaf( $ctoken ) )
123 $stats->{'leaves'}++;
124 if( $config_tree->getNodeParam( $ctoken, 'ds-type' )
127 $stats->{'collectorLeaves'}++;
129 if( defined( $config_tree->getNodeParam( $ctoken, 'monitor' ) ) )
131 $stats->{'monitorLeaves'}++;
133 my $val = $config_tree->getNodeParam( $ctoken, 'rrd-hwpredict' );
134 if( defined( $val ) and $val eq 'enabled' )
136 $stats->{'holtwintersLeaves'}++;
143 sub collectOtherStats
145 my $config_tree = shift;
148 my $n = scalar( $config_tree->getViewNames() );
149 $stats->{'views'} = $n if defined( $n );
151 $n = scalar( $config_tree->getMonitorNames() );
152 $stats->{'monitors'} = $n if defined( $n );
154 $n = scalar( $config_tree->getActionNames() );
155 $stats->{'actions'} = $n if defined( $n );
157 $n = $config_tree->getTimestamp();
158 $stats->{'compiled'} = $n if defined( $n );
164 # indent-tabs-mode: nil
165 # perl-indent-level: 4