Parcourir la source

Integration json prtg

dorian il y a 10 mois
Parent
commit
90e50e7739
4 fichiers modifiés avec 36 ajouts et 4 suppressions
  1. 3 0
      Cle-API.txt
  2. 28 0
      call-api.php
  3. 1 3
      data_structure.json
  4. 4 1
      prtg.php

+ 3 - 0
Cle-API.txt

@@ -0,0 +1,3 @@
+Clé API PRTG :
+
+J6W7V5ENAJOJAPTVOU7TIBRIUFIL3U7IBCPVS2GGH4======

+ 28 - 0
call-api.php

@@ -0,0 +1,28 @@
+<?php
+require_once 'HTTP/Request2.php';
+$request = new HTTP_Request2();
+$request->setUrl('https://prtg.easytelecoms.fr:1616/api/v2/sensors?offset=0&limit=100&filter=&sort_by=&include_all_channels=true');
+$request->setMethod(HTTP_Request2::METHOD_GET);
+$request->setConfig(array(
+    'follow_redirects' => TRUE,
+    'ssl_verify_peer' => false, 
+    'ssl_verify_host' => false
+));
+$request->setHeader(array(
+  'Accept' => 'application/json',
+  'Authorization' => 'Bearer H57EHLEJBRNAOPH5NRQGKEJRJX4BRTLQ3FVJ7ZAPE4======'
+));
+try {
+  $response = $request->send();
+  if ($response->getStatus() == 200) {
+    echo $response->getBody();
+  }
+  else {
+    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
+    $response->getReasonPhrase();
+  }
+}
+catch(HTTP_Request2_Exception $e) {
+  echo 'Error: ' . $e->getMessage();
+}
+?>

+ 1 - 3
data_structure.json

@@ -10,6 +10,7 @@
         <link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css" rel="stylesheet" />
         <link href="css/styles.css" rel="stylesheet" />
         <script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
+        <?php include_once('api_functions.php'); ?>
     </head>
     <body class="sb-nav-fixed">
     <?php
@@ -48,11 +49,8 @@
 
         $dbconnect->close();
     ?>
-    <iframe src="https://prtg.easytelecoms.fr/group.htm?id=12397&tabid=1#objecttreecontainer" width="600" height="400"></iframe>
-    <iframe src="https://eap.easytelecoms.fr:5001/019719d25d8fc852af63badf8e25413a/login#devices" width="600" height="400"></iframe>
     <a href="index.php">Retour</a>
 
-
         <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
         <script src="js/scripts.js"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>

+ 4 - 1
prtg.php

@@ -39,8 +39,11 @@
                 echo "<p>Type: " . mysqli_fetch_array($dbconnect->query('SELECT name FROM type WHERE id="' . $row['type'] . '"'))['0'] . "</p>";
                 echo "<p>Localisation: {$row['localisation']}</p>";
                 echo "<p>Département: {$row['departement']}</p>";
-                echo "<iframe src='https://prtg.easytelecoms.fr/group.htm?id=12397&tabid=1#objecttreecontainer' width='600' height='400'></iframe>";
+
+                include_once('call-api.php');
+
                 echo "<a href='infos.php?id={$row['id']}'>Retour</a>";
+
             } else {
                 echo "<p>Client non trouvé.</p>";
             }