jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [shoutcast/] [diagrams.pl] - Blame information for rev 36

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.16 2004/05/28 17:45:53 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICdiagram;
15use common;
16 
17(my $VERSION = '$Revision: 1.16 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.16 2004/05/28 17:45:53 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
19 
20# read all settings
21#
22my $MODNAME=HotSaNICparser::get_module_name();
23my %CONFIG=HotSaNICparser::get_config("../..");
24my %MODULECONFIG=HotSaNICmod::common::configure();
25 
26my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};
27 
28my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
29if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; }
30 
31my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV);
32my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);
33 
34# handle module-specific stuff
35#
36push @OPTIONS,(
37 "--alt-autoscale-max"); # alternate scaling
38 
39my $LEGEND="listeners";
40 
41# generate diagrams
42#
43foreach my $entry (@{$MODULECONFIG{STREAM}}) {
44 my (undef,undef,undef,$DB_FILE,$name,$file,$description,$bandwidth)=HotSaNICmod::common::get_names($entry);
45 
46 if (%PLOT) { next if ! defined $PLOT{$name}; }
47 
48 $DB_FILE="./rrd/$DB_FILE.rrd";
49 if (defined $bandwidth) { $bandwidth/=8; }
50 
51# if database exists, create images...
52 if ( -e $DB_FILE) {
53 
54 
55 print "creating images for $name (listeners) ...\n";
56 
57 foreach my $range ("1h","6h","1day","1week","1month","1year") {
58 my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
59 
60 my $legends="min avg max";
61 if ($range eq "1h") { $legends="min avg max cur"; }
62 
63 my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "listeners on $name - last $timelong ($DATESTRING)");
64 my @COMMANDS=("DEF:users=$DB_FILE:users:AVERAGE",
65 "DEF:unique=$DB_FILE:unique:AVERAGE",
66 HotSaNICdiagram::insert_data("AREA" ,"users" ,$MODULECONFIG{COLOR_AREA} ,"users ",$legends,$LEGEND,1),
67 "LINE1:users#".$MODULECONFIG{COLOR_LINE}.":",
68 HotSaNICdiagram::insert_data("LINE2","unique",$MODULECONFIG{COLOR_UNIQUE},"unique",$legends,$LEGEND,1));
69 if (defined $bandwidth) {
70 push @COMMANDS,"CDEF:bytes=users,$bandwidth,*",
71 "CDEF:tot=bytes,$fullrange,*",
72 HotSaNICdiagram::insert_data("","0 bytes","","rate ",$legends,"bytes/s",1),
73 "GPRINT:tot:AVERAGE: totals for last $timelong\\:%7.2lf %s bytes";
74 }
75 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
76 
77 my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
78 HotSaNICdiagram::graph(%CONF);
79 }
80 print "\n";
81 }
82 else { print " No database \"$DB_FILE\" found.\n Please check if the daemon is running.\n"; }
83 }
84exit 0;
85 

Powered by WebSVN 2.2.1