-
-sub gengraph {
- $qossettings{'DEV'} = shift;
- $qossettings{'CLASS'} = shift;
- my $ERROR="";
- if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
- $qossettings{'CLASSPRFX'} = '1';
- } else {
- $qossettings{'CLASSPRFX'} = '2';
- }
- my $color=random_hex_color(6);
-
- RRDs::graph ("/srv/web/ipfire/html/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-packets.png",
- "--start", "-3240", "-aPNG", "-i", "-z",
- "--alt-y-grid", "-w 600", "-h 150", "-r",
- "--color", "SHADEA#EAE9EE",
- "--color", "SHADEB#EAE9EE",
- "--color", "BACK#FFFFFF",
- "-t $qossettings{'CLASS'} ($qossettings{'DEV'})",
- "DEF:pkts=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:pkts:AVERAGE",
- "DEF:dropped=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:dropped:AVERAGE",
- "DEF:overlimits=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:overlimits:AVERAGE",
- "AREA:pkts$color:packets",
- "GPRINT:pkts:LAST:total packets\\:%8.3lf %s packets\\j",
- "LINE3:dropped#FF0000:dropped",
- "GPRINT:dropped:LAST:dropped packets\\:%8.3lf %s packets\\j",
- "LINE3:overlimits#0000FF:overlimits",
- "GPRINT:overlimits:LAST:overlimits\\:%8.3lf %s packets\\j",
- );
- $ERROR = RRDs::error;
- print "$ERROR";
-}
-
-sub overviewgraph {
- $qossettings{'DEV'} = shift;
- if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
- $qossettings{'CLASSPRFX'} = '1';
- } else {
- $qossettings{'CLASSPRFX'} = '2';
- }
- my $ERROR="";
- my $count="1";
- my $color="#000000";
- my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}.png",
- "--start", "-3240", "-aPNG", "-i", "-z",
- "--alt-y-grid", "-w 600", "-h 150", "-r",
- "--color", "SHADEA#EAE9EE",
- "--color", "SHADEB#EAE9EE",
- "--color", "BACK#FFFFFF",
- "-t Auslastung auf ($qossettings{'DEV'})"
- );
- open( FILE, "< $classfile" ) or die "Unable to read $classfile";
- @classes = <FILE>;
- close FILE;
- foreach $classentry (sort @classes)
- {
- @classline = split( /\;/, $classentry );
- if ( $classline[0] eq $qossettings{'DEV'} )
- {
- $color=random_hex_color(6);
- push(@command, "DEF:$classline[1]=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bits:AVERAGE");
-
- if ($count eq "1") {
- push(@command, "AREA:$classline[1]$color:Klasse $classline[1] - $classline[8]\\j");
- } else {
- push(@command, "STACK:$classline[1]$color:Klasse $classline[1] - $classline[8]\\j");
- }
- $count++;
- }
- }
- RRDs::graph (@command);
- $ERROR = RRDs::error;
- print "$ERROR";
-}
-
-sub random_hex_color {
- my $size = shift;
- $size = 6 if $size !~ /^3|6$/;
- my @hex = ( 0 .. 9, 'a' .. 'f' );
- my @color;
- push @color, @hex[rand(@hex)] for 1 .. $size;
- return join('', '#', @color);
-}
\ No newline at end of file