-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathget_processes.go
More file actions
executable file
·56 lines (48 loc) · 2.01 KB
/
get_processes.go
File metadata and controls
executable file
·56 lines (48 loc) · 2.01 KB
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
//This script can be run using NetBackup 8.2 and higher.
//It gets all NetBackup processes running on the given host.
package main
import (
"flag"
"fmt"
"log"
"os"
"apihelper"
)
//###################
// Global Variables
//###################
var (
nbmaster = flag.String("nbmaster", "", "NetBackup Master Server")
username = flag.String("username", "", "User name to log into the NetBackup webservices")
password = flag.String("password", "", "Password for the given user")
domainName = flag.String("domainName", "", "Domain name of the given user")
domainType = flag.String("domainType", "", "Domain type of the given user")
client = flag.String("client", "", "NetBackup host name")
)
const usage = "\n\nUsage: go run ./get_processes.go -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>] -client <client>\n\n"
func main() {
// Print usage
flag.Usage = func() {
fmt.Fprintf(os.Stderr, usage)
os.Exit(1)
}
// Read command line arguments
flag.Parse()
if len(*nbmaster) == 0 {
log.Fatalf("Please specify the name of the NetBackup Master Server using the -nbmaster parameter.\n")
}
if len(*username) == 0 {
log.Fatalf("Please specify the username using the -username parameter.\n")
}
if len(*password) == 0 {
log.Fatalf("Please specify the password using the -password parameter.\n")
}
if len(*client) == 0 {
log.Fatalf("Please specify the name of a NetBackup host using the -client parameter.\n")
}
httpClient := apihelper.GetHTTPClient()
jwt := apihelper.Login(*nbmaster, httpClient, *username, *password, *domainName, *domainType)
hostUuid := apihelper.GetHostUUID(*nbmaster, httpClient, jwt, *client);
filter := "";
apihelper.GetProcesses(*nbmaster, httpClient, jwt, *client, hostUuid, filter);
}