Advertisement
fagervan

fix no interface in icmp item. Zabbix 6.4.

Mar 29th, 2023
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | Fixit | 0 0
  1. <?php
  2. // fix no interface in icmp item. Zabbix 6.4.   (c) fg
  3.  
  4. $mysqli = new mysqli('127.0.0.1', 'dbuser', 'dbpass', 'zabbix');
  5. if ($mysqli->connect_errno) {
  6.     echo "Errno: " . $mysqli->connect_errno . "\n";
  7.     echo "Error: " . $mysqli->connect_error . "\n";
  8.     die;
  9. }
  10.  
  11. echo "<pre>";
  12. $sql="select * from items where key_ like \"icmp%\" ";
  13. echo "$sql \n";
  14.  
  15. $rs = $mysqli->query($sql);
  16. echo mysqli_error($mysqli);
  17.  
  18. foreach($rs as $row) {
  19. //    print_r($row);
  20.     $itemid=$row['itemid'];
  21.     $hostid=$row['hostid'];
  22.     $interfaceid=$row['interfaceid'];
  23.     echo "$hostid - $interfaceid ";
  24.     if ($interfaceid=='') {
  25.         echo "error";
  26.         // busca tabla interface
  27.         $sql="select interfaceid,ip from interface where hostid='$hostid' limit 1";
  28.         echo "\n$sql \n";
  29.         $rs1 = $mysqli->query($sql);
  30.         echo mysqli_error($mysqli);
  31.         $row1=mysqli_fetch_assoc($rs1);
  32.         print_r($row1);
  33.         $interfaceid=$row1['interfaceid'];
  34.  
  35.         if ($interfaceid>0) {
  36.             $sql="update items set interfaceid='$interfaceid' where itemid='$itemid' limit 1";
  37.             echo "$sql\n";
  38.             $rs2 = $mysqli->query($sql);
  39.             echo mysqli_error($mysqli);
  40.             echo mysqli_affected_rows($mysqli);
  41.         }
  42.     }
  43.     echo "<hr>";
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement