-
Notifications
You must be signed in to change notification settings - Fork 15
/
onustate.php
49 lines (42 loc) · 1.92 KB
/
onustate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// php onustate.php &
// Initialize a variable into domain name
$domain1 = 'http://rrrr.go.id';
// Function to get HTTP response code
function get_http_response_code($domain1) {
$headers = get_headers($domain1);
return substr($headers[0], 9, 3);
}
// Function call
$get_http_response_code = get_http_response_code($domain1);
// Display the HTTP response code
echo $get_http_response_code;
$connlok = new PDO('mysql:host=xxx;dbname=olt', 'yyy', 'zzz');
$connlok->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$lokasi = snmpwalk("OLT-IP", "community", ".1.3.6.1.4.1.3902.1012.3.28.1.1.3");
$status = snmpwalk("OLT-IP", "community", "ZXGPON-SERVICE-MIB::zxGponOntPhaseState");
$lastonline = snmpwalk("OLT-IP", "community", "ZXGPON-SERVICE-MIB::zxGponOnuLastOnlineTime");
$lastoffline = snmpwalk("OLT-IP", "community", "ZXGPON-SERVICE-MIB::zxGponOnuLastOfflineTime");
$onurx = snmpwalk("OLT-IP", "community", ".1.3.6.1.4.1.3902.1012.3.50.12.1.1.10");
$onutx = snmpwalk("OLT-IP", "community", ".1.3.6.1.4.1.3902.1012.3.50.12.1.1.14");
$sql="INSERT INTO lokasi(`waktu_lokasi`,`lokasi`) VALUES(now(),?)";
$sqlstat="INSERT INTO status(`waktu_status`,`status`) VALUES(now(),?)";
$sqllastonline="INSERT INTO onlineterakhir(`waktu_online`,`lastonline`) VALUES(now(),?)";
$sqllastoffline="INSERT INTO offlineterakhir(`waktu_offline`,`offlineterakhir`) VALUES(now(),?)";
$sqlonu = "INSERT INTO onu(`waktu_query_onu`,`onurx`, `onutx`) VALUES(now(),?,?)";
$stmt = $connlok->prepare($sql);
$stmte = $connlok->prepare($sqlstat);
$stmtee = $connlok->prepare($sqllastonline);
$stmteee = $connlok->prepare($sqllastoffline);
$stmteeee = $connlok->prepare($sqlonu);
while ($get_http_response_code = 200){
for ($i=0;$i<=34;$i++){
$stmt->execute([$lokasi[$i]]);
$stmte->execute([$status[$i]]);
$stmtee->execute([$lastonline[$i]]);
$stmteee->execute([$lastoffline[$i]]);
$stmteeee->execute([$onurx[$i],$onutx[$i]]);
}
sleep(300);
}
?>