Skip to content

Commit

Permalink
Change icon in Resource_Info
Browse files Browse the repository at this point in the history
  • Loading branch information
mnakao committed Apr 27, 2024
1 parent fb62070 commit dac257a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
23 changes: 20 additions & 3 deletions Resource_Info/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ def get_update_time()
return File.read(ACC_DIR + "date.txt")
end

def check_admin(group)
cmd = "resourcemod -g #{group}"
o = (Socket.gethostname == "fn06sv04")? `cmd` : `ssh login #{cmd}`
return (o != "You have no authority to execute the tool.\n")
end

def output()
@is_admin = []
@resource_info = []
@groups = `groups`.split.reject { |e| e.start_with?("isv") } - ["fugaku"]
month = Time.now.month
Expand Down Expand Up @@ -51,7 +58,7 @@ def output()
avail = (defined_limit[user] == "unlimited")? dashboard_resource(g).avail : limit - usage
tmp.push([user, limit, usage, avail])
end

# Add Exclusive use
if File.exist?(resource_file)
sum = 0
Expand All @@ -70,6 +77,7 @@ def output()
end

@resource_info.push(tmp)
@is_admin.push(check_admin(g))
else
unused_groups.push(g)
end # if File.exist?(period_file)
Expand All @@ -89,8 +97,17 @@ def output()
post '/' do
group = params['group']
user = params['user']
voule_s = params['volume_NH'] * 3600
`resourcemod -g #{group} -u #{user} -resource #{voule_s}`
voule_s = params['volume_NH'].to_i * 3600

cmd = "resourcemod -g #{group} -u #{user}"
cmd += " -resource #{voule_s}" if params['limit'] != params['volume_NH']
(Socket.gethostname == "fn06sv04")? system(cmd) : system("ssh login #{cmd}")

# Rewrite resource.csv
resource_file = ACC_GROUP_DIR + group + "/resource.csv"
cmd = "accountj -g #{group} -c -r 1 -e -E | tr -d '\"' | egrep '^SUBTHEME|^SUBTHEMEPERIOD|^EXCLUSIVEUSE|^RESOURCE_GROUP|^USER' | egrep -v '^USER_' > #{resource_file}"
(Socket.gethostname == "fn06sv04")? system(cmd) : system("ssh login #{cmd}")

output()
# Render the view
erb :index
Expand Down
2 changes: 1 addition & 1 deletion Resource_Info/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Resource Info
description: Resource usage of users by group.
icon: fa://dollar
icon: fa://clipboard
#category: Files
#subcategory: Utilities
category: Passenger Apps
Expand Down
14 changes: 11 additions & 3 deletions Resource_Info/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ input {
outline: solid 1px #FFDBC9;
}
</style>

<h1><%= title %> <font size="3">(Updated at <%= get_update_time() %>)</font></h1>
<p>
<font size="5">Resource usage for each user by group.</font>
Expand All @@ -35,7 +36,9 @@ input {
<tr>
<th style="vertical-align: middle;" rowspan="2">User</th>
<th colspan="4">Resource (NH)</th>
<th style="vertical-align: middle;" rowspan="2">Change Limit</th>
<% if @is_admin[i] %>
<th width="250px" style="vertical-align: middle;" rowspan="2">Change Limit</th>
<% end %>
</tr>
<tr>
<th>Limit</th>
Expand Down Expand Up @@ -63,21 +66,26 @@ input {
<strong class="bar_<%= dashboard_color(ratio(usage, limit)) %>" style="width: <%= ratio(usage, limit, 100) %>%;"><%= ratio(usage, limit) %>%</strong>
</div>
</td>
<% if @is_admin[i] %>
<td>
<form action="" method="post">
<input type="hidden" name="group" value="<%= g %>" required>
<input type="hidden" name="user" value="<%= user %>" required>
<input type="hidden" name="limit" value="<%= limit %>" required>
<input type="hidden" name="group" value="<%= g %>" required>
<input type="hidden" name="user" value="<%= user %>" required>
<input type="number" name="volume_NH" max="<%= get_resource_limit(g).to_i %>" min="0" value="<%= limit %>" required>
<input type="submit" value="submit">
</form>
</td>
<% end %>
<% else %>
<td> - </td>
<td> - </td>
<td> - </td>
<td> - </td>
<% if @is_admin[i] %>
<td> - </td>
<% end %>
<% end %>
</tr>
<% end %>
</table>
Expand Down
2 changes: 1 addition & 1 deletion misc/accounting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mkdir -p ${GROUP_DIR} ${HOME_DIR}
rm ${LOCKFILE} ${GROUP_TMP}
exit 1
fi
chmod 640 ${FILE}
chmod 660 ${FILE}
chown root:${II} ${FILE}
} &

Expand Down

0 comments on commit dac257a

Please sign in to comment.