-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckPort.php
78 lines (61 loc) · 1.49 KB
/
checkPort.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
<?php
require 'sites.php';
# List of the most important services on localhost
$PORTS = array (
'FTP' => '21',
'SMTP' => '25',
'DNS' => '53',
'POP3' => '110',
'SMTPS' => '465',
'IMAP' => '143',
'IMAPS' => '993',
'POP3S' => '995',
'MySQL' => '3306',
'REDIS' => '6379',
'PLESK' => '8443'
);
if ($interface == 'cli') {
if (isset($argv[1]) AND in_array($argv[1],$PORTS)) {
$port = $argv[1];
$service = array_search($port, $PORTS);
$check = exec("netstat -lnt|grep -w $port");
$string = $service."state";
/*
Output to Solar Winds
*/
if ($check != "") {
echo "Statistic.$string:1 \n";
}
else {
echo "Statistic.$string:0 \n";
}
}
else {
echo "Usage: php checkPorts.php port\n
Port need to specify like a num\n
Permit a next arguments:\n
- 21 (ftp)\n
- 25 (smtp)\n
- 53 (dns)\n
- 110 (pop3)\n
- 465 (smtp-ssl)\n
- 143 (imap)\n
- 993 (imap-ssl)\n
- 995 (pop3-ssl)\n
- 3306 (Mysql)\n
- 6379 (redis image)\n
- 8443 (Plesk panel)\n\n";
}
}
else {
header("cache-control: no-cache, must-revalidate, max-age=0");
echo "<b>$script</b> - in http mode provide a summary info about all TCP service ports.<br><pre>\n";
foreach ($PORTS as $service => $port) {
echo "$service state: \n";
passthru("netstat -ltn|grep -w $port");
echo "---\n";
}
echo "</pre>";
require 'footer.php';
}
?>