function compare_indexes($db_master, $db_test, $table_name, $masterdb, $testdb) { $master_details = get_indexes($db_master, $table_name, $masterdb); $master_index_no = count($master_details); $test_details = get_indexes($db_test, $table_name, $testdb); $test_index_no = count($test_details); if ($test_index_no == 0) { $class = 'dkred'; echo "<table class=\"nonexist\">"; } else { $class = 'grey'; echo "<table>"; } echo "<tr><td class=\"{$class}\">Non_unique</td><td class=\"{$class}\">Key_name</td><td class=\"{$class}\">Column_name</td><td class=\"{$class}\">Index_type</td></tr>\n"; $lines_to_check = array(1, 2, 4, 10); for ($i = 0; $i < $master_index_no; $i++) { echo "<tr>"; $master_line = $master_details[$i]; if (isset($test_details[$i])) { $test_line = $test_details[$i]; for ($col = 0; $col < 13; $col++) { if (in_array($col, $lines_to_check)) { $text = format_text($master_line[$col]); if ($master_line[$col] === $test_line[$col]) { echo "<td>{$text}</td>"; } else { echo "<td class=\"err\">{$text}</td>"; } } } } else { for ($col = 0; $col < 13; $col++) { if (in_array($col, $lines_to_check)) { $text = format_text($master_line[$col]); echo "<td class=\"err\">{$text}</td>"; } } } echo "</tr>"; } // Display extra fields in test table. if (count($test_details) > count($master_details)) { for ($i = $master_index_no; $i < $test_index_no; $i++) { $test_line = $test_details[$i]; echo "<tr>"; for ($col = 0; $col < 13; $col++) { if (in_array($col, $lines_to_check)) { $text = format_text($test_line[$col]); echo "<td class=\"err\">{$text}</td>"; } } echo "</tr>\n"; } } echo "</table>\n<br />\n"; }
*/ } elseif ($cmd == "query") { $arg = $_SERVER["argv"][5]; $arr_index = get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids); for ($i = 0; $i < sizeof($arr_index); $i++) { if ($arg == "usage") { print $arr_index[$i] . "!" . $arr[$i] . "\n"; } elseif ($arg == "index") { print $arr_index[$i] . "!" . $arr_index[$i] . "\n"; } } } elseif ($cmd == "get") { $arg = $_SERVER["argv"][5]; $index = $_SERVER["argv"][6]; $arr_index = get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids); if (isset($arr_index[$index])) { print $arr[$index]; } } function get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids) { $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); $return_arr = array(); $j = 0; for ($i = 0; $i < sizeof($arr); $i++) { if (ereg("^[0-9]+\$", $arr[$i])) { $return_arr[$j] = $arr[$i]; $j++; }
} } elseif ($cmd == "query") { $arg = $_SERVER["argv"][5]; $arr_index = get_indexes($hostname, $snmp_community, $snmp_version); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version); for ($i = 0; $i < sizeof($arr_index); $i++) { if ($arg == "usage") { print $arr_index[$i] . "!" . $arr[$i] . "\n"; } elseif ($arg == "index") { print $arr_index[$i] . "!" . $arr_index[$i] . "\n"; } } } elseif ($cmd == "get") { $arg = $_SERVER["argv"][5]; $index = $_SERVER["argv"][6]; $arr_index = get_indexes($hostname, $snmp_community, $snmp_version); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version); if (isset($arr_index[$index])) { print $arr[$index]; } } function get_cpu_usage($hostname, $snmp_community, $snmp_version) { $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, "", "", 161, 1000)); $return_arr = array(); $j = 0; for ($i = 0; $i < sizeof($arr); $i++) { if (ereg("^[0-9]+\$", $arr[$i])) { $return_arr[$j] = $arr[$i]; $j++; }
$arr_index = get_indexes($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol); for ($i=0;($i<sizeof($arr_index));$i++) { if ($arg == "usage") { print $arr_index[$i] . "!" . $arr[$i] . "\n"; }elseif ($arg == "index") { print $arr_index[$i] . "!" . $arr_index[$i] . "\n"; } } }elseif ($cmd == "get") { $arg = $_SERVER["argv"][10]; $index = $_SERVER["argv"][11]; $arr_index = get_indexes($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol); $arr = get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol); if (isset($arr_index[$index])) { print $arr[$index]; } } function get_cpu_usage($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol) { $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000)); $return_arr = array(); $j = 0; for ($i=0;($i<sizeof($arr));$i++) { if (is_numeric($arr[$i])) {