-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_ssh.php
112 lines (70 loc) · 2.24 KB
/
test_ssh.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
include('required/vendor/autoload.php');
include('required/snmp/snmp.php');
/////Set session variables////
$needed_stuff = array();
$ip = '192.168.43.11';
$uname = 'pi';
$pass = 'root123';
$snmp = new snmp();
$snmp->version = SNMP_VERSION_2;
$comm = "public";
$errors = array();
/*
$needed_stuffx["filesystem"] = $disk[$i];
$needed_stuffx["size"] = $disk[$i+1];
$needed_stuffx["used"] = $disk[$i+2];
$needed_stuffx["avail"] = $disk[$i+3];
$needed_stuffx["usep"] = $disk[$i+4];
array_push($needed_stuff,$needed_stuffx);
*/
$ssh = new \phpseclib\Net\SSH2($ip);
if (!$ssh->login($uname, $pass )) {
// echo "errors";
array_push($errors, "snmp connection failed");
// echo json_encode($errors);
//exit('Login Failed');
}
$cmd =($snmp->walk($ip, '.1.3.6.1.2.1.1.3',['community' => $comm]));
if(sizeof($cmd)==0)
{ array_push($errors, "snmp connection failed"); }
echo json_encode($errors);
/// for interfaces without IP, get their index and push N/A to array
//echo json_encode($needed_stuff);
//echo json_encode($cmd);
/*
for($i=7; $i<sizeof($disk); $i=$i+6)
{ // array_push($needed_stuff, $disk[$i]);
//array_push($needed_stuff, $disk[$i+1]);
// array_push($needed_stuff, $disk[$i+2]);
// array_push($needed_stuff, $disk[$i+3]);
$needed_stuffx["filesystem"] = $disk[$i];
$needed_stuffx["size"] = $disk[$i+1];
$needed_stuffx["used"] = $disk[$i+2];
$needed_stuffx["avail"] = $disk[$i+3];
$needed_stuffx["usep"] = $disk[$i+4];
array_push($needed_stuff,$needed_stuffx);
}
*/
// echo json_encode($needed_stuff);
/*
for($i=11; $i<(sizeof($disk)); $i=$i+6)
{
array_push($needed_stuff, $disk[$i]);
}
*/
//echo json_encode($needed_stuff);
//$needed_stuff['networking'] = "stopped";
/*
$ip = '192.168.43.111';
$comm = 'public';
$snmp = new snmp();
$snmp->version = SNMP_VERSION_2;
$tswap =($snmp->walk($ip, '1.3.6.1.6.3.10.2.1.3',['community' => $comm]));
print_r($tswap);
$tswap = implode(',' , $tswap);
$tswap = explode(',' , $tswap);
echo sizeof($tswap);
echo json_encode($tswap);
*/
?>