nagios.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. $default_displayed=500;
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  6. $default_sort='ip_int';
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  8. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/subnetfilter.php");
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  10. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
  12. $sort_table = 'user_auth';
  13. if ($sort_field == 'login') { $sort_table = 'user_list'; }
  14. if ($sort_field == 'fio') { $sort_table = 'user_list'; }
  15. $sort_url = "<a href=nagios.php?ou=" . $rou;
  16. if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and user_list.ou_id=$rou "; }
  17. if ($rsubnet == 0) { $subnet_filter = ''; } else {
  18. $subnet_range = get_subnet_range($db_link,$rsubnet);
  19. if (!empty($subnet_range)) { $subnet_filter = " and user_auth.ip_int>=".$subnet_range['start']." and user_auth.ip_int<=".$subnet_range['stop']; }
  20. }
  21. $enabled_filter='';
  22. if ($enabled>0) {
  23. if ($enabled===2) { $enabled_filter = ' and user_auth.nagios=1'; }
  24. if ($enabled===1) { $enabled_filter = ' and user_auth.nagios=0'; }
  25. }
  26. $ip_list_filter = $ou_filter.$subnet_filter.$enabled_filter;
  27. print_ip_submenu($page_url);
  28. ?>
  29. <div id="cont">
  30. <form name="filter" action="nagios.php" method="post">
  31. <table class="data">
  32. <tr>
  33. <td>
  34. <b><?php print WEB_cell_ou; ?> :</b><?php print_ou_select($db_link, 'ou', $rou); ?>
  35. <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?>
  36. <b><?php print WEB_nagios; ?> :</b><?php print_enabled_select('enabled', $enabled); ?>
  37. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  38. <input id="btn_filter" name="btn_filter" type="submit" value="<?php print WEB_btn_show; ?>">
  39. </td>
  40. </tr>
  41. </table>
  42. </form>
  43. <a class="mainButton" href="#modal"><?php print WEB_btn_apply_selected; ?></a>
  44. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  45. <div class="remodalBorder">
  46. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  47. <form id="formAuthApply">
  48. <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
  49. <input type="hidden" name="ApplyForAll" value="MassChange">
  50. <table class="data" align=center>
  51. <tr><td><input type=checkbox class="putField" name="e_nag_enabled" value='1'></td><td>Nagios&nbsp<?php print_qa_select('n_enabled', 1); ?></td></tr>
  52. <tr><td><input type=checkbox class="putField" name="e_nag_link" value='1'></td><td>Link&nbsp<?php print_qa_select('n_link', 0); ?></td></tr>
  53. <tr><td><input type=checkbox class="putField" name="e_nag_handler" value='1'></td><td>Event-handler&nbsp<?php print_nagios_handler_select($db_link,'n_handler', ''); ?></td></tr>
  54. </table>
  55. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  56. </form>
  57. </div>
  58. </div>
  59. <?php
  60. $countSQL="SELECT Count(*) FROM user_auth, user_list WHERE user_auth.user_id = user_list.id AND user_auth.deleted =0 $ip_list_filter";
  61. $count_records = get_single_field($db_link,$countSQL);
  62. $total=ceil($count_records/$displayed);
  63. if ($page>$total) { $page=$total; }
  64. if ($page<1) { $page=1; }
  65. $start = ($page * $displayed) - $displayed;
  66. print_navigation($page_url,$page,$displayed,$count_records,$total);
  67. ?>
  68. <br>
  69. <form id="def" name="def">
  70. <table class="data">
  71. <tr>
  72. <td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
  73. <td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
  74. <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
  75. <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
  76. <td align=Center><?php print WEB_cell_description; ?></td>
  77. <td align=Center><?php print WEB_cell_wikiname; ?></td>
  78. <td align=Center><?php print $sort_url . "&sort=nagios&order=$new_order>" . WEB_cell_nagios; ?></td>
  79. <td align=Center><?php print $sort_url . "&sort=link_check&order=$new_order>" . WEB_cell_link; ?></td>
  80. <td align=Center><?php print WEB_cell_nagios_handler; ?></td>
  81. <td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>Last</a>"; ?></td>
  82. <td align=Center><?php print WEB_cell_connection; ?></td>
  83. </tr>
  84. <?php
  85. $sSQL = "SELECT user_auth.*, user_list.login FROM user_auth, user_list
  86. WHERE user_auth.user_id = user_list.id AND user_auth.deleted =0 $ip_list_filter
  87. ORDER BY $sort_table.$sort_field $order LIMIT $displayed OFFSET $start";
  88. $users = get_records_sql($db_link,$sSQL);
  89. foreach ($users as $user) {
  90. if ($user['dhcp_time'] == '0000-00-00 00:00:00') {
  91. $dhcp_str = '';
  92. } else {
  93. $dhcp_str = $user['dhcp_time'] . " (" . $user['dhcp_action'] . ")";
  94. }
  95. if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  96. print "<tr align=center>\n";
  97. $cl = "data";
  98. if ($user['nagios_status'] == "UP") { $cl = "up"; }
  99. if ($user['nagios_status'] == "DOWN") { $cl = "down"; }
  100. if (!$user['nagios']) { $cl = "data"; }
  101. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$user['id']."></td>\n";
  102. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['login'] . "</a></td>\n";
  103. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  104. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  105. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  106. print "<td class=\"$cl\" width=200>".$user['description']." [" . $user['dhcp_hostname'] . "]</td>\n";
  107. } else {
  108. print "<td class=\"$cl\" width=200>".$user['description']."</td>\n";
  109. }
  110. if (!empty($user['WikiName'])) {
  111. $wiki_url = rtrim(get_option($db_link, 60),'/');
  112. if (preg_match('/127.0.0.1/', $wiki_url)) { print "<td class=\"$cl\" ></td>\n"; } else {
  113. $wiki_web = rtrim(get_option($db_link, 63),'/');
  114. $wiki_web = ltrim($wiki_web,'/');
  115. $wiki_link = $wiki_url.'/'.$wiki_web.'/'.$user['WikiName'];
  116. print "<td class=\"$cl\" >"; print_url($user['WikiName'],$wiki_link); print "</td>\n";
  117. }
  118. } else {
  119. print "<td class=\"$cl\" ></td>\n";
  120. }
  121. if (!empty($user['nagios']) and $user['nagios']) {
  122. if (preg_match('/127.0.0.1/', get_const('nagios_url'))) { print "<td class=\"$cl\" >". get_qa($user['nagios']) ."</td>\n"; } else {
  123. $nagios_link = get_const('nagios_url').'status.cgi?host='.get_nagios_name($user);
  124. print "<td class=\"$cl\" >"; print_url(get_qa($user['nagios']),$nagios_link); print "</td>\n";
  125. }
  126. } else {
  127. print_td_qa($user['nagios'],FALSE,$cl);
  128. }
  129. print_td_qa($user['link_check'],FALSE,$cl);
  130. print "<td class=\"$cl\" >".$user['nagios_handler']."</td>\n";
  131. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  132. print "<td class=\"$cl\" >" . get_connection($db_link, $user['id']) . "</td>\n";
  133. print "</tr>\n";
  134. }
  135. print "</table>\n";
  136. print_navigation($page_url,$page,$displayed,$count_records,$total);
  137. ?>
  138. <br>
  139. <table class="data">
  140. <tr><td><?php echo WEB_color_description; ?></td></tr>
  141. <tr>
  142. <td class="up"><?php echo WEB_nagios_host_up; ?></td>
  143. <td class="down"><?php echo WEB_nagios_host_down; ?></td>
  144. <td class="data"><?php echo WEB_nagios_host_unknown; ?></td>
  145. </table>
  146. <script src="/js/remodal/remodal.min.js"></script>
  147. <script src="/js/remodal-auth.js"></script>
  148. <script>
  149. document.getElementById('ou').addEventListener('change', function(event) {
  150. const buttonApply = document.getElementById('btn_filter');
  151. buttonApply.click();
  152. });
  153. document.getElementById('subnet').addEventListener('change', function(event) {
  154. const buttonApply = document.getElementById('btn_filter');
  155. buttonApply.click();
  156. });
  157. document.getElementById('enabled').addEventListener('change', function(event) {
  158. const buttonApply = document.getElementById('btn_filter');
  159. buttonApply.click();
  160. });
  161. document.getElementById('rows').addEventListener('change', function(event) {
  162. const buttonApply = document.getElementById('btn_filter');
  163. buttonApply.click();
  164. });
  165. </script>
  166. <?php
  167. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
  168. ?>