switchport.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
  5. if (isset($_POST["regensnmp"])) {
  6. $snmp_index = $_POST["f_snmp_start"] * 1;
  7. $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id order by id";
  8. $flist = mysqli_query($db_link, $sSQL);
  9. LOG_DEBUG($db_link, "Recalc snmp_index for device id: $id with start $snmp_index");
  10. while (list ($port_id, $port) = mysqli_fetch_array($flist)) {
  11. $snmp = $port + $snmp_index - 1;
  12. $new['snmp_index'] = $snmp;
  13. update_record($db_link, "device_ports", "id='$port_id'", $new);
  14. }
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. }
  17. $switch=get_record($db_link,'devices',"id=".$id);
  18. unset($_POST);
  19. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  20. print_editdevice_submenu($page_url,$id);
  21. ?>
  22. <div id="cont">
  23. <form name="def" action="switchport.php?id=<? echo $id; ?>" method="post">
  24. <?php
  25. print "<br>\n";
  26. print "<b>Список портов ".$switch['device_name']." - ".$switch['ip']."</b><br>\n";
  27. print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
  28. print "<tr>\n";
  29. print "<td>Порт</td>\n";
  30. print "<td>Snmp</td>\n";
  31. print "<td>Mac count</td>\n";
  32. print "<td>Uplink</td>\n";
  33. print "<td>Nagios</td>\n";
  34. print "<td>Skip</td>\n";
  35. print "<td>Юзер|Device</td>\n";
  36. print "<td>Комментарий</td>\n";
  37. print "<td>Vlan</td>\n";
  38. print "<td>График</td>\n";
  39. print "</tr>\n";
  40. $sSQL = "SELECT id,snmp_index,port,comment,target_port_id,last_mac_count,uplink,nagios,skip,vlan from device_ports WHERE device_ports.device_id=$id Order by port";
  41. $flist = mysqli_query($db_link, $sSQL);
  42. while (list ($d_id, $d_snmp, $d_port, $d_comment, $d_target_id, $d_mac_count, $d_uplink, $d_nagios, $d_skip, $d_vlan) = mysqli_fetch_array($flist)) {
  43. print "<tr align=center>\n";
  44. $cl="data";
  45. if ($d_uplink) { $cl="info"; }
  46. print "<td class=\"$cl\"><a href=\"editport.php?id=$d_id\">" . $d_port . "</a></td>\n";
  47. print "<td class=\"$cl\" >" . $d_snmp . "</td>\n";
  48. print "<td class=\"$cl\" ><button name=\"write\" class=\"j-submit-report\" onclick=\"window.open('portmactable.php?id=" . $d_id . "')\">" . $d_mac_count . "</button></td>\n";
  49. print "<td class=\"$cl\" >" . get_qa($d_uplink) . "</td>\n";
  50. print "<td class=\"$cl\" >" . get_qa($d_nagios) . "</td>\n";
  51. print "<td class=\"$cl\" >" . get_qa($d_skip) . "</td>\n";
  52. print "<td class=\"$cl\">";
  53. if (isset($d_target_id) and $d_target_id > 0) {
  54. print_device_port($db_link, $d_target_id);
  55. } else {
  56. print_auth_port($db_link, $d_id);
  57. }
  58. print "</td>\n";
  59. print "<td class=\"$cl\">" . $d_comment . "</td>\n";
  60. print "<td class=\"$cl\">" . $d_vlan . "</td>\n";
  61. global $torrus_url;
  62. $f_cacti_url = get_cacti_graph($switch['ip'], $d_snmp);
  63. if (! isset($torrus_url) and (! isset($f_cacti_url))) {
  64. print "<td class=\"$cl\"></td>\n";
  65. } else {
  66. if (isset($f_cacti_url)) {
  67. $snmp_url = "<a href=\"$f_cacti_url\">Статистика</a>";
  68. }
  69. if (isset($torrus_url)) {
  70. $normed_ifname = trim(str_replace("/", "_", $ifname));
  71. $normed_ifname = trim(str_replace(".", "_", $normed_ifname));
  72. $normed_ifname = trim(str_replace(" ", "_", $normed_ifname));
  73. $pattern = '/cisco/i';
  74. preg_match($pattern, $switch['device_model'], $matches);
  75. if (isset($matches[0])) {
  76. $normed_ifname = trim(str_replace("Gi", "GigabitEthernet", $normed_ifname));
  77. }
  78. $t_url = str_replace("HOST_IP", $switch['ip'], $torrus_url);
  79. $t_url = str_replace("IF_NAME", $normed_ifname, $t_url);
  80. $snmp_url = "<a href=\"$t_url\">Статистика</a>";
  81. }
  82. print "<td class=\"$cl\">" . $snmp_url . "</td>\n";
  83. }
  84. print "</td>\n";
  85. print "</tr>";
  86. }
  87. print "<tr>\n";
  88. print "<td colspan=6>snmp start</td>\n";
  89. print "<td class=\"data\"><input type=\"text\" name='f_snmp_start' value=1></td>\n";
  90. print "<td><input type=\"submit\" name=\"regensnmp\" value=\"Обновить snmp\"></td>\n";
  91. print "</tr>\n";
  92. print "</table>\n";
  93. ?>
  94. </form>
  95. <?
  96. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.small.php");
  97. ?>