npm update -gImport a Resource to Terraform Module
The example below will import an AWS instance into a terraform module:
terraform import module.foo.aws_instance.bar i-abcd1234Install ruby gem files
Install the gems on the destination machine from the local files:
cd /path/to/gems
gem install --force --local *.gemOne liner: To get available virtual memory
vmstat -s -SM | grep "free memory" | awk -F" " '{print$1}'Perl – system load
To find the system load use the following perl snippet :
- System load of last one minute :
my $system_load = exec('<a class="zem_slink" title="Uptime" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uptime">uptime</a> | awk -F "load average: " \'{ print $2 }\' | cut -d, -f1');
my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f1');- System load of last 5 minutes :
my $system_load = exec('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f2');
my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f2');- System load of last 15 minutes :
my $system_load = exec('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f3');
my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f3');Perl – How to Read a Text File into a Variable – 6 ways to do it
6 Ways to Read a Text File into a Variable
If you are working with large file(s) you might consider using File::Slurp. It is much fast than the conventional:
{
local $/=undef;
open FILE, "myfile" or die "Couldn't open file: $!";
binmode FILE;
$string = <FILE>;
close FILE;
}
{
local $/=undef;
open FILE, "myfile" or die "Couldn't open file: $!";
$string = <FILE>;
close FILE;
}
open FILE, "myfile" or die "Couldn't open file: $!";
$string = join("", <FILE>);
close FILE;
open FILE, "myfile" or die "Couldn't open file: $!";
while (<FILE>){
$string .= $_;
}
close FILE;
open( FH, "sample.txt") || die("Error: $!\n");
read(FH, $data, 2000);
close FH;The format for the read function is: