-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
113 lines (103 loc) · 3.78 KB
/
main.go
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
113
// Cisco DNA Center ISE Health Check Console Script.
//
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// This software is licensed to you under the terms of the Cisco Sample
// Code License, Version 1.1 (the "License"). You may obtain a copy of the
// License at
//
// https://developer.cisco.com/docs/licenses
//
// All use of the material herein must be in accordance with the terms of
// the License. All rights not expressly granted by the License are
// reserved. Unless required by applicable law or agreed to separately in
// writing, software distributed under the License is distributed on an "AS
// IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied.
//
// __author__ = "Robert Csapo"
// __email__ = "rcsapo@cisco.com"
// __version__ = "0.1"
// __copyright__ = "Copyright (c) 2019 Cisco and/or its affiliates."
// __license__ = "Cisco Sample Code License, Version 1.1"
package main
import (
"log"
"net"
"flag"
"fmt"
)
// Cisco ISE Settings Struct
type iseStruct struct {
Host string
Proto string
sshPort string
webPort string
ersPort string
pxGridInterPort string
pxGridSubPort string
}
// Create a var based of ISE Struct
var ise iseStruct
// Connection Test function
func connectTest(host,port,proto string) string {
host = host+":"+port
var status string
conn, err := net.Dial(proto, host)
if err != nil {
log.Println("ERROR:\t\t", err)
status = "Unreachable"
} else {
status = "Online"
defer conn.Close()
}
return(status)
}
// Main function
func main() {
flagHost := flag.String("host", "", "cisco ise hostname/ip-address")
flag.Parse()
if (*flagHost != "") {
// set ISE host if flag is used
ise.Host = string(*flagHost)
} else {
// get ISE host from input, as flag is missing
fmt.Print("Enter host (FQDN): ")
var host string
fmt.Scanln(&host)
ise.Host = host
}
ise.Proto = "tcp"
ise.sshPort = "22"
ise.webPort = "443"
ise.ersPort = "9060"
ise.pxGridInterPort = "5222"
ise.pxGridSubPort = "8910"
// Reference
// https://www.cisco.com/c/en/us/td/docs/security/ise/2-6/install_guide/b_ise_InstallationGuide_26/b_ise_InstallationGuide_26_chapter_0110.html
if (connectTest(ise.Host, ise.sshPort, ise.Proto) == "Online") {
log.Println("SUCCESS:\t\tCisco ISE ("+ise.Host+") - SSH port ("+ise.sshPort+") is accessible")
} else {
log.Println("ERROR:\t\tCisco ISE ("+ise.Host+") - SSH port ("+ise.sshPort+") is NOT accessible")
}
if (connectTest(ise.Host, ise.webPort, ise.Proto) == "Online") {
log.Println("SUCCESS:\t\tCisco ISE ("+ise.Host+") - Web port ("+ise.webPort+") is accessible")
} else {
log.Println("ERROR:\t\tCisco ISE ("+ise.Host+") - Web port ("+ise.webPort+") is NOT accessible")
}
if (connectTest(ise.Host, ise.ersPort, ise.Proto) == "Online") {
log.Println("SUCCESS:\t\tCisco ISE ("+ise.Host+") - ERS API port ("+ise.ersPort+") is accessible")
} else {
log.Println("ERROR:\t\tCisco ISE ("+ise.Host+") - ERS API port ("+ise.ersPort+") is NOT accessible")
}
if (connectTest(ise.Host, ise.pxGridInterPort, ise.Proto) == "Online") {
log.Println("SUCCESS:\t\tCisco ISE ("+ise.Host+") - pxGrid Inter-Node Communication port ("+ise.pxGridInterPort+") is accessible")
} else {
log.Println("ERROR:\t\tCisco ISE ("+ise.Host+") - pxGrid Inter-Node Communication port ("+ise.pxGridInterPort+") is NOT accessible")
}
if (connectTest(ise.Host, ise.pxGridSubPort, ise.Proto) == "Online") {
log.Println("SUCCESS:\t\tCisco ISE ("+ise.Host+") - pxGrid Subscribers port ("+ise.pxGridSubPort+") is accessible")
} else {
log.Println("ERROR:\t\tCisco ISE ("+ise.Host+") - pxGrid Subscribers port ("+ise.pxGridSubPort+") is NOT accessible")
}
}