mirror of https://github.com/mikaku/Monitorix.git
3.0: added support for 'fs' graph
This commit is contained in:
parent
d9a609ff32
commit
ae9220081b
|
@ -20,7 +20,7 @@
|
|||
|
||||
package fs;
|
||||
|
||||
#use strict;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Monitorix;
|
||||
use RRDs;
|
||||
|
@ -119,13 +119,13 @@ sub fs_init {
|
|||
# This tries to find out the physical device name of each fs.
|
||||
foreach my $k (sort keys %{$fs->{list}}) {
|
||||
my @fsl = split(',', $fs->{list}->{$k});
|
||||
foreach my $f (@$fsl) {
|
||||
foreach my $f (@fsl) {
|
||||
my $d = $fs->{devmap}->{$fs} if $fs->{devmap}->{$fs};
|
||||
next unless !$d;
|
||||
|
||||
if($f ne "swap") {
|
||||
eval {
|
||||
alarm $TIMEOUT;
|
||||
alarm $config->{timeout};
|
||||
open(IN, "df -P $f |");
|
||||
while(<IN>) {
|
||||
if(/ $f$/) {
|
||||
|
@ -139,7 +139,7 @@ sub fs_init {
|
|||
};
|
||||
}
|
||||
|
||||
if($os eq "Linux" && $kernel_branch > 2.4) {
|
||||
if($config->{os} eq "Linux" && $config->{kernel} > 2.4) {
|
||||
my $lvm;
|
||||
my $lvm_disk;
|
||||
my $is_md;
|
||||
|
@ -153,8 +153,7 @@ sub fs_init {
|
|||
# check for device names using symbolic links
|
||||
# e.g. /dev/disk/by-uuid/db312d12-0da6-44e5-a354-4c82118f4b66
|
||||
if(-l $d) {
|
||||
$link = readlink($d);
|
||||
$d = abs_path(dirname($d) . "/" . $link);
|
||||
$d = abs_path(dirname($d) . "/" . readlink($d));
|
||||
chomp($d);
|
||||
}
|
||||
|
||||
|
@ -167,11 +166,11 @@ sub fs_init {
|
|||
if($found = is_in_diskstats($d, $major, $minor)) {
|
||||
$d = $found;
|
||||
$fs->{devmap}->{$f} = $d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") unless !$opt_d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") if $debug;
|
||||
next;
|
||||
}
|
||||
|
||||
logger("$myself: Unable to find major/minor in /proc/diskstats.") unless !$opt_d;
|
||||
logger("$myself: Unable to find major/minor in /proc/diskstats.") if $debug;
|
||||
|
||||
# check if device is using EVMS <http://evms.sourceforge.net/>
|
||||
if($d =~ m/\/dev\/evms\//) {
|
||||
|
@ -179,7 +178,7 @@ sub fs_init {
|
|||
if($found = is_in_diskstats($d)) {
|
||||
$d = $found;
|
||||
$fs->{devmap}->{$f} = $d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") unless !$opt_d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") if $debug;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +187,7 @@ sub fs_init {
|
|||
$d =~ s/^.*mapper\///; # remove the mapper/ prefix
|
||||
|
||||
# check if the device is under a crypt LUKS (encrypted fs)
|
||||
my $dev;
|
||||
if($dev = is_luks($d)) {
|
||||
$d = $dev;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ sub fs_init {
|
|||
if($found = is_in_diskstats($d)) {
|
||||
$d = $found;
|
||||
$fs->{devmap}->{$f} = $d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") unless !$opt_d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") if $debug;
|
||||
next;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ sub fs_init {
|
|||
}
|
||||
}
|
||||
}
|
||||
} elsif($os eq "FreeBSD" || $os eq "OpenBSD" || $os eq "NetBSD") {
|
||||
} elsif($config->{os} eq "FreeBSD" || $config->{os} eq "OpenBSD" || $config->{os} eq "NetBSD") {
|
||||
# remove the /dev/ prefix
|
||||
if ($d =~ s/^.*dev\///) {
|
||||
# not ZFS; get the device name, eg ada0; md0; ad10
|
||||
|
@ -239,7 +239,7 @@ sub fs_init {
|
|||
}
|
||||
}
|
||||
$fs->{devmap}->{$f} = $d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") unless !$opt_d;
|
||||
logger("$myself: Detected physical device name for $f in '$d'.") if $debug;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,8 +300,8 @@ sub fs_update {
|
|||
my $used = 0;
|
||||
my $free = 0;
|
||||
|
||||
$f = trim($fsl[$n]); FIX ME !!!!
|
||||
if($f eq "swap") {
|
||||
my $f = trim($fsl[$n]) || "";
|
||||
if($f && $f eq "swap") {
|
||||
if($config->{os} eq "Linux") {
|
||||
open(IN, "free |");
|
||||
while(<IN>) {
|
||||
|
@ -320,7 +320,7 @@ sub fs_update {
|
|||
}
|
||||
}
|
||||
close(IN);
|
||||
} elsif($config->{os} eq "OpenBSD" || $os eq "NetBSD") {
|
||||
} elsif($config->{os} eq "OpenBSD" || $config->{os} eq "NetBSD") {
|
||||
open(IN, "pstat -sk |");
|
||||
while(<IN>) {
|
||||
if(/^swap_device\s+\d+\s+(\d+)\s+(\d+) /) {
|
||||
|
@ -353,7 +353,7 @@ sub fs_update {
|
|||
|
||||
# FS alert
|
||||
if($f eq "/" && lc($config->{enable_alerts}) eq "y") {
|
||||
if(!$config->{alert_rootfs_threshold} || $pcnt < $config->{alert_rootfs_threshold}) {
|
||||
if(!$config->{alert_rootfs_threshold} || $use < $config->{alert_rootfs_threshold}) {
|
||||
$config->{fs_hist}->{rootalert} = 0;
|
||||
} else {
|
||||
if(!$config->{fs_hist}->{rootalert}) {
|
||||
|
@ -361,7 +361,7 @@ sub fs_update {
|
|||
}
|
||||
if($config->{fs_hist}->{rootalert} > 0 && (time - $config->{fs_hist}->{rootalert}) > $config->{alert_rootfs_timeintvl}) {
|
||||
if(-x $config->{alert_rootfs_script}) {
|
||||
system($config->{alert_rootfs_script} . " " . $config->{alert_rootfs_timeintvl} . " " . $config->{alert_rootfs_threshold} . " " . $pcnt);
|
||||
system($config->{alert_rootfs_script} . " " . $config->{alert_rootfs_timeintvl} . " " . $config->{alert_rootfs_threshold} . " " . $use);
|
||||
}
|
||||
$config->{fs_hist}->{rootalert} = time;
|
||||
}
|
||||
|
@ -452,3 +452,549 @@ sub fs_update {
|
|||
my $err = RRDs::error;
|
||||
logger("ERROR: while updating $rrd: $err") if $err;
|
||||
}
|
||||
|
||||
sub fs_cgi {
|
||||
my ($package, $config, $cgi) = @_;
|
||||
|
||||
my $fs = $config->{fs};
|
||||
my @rigid = split(',', $fs->{rigid});
|
||||
my @limit = split(',', $fs->{limit});
|
||||
my $tf = $cgi->{tf};
|
||||
my $colors = $cgi->{colors};
|
||||
my $graph = $cgi->{graph};
|
||||
my $silent = $cgi->{silent};
|
||||
|
||||
my $u = "";
|
||||
my $width;
|
||||
my $height;
|
||||
my $graph_title;
|
||||
my $vlabel;
|
||||
my @PNG;
|
||||
my @PNGz;
|
||||
my @tmp;
|
||||
my @tmpz;
|
||||
my @riglim;
|
||||
my $n;
|
||||
my $n2;
|
||||
my $e;
|
||||
my $e2;
|
||||
my $str;
|
||||
my $err;
|
||||
my @LC = (
|
||||
"#FFA500",
|
||||
"#44EEEE",
|
||||
"#44EE44",
|
||||
"#4444EE",
|
||||
"#448844",
|
||||
"#5F04B4",
|
||||
"#EE44EE",
|
||||
"#EEEE44",
|
||||
);
|
||||
|
||||
my $rrd = $config->{base_lib} . $package . ".rrd";
|
||||
my $title = $config->{graph_title}->{$package};
|
||||
my $PNG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir};
|
||||
|
||||
$title = !$silent ? $title : "";
|
||||
|
||||
|
||||
# text mode
|
||||
#
|
||||
if(lc($config->{iface_mode}) eq "text") {
|
||||
if($title) {
|
||||
main::graph_header($title, 2);
|
||||
print(" <tr>\n");
|
||||
print(" <td bgcolor='$colors->{title_bg_color}'>\n");
|
||||
}
|
||||
my (undef, undef, undef, $data) = RRDs::fetch("$rrd",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"AVERAGE",
|
||||
"-r $tf->{res}");
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while fetching $rrd: $err\n") if $err;
|
||||
my $line1;
|
||||
my $line2;
|
||||
my $line3;
|
||||
print(" <pre style='font-size: 12px; color: $colors->{fg_color}';>\n");
|
||||
foreach my $k (sort keys %{$fs->{list}}) {
|
||||
my @f = split(',', $fs->{list}->{$k});
|
||||
for($n = 0; $n < scalar(@f); $n++) {
|
||||
$str = sprintf("%23s", $fs->{desc}->{$f[$n]} || trim($f[$n]));
|
||||
$line1 .= $str;
|
||||
$str = sprintf(" Use I/O Time ");
|
||||
$line2 .= $str;
|
||||
$line3 .= "-----------------------";
|
||||
}
|
||||
}
|
||||
print(" $line1\n");
|
||||
print("Time $line2\n");
|
||||
print("-----$line3\n");
|
||||
my $line;
|
||||
my @row;
|
||||
my $time;
|
||||
my $from;
|
||||
my $to;
|
||||
for($n = 0, $time = $tf->{tb}; $n < ($tf->{tb} * $tf->{ts}); $n++) {
|
||||
$line = @$data[$n];
|
||||
$time = $time - (1 / $tf->{ts});
|
||||
my ($root, $swap) = @$line;
|
||||
printf(" %2d$tf->{tc} ", $time);
|
||||
$e = 0;
|
||||
foreach my $k (sort keys %{$fs->{list}}) {
|
||||
my @f = split(',', $fs->{list}->{$k});
|
||||
for($n2 = 0; $n2 < scalar(@f); $n2++) {
|
||||
$from = ($e * 8 * 3) + ($n2 * 3);
|
||||
$to = $from + 3;
|
||||
my ($use, $ioa, $tim) = @$line[$from..$to];
|
||||
@row = ($use, $ioa, $tim);
|
||||
printf(" %4.1f%% %7.1f %7.1f ", @row);
|
||||
}
|
||||
$e++;
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
print(" </pre>\n");
|
||||
if($title) {
|
||||
print(" </td>\n");
|
||||
print(" </tr>\n");
|
||||
main::graph_footer();
|
||||
}
|
||||
print(" <br>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# graph mode
|
||||
#
|
||||
if($silent eq "yes" || $silent eq "imagetag") {
|
||||
$colors->{fg_color} = "#000000"; # visible color for text mode
|
||||
$u = "_";
|
||||
}
|
||||
if($silent eq "imagetagbig") {
|
||||
$colors->{fg_color} = "#000000"; # visible color for text mode
|
||||
$u = "";
|
||||
}
|
||||
|
||||
for($n = 0; $n < keys(%{$fs->{list}}); $n++) {
|
||||
for($n2 = 1; $n2 <= 8; $n2++) {
|
||||
$str = $u . $package . $n . $n2 . "." . $tf->{when} . ".png";
|
||||
push(@PNG, $str);
|
||||
unlink("$PNG_DIR" . $str);
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
$str = $u . $package . $n . $n2 . "z." . $tf->{when} . ".png";
|
||||
push(@PNGz, $str);
|
||||
unlink("$PNG_DIR" . $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$e = 0;
|
||||
foreach my $k (sort keys %{$fs->{list}}) {
|
||||
my @f = split(',', $fs->{list}->{$k});
|
||||
|
||||
if($e) {
|
||||
print(" <br>\n");
|
||||
}
|
||||
if($title) {
|
||||
main::graph_header($title, 2);
|
||||
}
|
||||
|
||||
undef(@tmp);
|
||||
undef(@tmpz);
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
for($n = 0; $n < 8; $n++) {
|
||||
if($f[$n]) {
|
||||
my $color;
|
||||
|
||||
$str = $fs->{desc}->{$f[$n]} || trim($f[$n]);
|
||||
if(trim($f[$n]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n];
|
||||
}
|
||||
push(@tmpz, "LINE2:fs" . $n . $color . ":$str");
|
||||
$str = sprintf("%-23s", $str);
|
||||
push(@tmp, "LINE2:fs" . $n . $color . ":$str");
|
||||
push(@tmp, "GPRINT:fs" . $n . ":LAST:Cur\\: %4.1lf%%");
|
||||
push(@tmp, "GPRINT:fs" . $n . ":AVERAGE: Avg\\: %4.1lf%%");
|
||||
push(@tmp, "GPRINT:fs" . $n . ":MIN: Min\\: %4.1lf%%");
|
||||
push(@tmp, "GPRINT:fs" . $n . ":MAX: Max\\: %4.1lf%%\\n");
|
||||
}
|
||||
}
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
if(scalar(@f) && (scalar(@f) % 2)) {
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
}
|
||||
if($title) {
|
||||
print(" <tr>\n");
|
||||
print(" <td bgcolor='$colors->{title_bg_color}'>\n");
|
||||
}
|
||||
($width, $height) = split('x', $config->{graph_size}->{main});
|
||||
if($silent =~ /imagetag/) {
|
||||
($width, $height) = split('x', $config->{graph_size}->{remote}) if $silent eq "imagetag";
|
||||
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
|
||||
@tmp = @tmpz;
|
||||
}
|
||||
RRDs::graph("$PNG_DIR" . "$PNG[$e * 3]",
|
||||
"--title=$config->{graphs}->{_fs1} ($tf->{nwhen}$tf->{twhen})",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=Percent (%)",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
"--upper-limit=100",
|
||||
"--lower-limit=0",
|
||||
"--rigid",
|
||||
@{$cgi->{version12}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:fs0=$rrd:fs" . $e . "_use0:AVERAGE",
|
||||
"DEF:fs1=$rrd:fs" . $e . "_use1:AVERAGE",
|
||||
"DEF:fs2=$rrd:fs" . $e . "_use2:AVERAGE",
|
||||
"DEF:fs3=$rrd:fs" . $e . "_use3:AVERAGE",
|
||||
"DEF:fs4=$rrd:fs" . $e . "_use4:AVERAGE",
|
||||
"DEF:fs5=$rrd:fs" . $e . "_use5:AVERAGE",
|
||||
"DEF:fs6=$rrd:fs" . $e . "_use6:AVERAGE",
|
||||
"DEF:fs7=$rrd:fs" . $e . "_use7:AVERAGE",
|
||||
@tmp);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNG[$e * 3]: $err\n") if $err;
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
||||
RRDs::graph("$PNG_DIR" . "$PNGz[$e * 3]",
|
||||
"--title=$config->{graphs}->{_fs1} ($tf->{nwhen}$tf->{twhen})",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=Percent (%)",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
"--upper-limit=100",
|
||||
"--lower-limit=0",
|
||||
"--rigid",
|
||||
@{$cgi->{version12}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:fs0=$rrd:fs" . $e . "_use0:AVERAGE",
|
||||
"DEF:fs1=$rrd:fs" . $e . "_use1:AVERAGE",
|
||||
"DEF:fs2=$rrd:fs" . $e . "_use2:AVERAGE",
|
||||
"DEF:fs3=$rrd:fs" . $e . "_use3:AVERAGE",
|
||||
"DEF:fs4=$rrd:fs" . $e . "_use4:AVERAGE",
|
||||
"DEF:fs5=$rrd:fs" . $e . "_use5:AVERAGE",
|
||||
"DEF:fs6=$rrd:fs" . $e . "_use6:AVERAGE",
|
||||
"DEF:fs7=$rrd:fs" . $e . "_use7:AVERAGE",
|
||||
@tmpz);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNGz[$e * 3]: $err\n") if $err;
|
||||
}
|
||||
$e2 = $e + 1;
|
||||
if($title || ($silent =~ /imagetag/ && $graph =~ /fs$e2/)) {
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
if(lc($config->{disable_javascript_void}) eq "y") {
|
||||
print(" <a href=\"" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3] . "\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3] . "' border='0'></a>\n");
|
||||
}
|
||||
else {
|
||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3] . "' border='0'></a>\n");
|
||||
}
|
||||
} else {
|
||||
print(" <img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3] . "'>\n");
|
||||
}
|
||||
}
|
||||
if($title) {
|
||||
print(" </td>\n");
|
||||
print(" <td valign='top' bgcolor='" . $colors->{title_bg_color} . "'>\n");
|
||||
}
|
||||
|
||||
undef(@riglim);
|
||||
if(trim($rigid[1]) eq 1) {
|
||||
push(@riglim, "--upper-limit=" . trim($limit[1]));
|
||||
} else {
|
||||
if(trim($rigid[1]) eq 2) {
|
||||
push(@riglim, "--upper-limit=" . trim($limit[1]));
|
||||
push(@riglim, "--rigid");
|
||||
}
|
||||
}
|
||||
undef(@tmp);
|
||||
undef(@tmpz);
|
||||
for($n = 0; $n < 8; $n += 2) {
|
||||
my $color;
|
||||
if($f[$n]) {
|
||||
$str = $fs->{desc}->{$f[$n]} || trim($f[$n]);
|
||||
if(trim($f[$n]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n];
|
||||
}
|
||||
push(@tmpz, "LINE2:ioa" . $n . $color . ":$str\\g");
|
||||
$str = sprintf("%-17s", substr($str, 0, 17));
|
||||
push(@tmp, "LINE2:ioa" . $n . $color . ":$str");
|
||||
}
|
||||
if($f[$n + 1]) {
|
||||
$str = $fs->{desc}->{$f[$n + 1]} || trim($f[$n + 1]);
|
||||
if(trim($f[$n + 1]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n + 1];
|
||||
}
|
||||
push(@tmpz, "LINE2:ioa" . ($n + 1) . $color . ":$str\\g");
|
||||
$str = sprintf("%-17s", substr($str, 0, 17));
|
||||
push(@tmp, "LINE2:ioa" . ($n + 1) . $color . ":$str\\n");
|
||||
}
|
||||
}
|
||||
($width, $height) = split('x', $config->{graph_size}->{small});
|
||||
if($silent =~ /imagetag/) {
|
||||
($width, $height) = split('x', $config->{graph_size}->{remote}) if $silent eq "imagetag";
|
||||
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
|
||||
@tmp = @tmpz;
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
}
|
||||
RRDs::graph("$PNG_DIR" . "$PNG[$e * 3 + 1]",
|
||||
"--title=$config->{graphs}->{_fs2} ($tf->{nwhen}$tf->{twhen})",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=Reads+Writes/s",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
@riglim,
|
||||
"--lower-limit=0",
|
||||
@{$cgi->{version12}},
|
||||
@{$cgi->{version12_small}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:ioa0=$rrd:fs" . $e . "_ioa0:AVERAGE",
|
||||
"DEF:ioa1=$rrd:fs" . $e . "_ioa1:AVERAGE",
|
||||
"DEF:ioa2=$rrd:fs" . $e . "_ioa2:AVERAGE",
|
||||
"DEF:ioa3=$rrd:fs" . $e . "_ioa3:AVERAGE",
|
||||
"DEF:ioa4=$rrd:fs" . $e . "_ioa4:AVERAGE",
|
||||
"DEF:ioa5=$rrd:fs" . $e . "_ioa5:AVERAGE",
|
||||
"DEF:ioa6=$rrd:fs" . $e . "_ioa6:AVERAGE",
|
||||
"DEF:ioa7=$rrd:fs" . $e . "_ioa7:AVERAGE",
|
||||
@tmp);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNG[$e * 3 + 1]: $err\n") if $err;
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
||||
RRDs::graph("$PNG_DIR" . "$PNGz[$e * 3 + 1]",
|
||||
"--title=$config->{graphs}->{_fs2} ($tf->{nwhen}$tf->{twhen})",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=Reads+Writes/s",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
@riglim,
|
||||
"--lower-limit=0",
|
||||
@{$cgi->{version12}},
|
||||
@{$cgi->{version12_small}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:ioa0=$rrd:fs" . $e . "_ioa0:AVERAGE",
|
||||
"DEF:ioa1=$rrd:fs" . $e . "_ioa1:AVERAGE",
|
||||
"DEF:ioa2=$rrd:fs" . $e . "_ioa2:AVERAGE",
|
||||
"DEF:ioa3=$rrd:fs" . $e . "_ioa3:AVERAGE",
|
||||
"DEF:ioa4=$rrd:fs" . $e . "_ioa4:AVERAGE",
|
||||
"DEF:ioa5=$rrd:fs" . $e . "_ioa5:AVERAGE",
|
||||
"DEF:ioa6=$rrd:fs" . $e . "_ioa6:AVERAGE",
|
||||
"DEF:ioa7=$rrd:fs" . $e . "_ioa7:AVERAGE",
|
||||
@tmpz);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNGz[$e * 3 + 1]: $err\n") if $err;
|
||||
}
|
||||
$e2 = $e + 2;
|
||||
if($title || ($silent =~ /imagetag/ && $graph =~ /fs$e2/)) {
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
if(lc($config->{disable_javascript_void}) eq "y") {
|
||||
print(" <a href=\"" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3 + 1] . "\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 1] . "' border='0'></a>\n");
|
||||
}
|
||||
else {
|
||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3 + 1] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 1] . "' border='0'></a>\n");
|
||||
}
|
||||
} else {
|
||||
print(" <img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 1] . "'>\n");
|
||||
}
|
||||
}
|
||||
|
||||
undef(@riglim);
|
||||
if(trim($rigid[2]) eq 1) {
|
||||
push(@riglim, "--upper-limit=" . trim($limit[2]));
|
||||
} else {
|
||||
if(trim($rigid[2]) eq 2) {
|
||||
push(@riglim, "--upper-limit=" . trim($limit[2]));
|
||||
push(@riglim, "--rigid");
|
||||
}
|
||||
}
|
||||
undef(@tmp);
|
||||
undef(@tmpz);
|
||||
if($config->{os} eq "Linux") {
|
||||
if($config->{kernel} > 2.4) {
|
||||
$graph_title = "$config->{graphs}->{_fs3} ($tf->{nwhen}$tf->{twhen})";
|
||||
$vlabel = "Milliseconds";
|
||||
} else {
|
||||
$graph_title = "Disk sectors activity ($tf->{nwhen}$tf->{twhen})";
|
||||
$vlabel = "Sectors/s";
|
||||
}
|
||||
for($n = 0; $n < 8; $n += 2) {
|
||||
my $color;
|
||||
if($f[$n]) {
|
||||
$str = $fs->{desc}->{$f[$n]} || trim($f[$n]);
|
||||
if(trim($f[$n]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n];
|
||||
}
|
||||
push(@tmpz, "LINE2:tim" . $n . $color . ":$str\\g");
|
||||
$str = sprintf("%-17s", substr($str, 0, 17));
|
||||
push(@tmp, "LINE2:tim" . $n . $color . ":$str");
|
||||
}
|
||||
if($f[$n + 1]) {
|
||||
$str = $fs->{desc}->{$f[$n + 1]} || trim($f[$n + 1]);
|
||||
if(trim($f[$n + 1]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n + 1];
|
||||
}
|
||||
push(@tmpz, "LINE2:tim" . ($n + 1) . $color . ":$str\\g");
|
||||
$str = sprintf("%-17s", substr($str, 0, 17));
|
||||
push(@tmp, "LINE2:tim" . ($n + 1) . $color . ":$str\\n");
|
||||
}
|
||||
}
|
||||
} elsif(grep {$_ eq $config->{os}} ("FreeBSD", "OpenBSD", "NetBSD")) {
|
||||
$graph_title = "Disk data activity ($tf->{nwhen}$tf->{twhen})";
|
||||
$vlabel = "KB/s";
|
||||
for($n = 0; $n < 8; $n += 2) {
|
||||
my $color;
|
||||
my $str2;
|
||||
|
||||
$str2 = $fs->{desc}->{$f[$n]} || trim($f[$n]);
|
||||
if($f[$n]) {
|
||||
$str = sprintf("%-17s", $str2, 0, 17);
|
||||
if(trim($f[$n]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n];
|
||||
}
|
||||
push(@tmp, "LINE2:tim" . $n . $color . ":$str");
|
||||
push(@tmpz, "LINE2:tim" . $n . $color . ":$f[$n]\\g");
|
||||
}
|
||||
$str2 = $fs->{desc}->{$f[$n + 1]} || trim($f[$n + 1]);
|
||||
if($f[$n + 1]) {
|
||||
$str = sprintf("%-17s", $str2, 0, 17);
|
||||
if(trim($f[$n + 1]) eq "/") {
|
||||
$color = "#EE4444";
|
||||
} elsif($str eq "swap") {
|
||||
$color = "#CCCCCC";
|
||||
} elsif($str eq "/boot") {
|
||||
$color = "#666666";
|
||||
} else {
|
||||
$color = $LC[$n + 1];
|
||||
}
|
||||
push(@tmp, "LINE2:tim" . ($n + 1) . $color . ":$str\\n");
|
||||
push(@tmpz, "LINE2:tim" . ($n + 1) . $color . ":$f[$n + 1]\\g");
|
||||
}
|
||||
}
|
||||
}
|
||||
($width, $height) = split('x', $config->{graph_size}->{small});
|
||||
if($silent =~ /imagetag/) {
|
||||
($width, $height) = split('x', $config->{graph_size}->{remote}) if $silent eq "imagetag";
|
||||
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
|
||||
@tmp = @tmpz;
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
push(@tmp, "COMMENT: \\n");
|
||||
}
|
||||
RRDs::graph("$PNG_DIR" . "$PNG[$e * 3 + 2]",
|
||||
"--title=$graph_title",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=$vlabel",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
@riglim,
|
||||
"--lower-limit=0",
|
||||
@{$cgi->{version12}},
|
||||
@{$cgi->{version12_small}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:tim0=$rrd:fs" . $e . "_tim0:AVERAGE",
|
||||
"DEF:tim1=$rrd:fs" . $e . "_tim1:AVERAGE",
|
||||
"DEF:tim2=$rrd:fs" . $e . "_tim2:AVERAGE",
|
||||
"DEF:tim3=$rrd:fs" . $e . "_tim3:AVERAGE",
|
||||
"DEF:tim4=$rrd:fs" . $e . "_tim4:AVERAGE",
|
||||
"DEF:tim5=$rrd:fs" . $e . "_tim5:AVERAGE",
|
||||
"DEF:tim6=$rrd:fs" . $e . "_tim6:AVERAGE",
|
||||
"DEF:tim7=$rrd:fs" . $e . "_tim7:AVERAGE",
|
||||
@tmp);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNG[$e * 3 + 2]: $err\n") if $err;
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
||||
RRDs::graph("$PNG_DIR" . "$PNGz[$e * 3 + 2]",
|
||||
"--title=$graph_title",
|
||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||
"--imgformat=PNG",
|
||||
"--vertical-label=$vlabel",
|
||||
"--width=$width",
|
||||
"--height=$height",
|
||||
@riglim,
|
||||
"--lower-limit=0",
|
||||
@{$cgi->{version12}},
|
||||
@{$cgi->{version12_small}},
|
||||
@{$colors->{graph_colors}},
|
||||
"DEF:tim0=$rrd:fs" . $e . "_tim0:AVERAGE",
|
||||
"DEF:tim1=$rrd:fs" . $e . "_tim1:AVERAGE",
|
||||
"DEF:tim2=$rrd:fs" . $e . "_tim2:AVERAGE",
|
||||
"DEF:tim3=$rrd:fs" . $e . "_tim3:AVERAGE",
|
||||
"DEF:tim4=$rrd:fs" . $e . "_tim4:AVERAGE",
|
||||
"DEF:tim5=$rrd:fs" . $e . "_tim5:AVERAGE",
|
||||
"DEF:tim6=$rrd:fs" . $e . "_tim6:AVERAGE",
|
||||
"DEF:tim7=$rrd:fs" . $e . "_tim7:AVERAGE",
|
||||
@tmpz);
|
||||
$err = RRDs::error;
|
||||
print("ERROR: while graphing $PNG_DIR" . "$PNGz[$e * 3 + 2]: $err\n") if $err;
|
||||
}
|
||||
$e2 = $e + 3;
|
||||
if($title || ($silent =~ /imagetag/ && $graph =~ /fs$e2/)) {
|
||||
if(lc($config->{enable_zoom}) eq "y") {
|
||||
if(lc($config->{disable_javascript_void}) eq "y") {
|
||||
print(" <a href=\"" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3 + 2] . "\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 2] . "' border='0'></a>\n");
|
||||
}
|
||||
else {
|
||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . $config->{imgs_dir} . $PNGz[$e * 3 + 2] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 2] . "' border='0'></a>\n");
|
||||
}
|
||||
} else {
|
||||
print(" <img src='" . $config->{url} . $config->{imgs_dir} . $PNG[$e * 3 + 2] . "'>\n");
|
||||
}
|
||||
}
|
||||
|
||||
if($title) {
|
||||
print(" </td>\n");
|
||||
print(" </tr>\n");
|
||||
main::graph_footer();
|
||||
}
|
||||
$e++;
|
||||
}
|
||||
print(" <br>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue