| version 1.5, 2003/11/24 18:35:45 |
version 1.6, 2003/12/11 13:04:56 |
|
|
| # 16/10/2003 - added automatic database reconnecting (nepto) |
# 16/10/2003 - added automatic database reconnecting (nepto) |
| # |
# |
| |
|
| # $Platon: scripts/syswatcher/syswatcher.pl,v 1.4 2003/11/14 09:53:51 rajo Exp $ |
# $Platon: scripts/syswatcher/syswatcher.pl,v 1.5 2003/11/24 18:35:45 rajo Exp $ |
| |
|
| use strict; |
use strict; |
| |
|
| Line 49 $update_interval = 10; # seconds |
|
| Line 49 $update_interval = 10; # seconds |
|
| # MAIN |
# MAIN |
| # |
# |
| |
|
| |
FORK: { |
| |
my $pid; |
| |
if ($pid = fork) { |
| |
# parent |
| |
exit 0; |
| |
} |
| |
elsif (defined $pid) { |
| |
# child |
| |
} |
| |
elsif ($! =~ /No more process/) { |
| |
# EAGAIN |
| |
warn "Can't fork: $!"; |
| |
sleep 5; |
| |
redo fork; |
| |
} |
| |
else { |
| |
die "Can't fork: $!"; |
| |
} |
| |
} |
| |
|
| print_info("PID = $$ $0 started"); |
print_info("PID = $$ $0 started"); |
| |
|
| while (1) { |
while (1) { |
|
|
| my $modify_time = -86400.0 * -M $0; |
my $modify_time = -86400.0 * -M $0; |
| if (defined $modify_time && $modify_time > 0) { # Autorestart - if file exists and is modified |
if (defined $modify_time && $modify_time > 0) { # Autorestart - if file exists and is modified |
| print_info("Script '$0' MODIFIED $modify_time seconds after startup, restarting ..."); |
print_info("Script '$0' MODIFIED $modify_time seconds after startup, restarting ..."); |
| exec $0; |
exec $0, @ARGV; |
| } |
} |
| } |
} |
| |
|
|
|
| |
|
| $sql_loadavg->execute( |
$sql_loadavg->execute( |
| $load1, $load5, $load15, $procs_run, $procs_total, $last_pid) or warn $dbh->errstr; |
$load1, $load5, $load15, $procs_run, $procs_total, $last_pid) or warn $dbh->errstr; |
| print_info("Loadavg inserted"); |
#print_info("Loadavg inserted"); |
| |
|
| close FILE; |
close FILE; |
| |
|
|
|
| $xx{LowFree}, $xx{SwapTotal}, $xx{SwapFree}, $xx{Dirty}, $xx{Writeback}, |
$xx{LowFree}, $xx{SwapTotal}, $xx{SwapFree}, $xx{Dirty}, $xx{Writeback}, |
| $xx{Mapped}, $xx{Slab}, $xx{Committed_AS}, $xx{PageTables},$xx{VmallocTotal}, |
$xx{Mapped}, $xx{Slab}, $xx{Committed_AS}, $xx{PageTables},$xx{VmallocTotal}, |
| $xx{VmallocUsed}, $xx{VmallocChunk}, $xx{HugePages_Total}, $xx{HugePages_Free}, $xx{Hugepagesize} |
$xx{VmallocUsed}, $xx{VmallocChunk}, $xx{HugePages_Total}, $xx{HugePages_Free}, $xx{Hugepagesize} |
| ) or warn $dbh->errstr; |
) or warn $dbh->errstr; |
| print_info("Meminfo inserted"); |
#print_info("Meminfo inserted"); |
| |
|
| return 1; |
return 1; |
| |
|