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
1 year ago
by
Georg Sauthoff
Browse files
Options
Downloads
Patches
Plain Diff
add unix time column
parent
c342254e
No related branches found
Branches containing commit
No related tags found
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 {
...
@@ -80,6 +80,7 @@ enum class Column {
CWBYTE
,
// /proc/$pid/io::cancelled_write_bytes
CWBYTE
,
// /proc/$pid/io::cancelled_write_bytes
CWD
,
//
CWD
,
//
ENV
,
//
ENV
,
//
EPOCH
,
// clock_gettime()
EXE
,
//
EXE
,
//
FDS
,
// ls /proc/$pid/fd | wc -l
FDS
,
// ls /proc/$pid/fd | wc -l
FDSIZE
,
// /proc/$pid/status::FDSize
FDSIZE
,
// /proc/$pid/status::FDSize
...
@@ -137,6 +138,7 @@ static const string_view col2header[] = {
...
@@ -137,6 +138,7 @@ static const string_view col2header[] = {
"cwbyte"
,
// CWBYTE
"cwbyte"
,
// CWBYTE
"cwd"
,
// CWD
"cwd"
,
// CWD
"env"
,
// ENV
"env"
,
// ENV
"epoch"
,
// EPOCH
"exe"
,
// EXE
"exe"
,
// EXE
"fds"
,
// FDS
"fds"
,
// FDS
"fdsz"
,
// FDSIZE
"fdsz"
,
// FDSIZE
...
@@ -185,6 +187,7 @@ static const char * const col2help[] = {
...
@@ -185,6 +187,7 @@ static const char * const col2help[] = {
"write bytes, cancelled"
,
// CWBYTE
"write bytes, cancelled"
,
// CWBYTE
"current wording directory"
,
// CWD
"current wording directory"
,
// CWD
"display an environment variable, e.g. env:MYID"
,
// ENV
"display an environment variable, e.g. env:MYID"
,
// ENV
"unix time at traversal time, i.e. seconds since the epoch"
,
// EPOCH
"process' executable"
,
// EXE
"process' executable"
,
// EXE
"number of open files"
,
// FDS
"number of open files"
,
// FDS
"number of allocated file descriptor slots"
,
// FDSIZE
"number of allocated file descriptor slots"
,
// FDSIZE
...
@@ -233,6 +236,7 @@ static const unsigned col2width[] = {
...
@@ -233,6 +236,7 @@ static const unsigned col2width[] = {
11
,
// CWBYTE
11
,
// CWBYTE
15
,
// CWD
15
,
// CWD
8
,
// ENV
8
,
// ENV
10
,
// EPOCH
10
,
// EXE
10
,
// EXE
3
,
// FDS
3
,
// FDS
3
,
// FDSIZE
3
,
// FDSIZE
...
@@ -277,6 +281,7 @@ static const unordered_map<string_view, Column> str2column = {
...
@@ -277,6 +281,7 @@ static const unordered_map<string_view, Column> str2column = {
{
"tid"
,
Column
::
TID
},
{
"tid"
,
Column
::
TID
},
{
"comm"
,
Column
::
COMM
},
{
"comm"
,
Column
::
COMM
},
{
"name"
,
Column
::
COMM
},
{
"name"
,
Column
::
COMM
},
{
"epoch"
,
Column
::
EPOCH
},
{
"exe"
,
Column
::
EXE
},
{
"exe"
,
Column
::
EXE
},
{
"affinity"
,
Column
::
AFFINITY
},
{
"affinity"
,
Column
::
AFFINITY
},
{
"aff"
,
Column
::
AFFINITY
},
{
"aff"
,
Column
::
AFFINITY
},
...
@@ -638,6 +643,7 @@ struct Process {
...
@@ -638,6 +643,7 @@ struct Process {
unsigned
flags
();
unsigned
flags
();
string_view
comm
();
string_view
comm
();
string_view
epoch
();
string_view
exe
();
string_view
exe
();
string_view
wchan
();
string_view
wchan
();
string_view
wchar
();
string_view
wchar
();
...
@@ -700,6 +706,7 @@ Process_Attr process_attrs[] = {
...
@@ -700,6 +706,7 @@ Process_Attr process_attrs[] = {
&
Process
::
cwbyte
,
// CWBYTE
&
Process
::
cwbyte
,
// CWBYTE
&
Process
::
cwd
,
// CWD
&
Process
::
cwd
,
// CWD
nullptr
,
// ENV
nullptr
,
// ENV
&
Process
::
epoch
,
// EXE
&
Process
::
exe
,
// EXE
&
Process
::
exe
,
// EXE
&
Process
::
fds
,
// FDS
&
Process
::
fds
,
// FDS
&
Process
::
fdsize
,
// FDSIZE
&
Process
::
fdsize
,
// FDSIZE
...
@@ -1024,6 +1031,20 @@ string_view Process::cls()
...
@@ -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
()
string_view
Process
::
exe
()
{
{
return
read_link
(
"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