GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

Cacti plugins and SNMP via TCP

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cacti plugins and SNMP via TCP

    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

    Code:
    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;
    $host = (substr($options["host"], 0, 3) == "tcp" ? substr($options["host"], 4) : $options['host']);
    $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
    Code:
    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.
    $result[substr($args[$i], 2)] = (substr($args[$i + 1], 0, 3) == "tcp" ? substr($args[$i + 1], 4) : $args[$i + 1]);
    ++$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

  • #2
    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?

    Comment


    • #3
      Hey weber

      single cacti server connecting to multiple machines yes

      Comment

      Working...
      X