Not the answer you need?
Register and ask your own question!

Cacti plugins and SNMP via TCP

foosterbroekfoosterbroek EntrantInactive User Role Beginner
Hi guys

one thing I have noticed with the cacti templates that gets me every time I run an upgrade

The ss_get_by_ss.php and ss_get_mysql_stats.php files do not take in account that you may have snmpd running via a tcp connection rather than udp. Your hosts are defined by tcp:${ip address} rather than just ${ip address}

In the below code I have bolded my alterations

Excerpt from ss_get_mysql_stats.php
function ss_get_mysql_stats( $options ) {
# Process connection options.
global $debug, $mysql_user, $mysql_pass, $cache_dir, $poll_time, $chk_options,
$mysql_port, $mysql_ssl, $mysql_ssl_key, $mysql_ssl_cert, $mysql_ssl_ca,
$heartbeat, $heartbeat_table, $heartbeat_server_id, $heartbeat_utc;

$user = isset($options['user']) ? $options['user'] : $mysql_user;
$pass = isset($options['pass']) ? $options['pass'] : $mysql_pass;
[B]$host = (substr($options["host"], 0, 3) == "tcp" ? substr($options["host"], 4) : $options['host']);[/B]
$port = isset($options['port']) ? $options['port'] : $mysql_port;
$heartbeat_server_id = isset($options['server-id']) ? $options['server-id'] : $heartbeat_server_id;

$sanitized_host = str_replace(array(":", "/"), array("", "_"), $host);
$cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" . ($port != 3306 ? ":$port" : '');
debug("Cache file is $cache_file");

Excerpt from ss_get_by_ssh.php
function parse_cmdline( $args ) {
$result = array();
for ( $i = 0; $i < count($args); ++$i ) {
if ( strpos($args[$i], '--') === 0 ) {
if ( $i + 1 < count($args) && strpos($args[$i + 1], '--') !== 0 ) {
# The next element should be the value for this option.
[B]$result[substr($args[$i], 2)] = (substr($args[$i + 1], 0, 3) == "tcp" ? substr($args[$i + 1], 4) : $args[$i + 1]);[/B]
++$i;
}
}
}
debug($result);
return $result;
}

Might be an idea to push this to your code set. It shouldn't have any impact on existing clients that use snmp on the default udp. Not too sure if there is a quicker, or cleaner approach to this. Another option would be to have a command line option that tells the code that you are using tcp rather than udp

Comments

  • weberweber Advisor Inactive User Role Beginner
    I assume that you have SNMP devices/hosts in Cacti and you add Percona graphs to them, i.e. you are not using separate devices for Percona Host graphs?
  • foosterbroekfoosterbroek Entrant Inactive User Role Beginner
    Hey weber

    single cacti server connecting to multiple machines yes
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.