jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [shoutcast/] [diagrams.pl] - Rev 14 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.16 2004/05/28 17:45:53 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "../../lib";
use lib "./platform";
use HotSaNICparser;
use HotSaNICdiagram;
use common;

(my $VERSION = '$Revision: 1.16 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.16 2004/05/28 17:45:53 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

# read all settings
#
my $MODNAME=HotSaNICparser::get_module_name();
my %CONFIG=HotSaNICparser::get_config("../..");
my %MODULECONFIG=HotSaNICmod::common::configure();

my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};

my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; }

my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV);
my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);

# handle module-specific stuff
#
push @OPTIONS,(
  "--alt-autoscale-max");   # alternate scaling

my $LEGEND="listeners";

# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{STREAM}}) {
  my (undef,undef,undef,$DB_FILE,$name,$file,$description,$bandwidth)=HotSaNICmod::common::get_names($entry);

  if (%PLOT) { next if ! defined $PLOT{$name}; }

  $DB_FILE="./rrd/$DB_FILE.rrd";
  if (defined $bandwidth) { $bandwidth/=8; }

# if database exists, create images...
  if ( -e $DB_FILE) {


    print "creating images for $name (listeners) ...\n";

    foreach my $range ("1h","6h","1day","1week","1month","1year") {
      my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);

      my $legends="min avg max";
      if ($range eq "1h") { $legends="min avg max cur"; }

      my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "listeners on $name - last $timelong ($DATESTRING)");
      my @COMMANDS=("DEF:users=$DB_FILE:users:AVERAGE",
        "DEF:unique=$DB_FILE:unique:AVERAGE",
        HotSaNICdiagram::insert_data("AREA" ,"users" ,$MODULECONFIG{COLOR_AREA}  ,"users ",$legends,$LEGEND,1),
        "LINE1:users#".$MODULECONFIG{COLOR_LINE}.":",
        HotSaNICdiagram::insert_data("LINE2","unique",$MODULECONFIG{COLOR_UNIQUE},"unique",$legends,$LEGEND,1));
      if (defined $bandwidth) {
        push @COMMANDS,"CDEF:bytes=users,$bandwidth,*",
          "CDEF:tot=bytes,$fullrange,*",
          HotSaNICdiagram::insert_data("","0 bytes","","rate  ",$legends,"bytes/s",1),
          "GPRINT:tot:AVERAGE:  totals for last $timelong\\:%7.2lf %s bytes";
        }
      push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
            
      my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
      HotSaNICdiagram::graph(%CONF);
      }
    print "\n";
    }
  else { print "  No database \"$DB_FILE\" found.\n  Please check if the daemon is running.\n"; }
  }
exit 0;


Powered by WebSVN 2.2.1