Adding a Swap Graph
Most of you are aware of the excellent Better Cacti Templates (BCT) http://code.google.com/p/mysql-cacti-templates/
The attached patch will add the ability to create Swap graphs to an existing installation of BCT.
The following instructions assume you have an installed, working version of BCT already running in Cacti.
I have modified the ss_get_by_ssh.php script that comes with BCT (see bottom of this message for details in Appendix A.)
Instructions:
1) Extract the attached swap-patch.tar.gz to a temporary location on the server where Cacti is installed.
2) Copy swap-patch/ss_get_by_ssh.php to your existing cacti scripts folder. It should overwrite your current ss_get_by_ssh.php file already located there.
NOTE: If you made changes to your existing ss_get_by_ssh.php such as $ssh_users, you will need to make those changes again or see Appendix A below if you would rather edit your existing file. If you were smart and used an external configuration file (ss_get_by_ssh.php.cnf) as suggested in the BCT documentation, then you have no worries mate. Proceed to the next step!
3) In Cacti, import swap-patch/cacti_graph_template_x_swap_gt.xml
4) Once X Swap GT has been imported successfully, you can add X Swap graphs to your devices.
Appendix A: Details of Changes to ss_get_by_ssh.php
Changes shown in red:
# Stuff from 'free'
'STAT_memcached' => 'au',
'STAT_membuffer' => 'av',
'STAT_memshared' => 'aw',
'STAT_memfree' => 'ax',
'STAT_memused' => 'ay',
'STAT_swapfree' => 'dc',
'STAT_swapused' => 'dd',
Note: I'm using variables dc and dd because db is the last variable in the $keys array (at time of writing using Better Cacti Templates v1.1.7)
function memory_parse ( $options, $output ) {
$result = array(
'STAT_memcached' => null,
'STAT_membuffer' => null,
'STAT_memshared' => null,
'STAT_memfree' => null,
'STAT_memused' => null,
'STAT_swapfree' => null,
'STAT_swapused' => null,
);
foreach ( explode("\n", $output) as $line ) {
if ( preg_match_all('/\S+/', $line, $words) ) {
$words = $words[0];
if ( $words[0] == "Mem:" ) {
$result['STAT_memcached'] = $words[6];
$result['STAT_membuffer'] = $words[5];
$result['STAT_memshared'] = $words[4];
$result['STAT_memfree'] = $words[3];
$result['STAT_memused'] = sprintf('%.0f',
$words[2] - $words[4] - $words[5] - $words[6]);
}
if ( $words[0] == "Swap:" ) {
$result[ 'STAT_swapfree'] = $words[3];
$result[ 'STAT_swapused'] = $words[2];
}
}
}
return $result;
}
Swap Graph
Moderators: Developers, Moderators
Swap Graph
- Attachments
-
- swap-patch.tar.gz
- (13.73 KiB) Downloaded 258 times
Who is online
Users browsing this forum: No registered users and 6 guests