/usr/share/doc/trend/examples/mem is in trend 1.4-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/usr/bin/env perl
# memory + swap usage for trend
use strict;
use warnings;
use Time::HiRes "usleep";
# be sure to flush right away!
$| = 1;
# sleep time
my $ms = ($ARGV[0]? $ARGV[0]: 0.1) * 1000000;
# main loop
while()
{
open FD, "/proc/meminfo" or die;
while(<FD>)
{
# 2.4 kernel
my ($tot, $used, $free, $buf, $cache) = /^Mem: *(\d+) +(\d+) +(\d+) +\d+ +(\d+) +(\d+)$/;
if($tot)
{
print(($tot - $free - $buf - $cache) / 1024. . "\n");
last;
}
# 2.6 kernel
my ($active) = /^Active: *(\d+) kB$/;
if($active)
{
print "$active\n";
last;
}
}
close FD;
usleep $ms;
}
|