|
|
@ -39,20 +39,21 @@ sub magic_level {
|
|
|
|
return $new_level;
|
|
|
|
return $new_level;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
my $fs = Sys::Filesystem->new();
|
|
|
|
sub conky_fs {
|
|
|
|
my @filesystems = $fs->filesystems();
|
|
|
|
my $fs = Sys::Filesystem->new();
|
|
|
|
|
|
|
|
my @filesystems = $fs->filesystems();
|
|
|
|
|
|
|
|
|
|
|
|
# determine longest mount point path
|
|
|
|
# determine longest mount point path
|
|
|
|
my $mlength = 5;
|
|
|
|
my $mlength = 5;
|
|
|
|
for my $f (@filesystems) {
|
|
|
|
for my $f (@filesystems) {
|
|
|
|
my $mount_point = $fs->mount_point($f);
|
|
|
|
my $mount_point = $fs->mount_point($f);
|
|
|
|
|
|
|
|
|
|
|
|
if (length($mount_point) > $mlength) {
|
|
|
|
if (length($mount_point) > $mlength) {
|
|
|
|
$mlength = length($mount_point);
|
|
|
|
$mlength = length($mount_point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for my $f (@filesystems) {
|
|
|
|
for my $f (@filesystems) {
|
|
|
|
my $mount_point = $fs->mount_point($f);
|
|
|
|
my $mount_point = $fs->mount_point($f);
|
|
|
|
my $format = $fs->format($f);
|
|
|
|
my $format = $fs->format($f);
|
|
|
|
|
|
|
|
|
|
|
@ -86,23 +87,23 @@ for my $f (@filesystems) {
|
|
|
|
$bfree/(1024*1024),
|
|
|
|
$bfree/(1024*1024),
|
|
|
|
$mount_point
|
|
|
|
$mount_point
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# hddtemp
|
|
|
|
sub conky_hddtemp {
|
|
|
|
|
|
|
|
my $color_toocold = "#0000ff";
|
|
|
|
my $color_toocold = "#0000ff";
|
|
|
|
my $color_toohot = "#ff0000";
|
|
|
|
my $color_toohot = "#ff0000";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $socket=IO::Socket::INET->new(
|
|
|
|
my $socket=IO::Socket::INET->new(
|
|
|
|
PeerAddr => 'localhost', PeerPort=> 7634,
|
|
|
|
PeerAddr => 'localhost', PeerPort=> 7634,
|
|
|
|
Proto => 'tcp', Type => $IO::Socket::SOCK_STREAM)
|
|
|
|
Proto => 'tcp', Type => $IO::Socket::SOCK_STREAM)
|
|
|
|
or croak "Can't talk to hddtemp";
|
|
|
|
or croak "Can't talk to hddtemp";
|
|
|
|
my $hddtemp_output = <$socket>;
|
|
|
|
my $hddtemp_output = <$socket>;
|
|
|
|
close $socket;
|
|
|
|
close $socket;
|
|
|
|
|
|
|
|
|
|
|
|
my @hddtemp_output = split /[|]/x, $hddtemp_output;
|
|
|
|
my @hddtemp_output = split /[|]/x, $hddtemp_output;
|
|
|
|
my $diskcount = $#hddtemp_output/5;
|
|
|
|
my $diskcount = $#hddtemp_output/5;
|
|
|
|
for (my $i = 0; $i < $diskcount; $i++) {
|
|
|
|
for (my $i = 0; $i < $diskcount; $i++) {
|
|
|
|
my $dev = $hddtemp_output[$i*5+1];
|
|
|
|
my $dev = $hddtemp_output[$i*5+1];
|
|
|
|
my $temp = $hddtemp_output[$i*5+3];
|
|
|
|
my $temp = $hddtemp_output[$i*5+3];
|
|
|
|
my $unit = $hddtemp_output[$i*5+4];
|
|
|
|
my $unit = $hddtemp_output[$i*5+4];
|
|
|
@ -116,15 +117,16 @@ for (my $i = 0; $i < $diskcount; $i++) {
|
|
|
|
|
|
|
|
|
|
|
|
printf " \${color #98c2c7}%s\$color ", $dev;
|
|
|
|
printf " \${color #98c2c7}%s\$color ", $dev;
|
|
|
|
printf "\${color $color}%02.f°%s\$color\n", $temp, $unit;
|
|
|
|
printf "\${color $color}%02.f°%s\$color\n", $temp, $unit;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# mdstat
|
|
|
|
sub conky_mdstat {
|
|
|
|
open my $fh, "<", "/proc/mdstat";
|
|
|
|
open my $fh, "<", "/proc/mdstat";
|
|
|
|
my $md_current;
|
|
|
|
my $md_current;
|
|
|
|
my $md_current_state;
|
|
|
|
my $md_current_state;
|
|
|
|
my $md_current_mdstat;
|
|
|
|
my $md_current_mdstat;
|
|
|
|
|
|
|
|
|
|
|
|
sub print_md_current_state {
|
|
|
|
my $print_md_current_state = sub {
|
|
|
|
if (defined $md_current) {
|
|
|
|
if (defined $md_current) {
|
|
|
|
my $color = $color_ok;
|
|
|
|
my $color = $color_ok;
|
|
|
|
my $print_mdstat = 0;
|
|
|
|
my $print_mdstat = 0;
|
|
|
@ -149,14 +151,14 @@ sub print_md_current_state {
|
|
|
|
$md_current_mdstat;
|
|
|
|
$md_current_mdstat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
while (my $line = <$fh>) {
|
|
|
|
while (my $line = <$fh>) {
|
|
|
|
next if $line =~ /^Personalities\s*:/xsmi;
|
|
|
|
next if $line =~ /^Personalities\s*:/xsmi;
|
|
|
|
next if $line =~ /^unused\sdevices\s*:/xsmi;
|
|
|
|
next if $line =~ /^unused\sdevices\s*:/xsmi;
|
|
|
|
|
|
|
|
|
|
|
|
if ($line =~ /^(.*) : /) {
|
|
|
|
if ($line =~ /^(.*) : /) {
|
|
|
|
print_md_current_state();
|
|
|
|
&$print_md_current_state();
|
|
|
|
|
|
|
|
|
|
|
|
$md_current = $1;
|
|
|
|
$md_current = $1;
|
|
|
|
$md_current_state = undef;
|
|
|
|
$md_current_state = undef;
|
|
|
@ -168,8 +170,13 @@ while (my $line = <$fh>) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$md_current_mdstat .= $line;
|
|
|
|
$md_current_mdstat .= $line;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $fh;
|
|
|
|
|
|
|
|
&$print_md_current_state();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close $fh;
|
|
|
|
|
|
|
|
print_md_current_state();
|
|
|
|
conky_fs();
|
|
|
|
|
|
|
|
conky_hddtemp();
|
|
|
|
|
|
|
|
conky_mdstat();
|
|
|
|
|
|
|
|
|
|
|
|
# vim:textwidth=120:
|
|
|
|
# vim:textwidth=120:
|
|
|
|