Skip to content

Instantly share code, notes, and snippets.

@tateisu
Last active February 10, 2020 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateisu/4fb063a69a0e883d9480c5cc4e9382b2 to your computer and use it in GitHub Desktop.
Save tateisu/4fb063a69a0e883d9480c5cc4e9382b2 to your computer and use it in GitHub Desktop.
マシンがヒマになったら音を鳴らすスクリプト
#!/usr/bin/perl --
use strict;
use warnings;
my $host = shift or die "usege: $0 ssh_config_name\n";
while(1){
my $strUptime = `ssh $host -C uptime`;
if(not $strUptime =~ /load average: ([\d\.]+), ([\d\.]+), ([\d\.]+)/ ){
warn "can't get uptime.\n";
}else{
my($la1,$la5,$la15)=map{0+$_} ($1,$2,$3);
print "loadavg of $host : $la1, $la5, $la15\n";
$la1 <= 0.5 and system "/usr/bin/ffplay -nodisp -autoexit -loglevel 0 shinchoku.mp3";
}
sleep 60;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment