-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnodetypes
executable file
·104 lines (88 loc) · 2.79 KB
/
nodetypes
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
#!/usr/bin/env perl
# Uses hostname regexes from JSV and properties from qhost to list node types and properties
##
require "/opt/geassist/etc/jsv/Jsvnode.pm";
our %types = %Jsvnode::types;
# Because these aren't covered in the JSV
$types{"*"} = { "match" => "^(login[0-9]+|nfs-|util[0-9]+)" };
our $nodeclass;
our $hostname;
our %counting_types;
our %matches;
if ($ARGV[0] == "") {
$ARGV[0] = "qhost |";
} else {
$ARGV[0] = "qhost -h $ARGV[0] |";
}
while (<>) {
if ($_ =~ m/ - /) {
next;
}
# Sample line:
# HOSTNAME ARCH NCPU NSOC NCOR NTHR LOAD MEMTOT MEMUSE SWAPTO SWAPUS
# ----------------------------------------------------------------------------------------------
# node-z00a-012 lx-amd64 12 2 12 12 27.01 47.0G 3.2G 128.0G 1.4G
if ($_ !~ m/^[ \t]*
(?<host>[^ \t]+) [ \t]+
(?<arch>[^ \t]+) [ \t]+
(?<cpus>[^ \t]+) [ \t]+
(?<sockets>[^ \t]+) [ \t]+
(?<cores>[^ \t]+) [ \t]+
(?<threads>[^ \t]+) [ \t]+
(?<load>[^ \t]+) [ \t]+
(?<ram_total>[^ \t]+) [ \t]+
(?<ram_used>[^ \t]+) [ \t]+
(?<swap_total>[^ \t]+) [ \t]+
(?<swap_used>[^ \t]+) [ \t]*$/x) {
next;
} else {
if ($1 eq "HOSTNAME") {
next;
}
%matches = (
"host" => $+{host},
"arch" => $+{arch},
"cpus" => $+{cpus},
"sockets" => $+{sockets},
"cores" => $+{cores},
"threads" => $+{threads},
"load" => $+{load},
"ram_total" => $+{ram_total},
"ram_used" => $+{ram_used},
"swap_total" => $+{swap_total},
"swap_used" => $+{swap_used},
);
# print "Host: ".$matches{"host"}." Arch:".$matches{'arch'}."\n";
my $type;
my $this_node_type;
foreach $type (keys %types) {
if ($matches{"host"} =~ m/$types{$type}{'match'}/) {
$this_node_type = $type;
#print $matches{"host"}.": $type\n";
break;
}
}
if ($this_node_type eq "") {
print "Unknown node type: ".$matches{"host"}."\n";
next;
}
my $node_key = $this_node_type."_".$matches{"cores"}."_".$matches{"ram_total"};
if (not defined($counting_types{$node_key})) {
$counting_types{$node_key} = {
"class_name" => $this_node_type,
"cores" => $matches{"cores"},
"ram_total" => $matches{"ram_total"},
"number" => 1
};
} else {
$counting_types{$node_key}{"number"} = $counting_types{$node_key}{"number"} + 1;
}
}
}
foreach $type (sort keys %counting_types) {
printf "%5d type %1s nodes: %2d cores, %6s RAM\n",
$counting_types{$type}{"number"},
$counting_types{$type}{"class_name"},
$counting_types{$type}{"cores"},
$counting_types{$type}{"ram_total"};
}