Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
memory.pl
Package: mrtg-2.13.2.zip [view]
Upload User: shbosideng
Upload Date: 2013-05-04
Package Size: 1555k
Code Size: 1k
Category:
SNMP
Development Platform:
C/C++
- #!/usr/bin/perl
- # This small utility is used to collect the available memory and
- # used memory. For free memory, it sums the free, cached and buffers.
- # You must enable the "gauge" feature to have a proper graph
- # as those numbers do not grow
- #
- # Colin Tinker
- # g1gsw@titanic.demon.co.uk
- # setup local vars
- my($machine);
- # Enter default macine name here
- $machine = "g1gsw.ampr.org";
- # This allows command args to override defaults listed above
- if (scalar(@ARGV) > 1 )
- {
- print("USAGE: memory.pl {machine}n");
- exit(-1);
- }
- if ($ARGV[0] ne '' && $ARGV[0] ne '#')
- {
- $machine = $ARGV[0];
- }
- # Calculate free memory
- $getfree = `cat /proc/meminfo | grep Mem:`;
- $getfree =~ /^Mem:s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)s+(d+)/;
- # Each (D+) = $1 or $2 or $3 etc
- $outfree = $3;
- $outbuffers = $5;
- $outcached = $6;
- # Total free memory
- $gettotal = $outfree+$outcached+$outbuffers;
- print $gettotal."n";
- # Get used memory free
- $getused = `cat /proc/meminfo | grep Swap:`;
- $outused = $1-$gettotal;
- print $outused."n";
- # Get uptime
- $getuptime = `/usr/bin/uptime`;
- # Parse though getuptime and get data
- $getuptime =~ /^s+(d{1,2}:d{2}..)s+ups+(d+)s+(w+),/;
- #Print getuptime data for mrtg
- print $2." ".$3."n";
- # Print machine name for mrtg
- print $machine."n";