Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gsauthof-utility
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
external
gsauthof-utility
Commits
3d1e66b4
Commit
3d1e66b4
authored
11 months ago
by
Georg Sauthoff
Browse files
Options
Downloads
Patches
Plain Diff
add unix time column
parent
c342254e
No related branches found
Branches containing commit
Tags
nightly/444e3604
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pq.cc
+21
-0
21 additions, 0 deletions
pq.cc
with
21 additions
and
0 deletions
pq.cc
+
21
−
0
View file @
3d1e66b4
...
...
@@ -80,6 +80,7 @@ enum class Column {
CWBYTE
,
// /proc/$pid/io::cancelled_write_bytes
CWD
,
//
ENV
,
//
EPOCH
,
// clock_gettime()
EXE
,
//
FDS
,
// ls /proc/$pid/fd | wc -l
FDSIZE
,
// /proc/$pid/status::FDSize
...
...
@@ -137,6 +138,7 @@ static const string_view col2header[] = {
"cwbyte"
,
// CWBYTE
"cwd"
,
// CWD
"env"
,
// ENV
"epoch"
,
// EPOCH
"exe"
,
// EXE
"fds"
,
// FDS
"fdsz"
,
// FDSIZE
...
...
@@ -185,6 +187,7 @@ static const char * const col2help[] = {
"write bytes, cancelled"
,
// CWBYTE
"current wording directory"
,
// CWD
"display an environment variable, e.g. env:MYID"
,
// ENV
"unix time at traversal time, i.e. seconds since the epoch"
,
// EPOCH
"process' executable"
,
// EXE
"number of open files"
,
// FDS
"number of allocated file descriptor slots"
,
// FDSIZE
...
...
@@ -233,6 +236,7 @@ static const unsigned col2width[] = {
11
,
// CWBYTE
15
,
// CWD
8
,
// ENV
10
,
// EPOCH
10
,
// EXE
3
,
// FDS
3
,
// FDSIZE
...
...
@@ -277,6 +281,7 @@ static const unordered_map<string_view, Column> str2column = {
{
"tid"
,
Column
::
TID
},
{
"comm"
,
Column
::
COMM
},
{
"name"
,
Column
::
COMM
},
{
"epoch"
,
Column
::
EPOCH
},
{
"exe"
,
Column
::
EXE
},
{
"affinity"
,
Column
::
AFFINITY
},
{
"aff"
,
Column
::
AFFINITY
},
...
...
@@ -638,6 +643,7 @@ struct Process {
unsigned
flags
();
string_view
comm
();
string_view
epoch
();
string_view
exe
();
string_view
wchan
();
string_view
wchar
();
...
...
@@ -700,6 +706,7 @@ Process_Attr process_attrs[] = {
&
Process
::
cwbyte
,
// CWBYTE
&
Process
::
cwd
,
// CWD
nullptr
,
// ENV
&
Process
::
epoch
,
// EXE
&
Process
::
exe
,
// EXE
&
Process
::
fds
,
// FDS
&
Process
::
fdsize
,
// FDSIZE
...
...
@@ -1024,6 +1031,20 @@ string_view Process::cls()
}
string_view
Process
::
epoch
()
{
struct
timespec
ts
;
ixxx
::
posix
::
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
auto
r
=
std
::
to_chars
(
misc_arr
.
begin
(),
misc_arr
.
end
(),
ts
.
tv_sec
);
assert
(
r
.
ec
==
std
::
errc
());
#if __cplusplus > 201703L
return
string_view
(
misc_arr
.
data
(),
r
.
ptr
);
#else
return
string_view
(
misc_arr
.
data
(),
r
.
ptr
-
misc_arr
.
data
());
#endif
}
string_view
Process
::
exe
()
{
return
read_link
(
"exe"
);
...
...
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