rajven 4 лет назад
Родитель
Сommit
d3285ecc42
2 измененных файлов с 31 добавлено и 4 удалено
  1. 16 4
      html/admin/iplist/nagios.php
  2. 15 0
      html/inc/common.php

+ 16 - 4
html/admin/iplist/nagios.php

@@ -95,6 +95,8 @@ foreach ($users as $user) {
     $cl = "data";
     if ($user['nagios_status'] == "UP") { $cl = "up"; }
     if ($user['nagios_status'] == "DOWN") { $cl = "down"; }
+    if (!$user['nagios']) { $cl = "data"; }
+
     print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['login'] . "</a></td>\n";
     print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
     print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
@@ -116,8 +118,17 @@ foreach ($users as $user) {
         } else {
         print "<td class=\"$cl\" ></td>\n";
         }
-    
-    print "<td class=\"$cl\" >" . get_qa($user['nagios']) . "</td>\n";
+
+    if (!empty($user['nagios']) and $user['nagios']) {
+        $nagios_url = rtrim(get_option($db_link, 57),'/');
+        if (preg_match('/127.0.0.1/', $nagios_url)) { print "<td class=\"$cl\" >". get_qa($user['nagios']) ."</td>\n"; } else {
+            $nagios_link = $nagios_url.'/cgi-bin/status.cgi?host='.get_nagios_name($user);
+            print "<td class=\"$cl\" >"; print_url(get_qa($user['nagios']),$nagios_link); print "</td>\n";
+            }
+        } else {
+        print "<td class=\"$cl\" >" . get_qa($user['nagios']) . "</td>\n";
+        }
+
     print "<td class=\"$cl\" >" . get_qa($user['link_check']) . "</td>\n";
     print "<td class=\"$cl\" >".$user['nagios_handler']."</td>\n";
     print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
@@ -131,8 +142,9 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <table class="data">
 <tr><td>Цветовая маркировка</td></tr>
 <tr>
-<td class="warn">Пользователь выключен</td>
-<td class="error">Блокировка по трафику</td>
+<td class="up">Хост включен</td>
+<td class="down">Хост недоступен</td>
+<td class="data">Неизвестно</td>
 </table>
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");

+ 15 - 0
html/inc/common.php

@@ -579,6 +579,21 @@ print_submenu_url('Удалённые адреса','/admin/iplist/deleted.php',
 print "</div>\n";
 }
 
+function get_nagios_name ($auth)
+{
+if (!empty($auth['dns_name'])) { return $auth['dns_name']; }
+if (!empty($auth['dhcp_hostname'])) { return $auth['dhcp_hostname']; }
+if (!empty($auth['comments'])) {
+    $result = transliterate($auth['comments']);
+    $result = preg_replace('/\(/', '-', $result);
+    $result = preg_replace('/\)/', '-', $result);
+    $result = preg_replace('/--/', '-', $result);
+    return $result;
+    }
+if (empty($auth['login'])) { $auth['login']='host'; }
+return $auth['login']."_".$auth['id'];
+}
+
 function get_ou($db, $ou_value)
 {
     if (!isset($ou_value)) { return; }