Code: Select all
#!/usr/bin/perl
$page = 4096;
open(PROC, '/proc/meminfo') || open(PROC, '/usr/bin/vm_stat |') || die "$!";
while (<PROC>) {
$page = $1 if /page\s+size\s+of\s+(\d+)\s+bytes/;
print $1*$page,"\n" and exit 0 if (/^$ARGV[0]\:\s+(\d+)/i);
}
close(PROC);
Code: Select all
$ nix_memory.pl 'Pages free'
568799232
$ nix_memory.pl 'Pages inactive'
999067648
That is how I try to use it for free + inactive mamory an example:
1 ) copy nix_memory.pl file to /cacti/scripts/ directory
2) Create two DataInputMethod
and create second DataInputMethod , the same, only to change
Name -> |host_description| - Memory - inactive
Grep String -> 'Pages inactive'
3) Create Data Templates
Memory - free
3) Create Graph Templates
4) Create New Graph
New Graph -> Create: Mac_Linux - Memory Usage -> Create
but cacti graph is not displayed
I am receiving the folling error:
Please help me solve the problem!12/03/2008 12:15:05 PM - CMDPHP: Poller[0] Host[1] Description[Localhost] DS[205] Graphs['Localhost - Memory Usage'] CMD: perl /opt/local/share/cacti/scripts/nix_memory.pl , output: U
12/03/2008 12:15:05 PM - CMDPHP: Poller[0] Host[1] Description[Localhost] DS[205] Graphs['Localhost - Memory Usage'] WARNING: Result from CMD not valid. Partial Result:
12/03/2008 12:15:05 PM - CMDPHP: Poller[0] Host[1] Description[Localhost] DS[204] Graphs['Localhost - Memory Usage'] CMD: perl /opt/local/share/cacti/scripts/nix_memory.pl , output: U
12/03/2008 12:15:05 PM - CMDPHP: Poller[0] Host[1] Description[Localhost] DS[204] Graphs['Localhost - Memory Usage'] WARNING: Result from CMD not valid. Partial Result: