Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pbsAccounting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio Roberto Vitello
pbsAccounting
Commits
7ebb43c9
Commit
7ebb43c9
authored
7 years ago
by
Fabio Roberto Vitello
Browse files
Options
Downloads
Patches
Plain Diff
bug fix on memory accounting
parent
28708394
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
main.cpp
+12
-3
12 additions, 3 deletions
main.cpp
main.h
+1
-1
1 addition, 1 deletion
main.h
print.cpp
+24
-11
24 additions, 11 deletions
print.cpp
read.cpp
+23
-7
23 additions, 7 deletions
read.cpp
with
60 additions
and
22 deletions
main.cpp
+
12
−
3
View file @
7ebb43c9
...
...
@@ -20,6 +20,11 @@
* -h : help
*/
// Created by Fabio Roberto Vitello on 16/06/17.
// Copyright © 2017 Fabio Roberto Vitello. All rights reserved.
//
#include
<cstdlib>
#include
<stdio.h>
#include
<string.h>
...
...
@@ -29,7 +34,7 @@
/* global variables */
GROUP
*
pgroups
;
USER
*
pusers
;
int
f_user
=
0
,
f_group
=
0
,
f_bill
=
0
,
f_stat
=
0
,
f_cpu
=
0
,
f_stdin
=
0
,
opt
=
1
,
memorypernode
;
int
f_user
=
0
,
f_group
=
0
,
f_bill
=
0
,
f_stat
=
0
,
f_cpu
=
0
,
f_stdin
=
0
,
opt
=
1
,
memorypernode
,
noverbose
=
0
;
char
unit
[
4
]
=
{
"SBU"
};
double
value
;
int
cpuvalue
;
...
...
@@ -45,7 +50,7 @@ void usage_exit(void)
void
help
()
{
puts
(
"pbsacct: program to make summary and report for PBS system."
);
puts
(
"usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-m value][-c][-s][-h] [file(s)]"
);
puts
(
"usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-m value][-
z][-
c][-s][-h] [file(s)]"
);
puts
(
"
\t
options:"
);
puts
(
"
\t
-a : report per-user and per-group usage"
);
puts
(
"
\t
-u : report per-user usage"
);
...
...
@@ -63,6 +68,7 @@ void help()
puts
(
"
\t
-s : include statistic information"
);
puts
(
"
\t
-p Custom Option added by Fabio Vitello: set the number of core to compute the to compute cputime in case of exclusive node request"
);
puts
(
"
\t
-m Custom Option added by Fabio Vitello: set the memory per node in GB"
);
puts
(
"
\t
-z Custom Option added by Fabio Vitello: no verbose"
);
puts
(
"
\t
-h : help"
);
puts
(
"
\t
If there isn't input file, it use the stdin.
\n
"
);
puts
(
"
\t
Examples:"
);
...
...
@@ -87,7 +93,7 @@ void parse_args(int ac, char **av)
f_cpu = 1;
*/
while
((
options
=
getopt
(
ac
,
av
,
"augb:B:np:m:sch"
))
!=
EOF
)
while
((
options
=
getopt
(
ac
,
av
,
"augb:B:np:m:
z
sch"
))
!=
EOF
)
switch
(
options
)
{
case
'a'
:
f_user
=
f_group
=
1
;
...
...
@@ -120,6 +126,9 @@ void parse_args(int ac, char **av)
case
'm'
:
memorypernode
=
atoi
(
optarg
);
break
;
case
'z'
:
noverbose
=
1
;
break
;
case
'h'
:
help
();
break
;
...
...
This diff is collapsed.
Click to expand it.
main.h
+
1
−
1
View file @
7ebb43c9
...
...
@@ -47,7 +47,7 @@ struct user {
/* global variables */
extern
GROUP
*
pgroups
;
extern
USER
*
pusers
;
extern
int
f_user
,
f_group
,
f_bill
,
f_stat
,
f_cpu
,
f_stdin
,
opt
;
extern
int
f_user
,
f_group
,
f_bill
,
f_stat
,
f_cpu
,
f_stdin
,
opt
,
noverbose
;
extern
char
unit
[
4
];
extern
double
value
;
extern
int
cpuvalue
;
...
...
This diff is collapsed.
Click to expand it.
print.cpp
+
24
−
11
View file @
7ebb43c9
...
...
@@ -21,9 +21,11 @@ void print_report(char *hostname)
USER
*
pu
;
double
total
;
printf
(
"
\n
*** Portable Batch System accounting ***
\n
"
);
printf
(
"Server Name: %s
\n
"
,
hostname
);
if
(
!
noverbose
)
{
printf
(
"
\n
*** Portable Batch System accounting ***
\n
"
);
printf
(
"Server Name: %s
\n
"
,
hostname
);
}
f_cpu
=
false
;
f_stat
=
false
;
/* print report user */
...
...
@@ -86,23 +88,33 @@ void print_report(char *hostname)
/* print report group */
if
(
f_group
)
{
printf
(
"
\n
*** PBS Per-Group Usage Report ***
\n
"
);
printf
(
"Group #Jobs Wall(h)"
);
if
(
f_cpu
)
{
if
(
!
noverbose
)
{
printf
(
"
\n
*** PBS Per-Group Usage Report ***
\n
"
);
printf
(
"Group #Jobs Wall(h)"
);
}
if
(
f_cpu
&&
!
noverbose
)
{
printf
(
" CPU(h)"
);
if
(
f_stat
)
printf
(
" Efcy(%)"
);
}
if
(
f_stat
)
{
if
(
f_stat
&&
!
noverbose
)
{
printf
(
" Av.Wall(h)"
);
if
(
f_cpu
)
printf
(
" Av.CPU(h)"
);
printf
(
" Av.#CPU"
);
}
printf
(
" Sum Wall(h)"
);
if
(
f_cpu
)
printf
(
" Sum CPU(h)"
);
if
(
f_bill
)
printf
(
"%14s"
,
unit
);
printf
(
"
\n
"
);
if
(
!
noverbose
)
printf
(
" Sum Wall(h)"
);
if
(
f_cpu
&&
!
noverbose
)
printf
(
" Sum CPU(h)"
);
if
(
f_bill
&&
!
noverbose
)
printf
(
"%14s"
,
unit
);
if
(
!
noverbose
)
printf
(
"
\n
"
);
pg
=
pgroups
;
while
(
pg
!=
NULL
){
if
(
noverbose
)
{
printf
(
"%-9s "
,
pg
->
groupname
);
printf
(
" %13.4f"
,(
pg
->
all_wall_time
/
60
));
}
else
{
printf
(
"%-9s %5d %10.4f"
,
pg
->
groupname
,
pg
->
num_jobs
,(
pg
->
wall_time
/
60
));
if
(
f_cpu
)
{
...
...
@@ -133,6 +145,7 @@ void print_report(char *hostname)
}
printf
(
"%14.2f"
,
total
);
}
}
printf
(
"
\n
"
);
pg
=
pg
->
p_next
;
}
...
...
This diff is collapsed.
Click to expand it.
read.cpp
+
23
−
7
View file @
7ebb43c9
...
...
@@ -24,7 +24,7 @@
/* read file(s) */
void
read_file
(
char
*
file
)
{
int
len
,
nodes
,
hour
,
min
,
sec
,
test
,
linenum
=
0
,
reqmemory
,
corememory
;
int
len
,
nodes
,
cpu
,
hour
,
min
,
sec
,
test
,
linenum
=
0
,
reqmemory
,
corememory
=
0
;
double
cpu_used
,
wall_used
,
memorypercore
;
char
buffer
[
BUFSIZ
],
*
p
,
*
ptr
,
*
line
;
char
uid
[
MAX_NAME_SIZE
],
gid
[
MAX_NAME_SIZE
];
...
...
@@ -64,8 +64,8 @@ void read_file(char *file)
p
[
strlen
(
p
)
-
2
]
=
0
;
reqmemory
=
atoi
(
p
);
corememory
=
floor
((
float
)
reqmemory
/
((
float
)
memorypernode
/
cpuvalue
));
if
(
corememory
>
cpuvalue
)
corememory
=
cpuvalue
;
//
if (corememory>cpuvalue)
//
corememory=cpuvalue;
}
// nodes = atoi(p);
}
...
...
@@ -82,16 +82,29 @@ void read_file(char *file)
if
(
ptr
!=
NULL
)
{
p
=
strtok
(
ptr
,
"="
);
p
=
strtok
(
NULL
,
"="
);
nodes
=
atoi
(
p
);
cpu
=
atoi
(
p
);
if
(
corememory
>
nodes
)
nodes
=
corememory
;
strcpy
(
line
,
buffer
);
ptr
=
strstr
(
line
,
"Resource_List.nodect"
);
p
=
strtok
(
ptr
,
"="
);
p
=
strtok
(
NULL
,
"="
);
nodes
*=
atoi
(
p
);
nodes
=
atoi
(
p
);
corememory
=
corememory
/
nodes
;
if
(
corememory
>
cpuvalue
)
corememory
=
cpuvalue
;
if
(
corememory
>
(
cpu
/
nodes
))
{
nodes
=
corememory
*
nodes
;
}
else
{
nodes
=
cpu
;
}
}
else
{
nodes
=
1
;
...
...
@@ -156,9 +169,12 @@ void read_file(char *file)
strcpy
(
line
,
buffer
);
ptr
=
strstr
(
line
,
"resources_used.cput"
);
if
(
ptr
==
NULL
)
{
if
(
!
noverbose
)
{
fprintf
(
stderr
,
"Warning: No used.cput data on line %d, skipping...
\n
"
,
linenum
);
}
free
(
line
);
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment