Summary
Question
The information provided below is for a Linux/UNIX OS because on Windows there is a GUI where all these steps could be done more easily.
1. Create class specification file:
The file could be created in any directory but for this example /tmp folder has been used:
#cd /tmp
#touch top.spec (the file could be named of course with a differently)
Once creating the top.spec file it needs to be edited and the following information to be added inside (such information could be found in each Operations Agent User Guide):
#vi top.spec
CLASS TOP_MEM_STATS = 10001
LABEL "TOP_MEM data"
INDEX BY HOUR
MAX INDEXES 12
ROLL BY HOUR
RECORDS PER HOUR 120; (this time interval is going to collect data each 30 seconds)
METRICS
MEM_USED = 106
LABEL "Memory Used"
PRECISION 0;
2. When the class specification file is being completed sdlcomp should be used in order to checked for syntax errors.
If none are found, sdlcomp creates or updates a set of log files to hold the data for the class:
# sdlcomp /tmp/top.spec /tmp/TOP_STAT
sdlcomp 11.14.014 2014-06-08_2304.
Check class specification syntax.
CLASS TOP_MEM_STATS = 10001
LABEL "TOP_MEM data"
INDEX BY HOUR
MAX INDEXES 12
ROLL BY HOUR
RECORDS PER HOUR 120;
METRICS
MEM_USED = 106
LABEL "Memory Used"
PRECISION 0;
NOTE: Time stamp inserted as first metric by default.
Syntax check successful.
Update SDL /tmp/trifon/TOP_STAT.
Class TOP_MEM_STATS successfully added to logfile set.
3. Now pipe the output of vmstat directly to the dsilog logging process (in order to have only the "used memory" the command it should be used is #vmstat - s. However -s switch displays a table of various event counters and memory statistics. This display does NOT repeat. Therefore in order to catch only "used memory" a script should be used). Use the following command:
#while true; do vmstat -s | grep "used memory" | awk '{print $1}'; sleep 30; done | /opt/perf/bin/dsilog /tmp/TOP_STAT TOP_MEM_STATS &
Now "used memory" is going to be collected each 30 sec. To be able to verify the following command should be used:
#extract -xp -l /tmp/TOP_STAT -C TOP_MEM_STATS -ut -f stdout
Writing TOP_MEM_STATS data to stdout
DATE & Memory
TIME Used
1448553090 3055896
1448553210 3056764
1448553240 3057408
1448553270 3057408
1448553300 3057788
To check if the process is still running:
#ps -ef | grep dsilog
root 5066 26875 0 15:53 pts/1 00:00:00 /opt/perf/bin/dsilog /tmp/TOP_STAT TOP_MEM_STATS
root 20534 26875 0 16:13 pts/1 00:00:00 grep dsilog
To stop the collection, simply kill the process:
#kill -9 5066