torstentfk Cacti User
Joined: 05 Apr 2005 Posts: 179 Location: Munich, Germany
|
Posted: Fri Sep 26, 2008 4:13 am Post subject: Error in ./scripts/unix_memory.pl |
|
|
Hi,
new-code:
| Code: |
#!/usr/bin/perl
open(PROCESS, "cat /proc/meminfo | grep $ARGV[0] |");
foreach (<PROCESS>) {
if ($_ =~ /($ARGV[0].*\s)(.*[0-9])( kB)/) {
print $2;
close(PROCESS);
exit();
}
}
close(PROCESS);
|
Inside the if-clause the close() and exit()-statement were missing:
| Code: | $# cat /proc/meminfo
MemTotal: 2076980 kB
MemFree: 1539736 kB
Buffers: 143224 kB
Cached: 250748 kB
SwapCached: 0 kB
Active: 330108 kB
Inactive: 150644 kB |
If there there are more lines matching the grep-string the script would concat all numbers at the output.
I haved call the script with "Cached" an got 2507480 KB. The last zero in the output is fetched from the next line "SwapCached"....
Torsten |
|