Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
celllframe-node
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
cellframe
celllframe-node
Merge requests
!917
"git@gitlab.demlabs.net:cellframe/libdap-python.git" did not exist on "df9a94222ca462b913a6344f1fcbc50e61b47f64"
[+] diagtool
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
[+] diagtool
release-5.2-diagtool
into
release-5.2
Overview
0
Commits
5
Pipelines
0
Changes
14
Merged
Dmitry Puzyrkov
requested to merge
release-5.2-diagtool
into
release-5.2
1 year ago
Overview
0
Commits
5
Pipelines
0
Changes
14
Expand
👍
0
👎
0
Merge request reports
Compare
release-5.2
version 1
1a20d42c
1 year ago
release-5.2 (base)
and
latest version
latest version
c6d5164b
5 commits,
1 year ago
version 1
1a20d42c
4 commits,
1 year ago
14 files
+
1017
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
14
Search (e.g. *.vue) (Ctrl+P)
diagtool/AbstractDiagnostic.cpp
0 → 100644
+
150
−
0
Options
#include
"AbstractDiagnostic.h"
AbstractDiagnostic
::
AbstractDiagnostic
(
QObject
*
parent
)
:
QObject
(
parent
)
{
s_timer_update
=
new
QTimer
();
s_mac
=
get_mac
();
}
AbstractDiagnostic
::~
AbstractDiagnostic
()
{
delete
s_timer_update
;
}
void
AbstractDiagnostic
::
set_timeout
(
int
timeout
){
s_timer_update
->
stop
();
s_timeout
=
timeout
;
s_timer_update
->
start
(
s_timeout
);
}
void
AbstractDiagnostic
::
start_diagnostic
()
{
s_timer_update
->
start
(
s_timeout
);
}
void
AbstractDiagnostic
::
stop_diagnostic
()
{
s_timer_update
->
stop
();
}
QJsonValue
AbstractDiagnostic
::
get_mac
()
{
QString
MAC
{
"unknown"
};
foreach
(
QNetworkInterface
netInterface
,
QNetworkInterface
::
allInterfaces
())
{
// Return only the first non-loopback MAC Address
if
(
!
(
netInterface
.
flags
()
&
QNetworkInterface
::
IsLoopBack
))
{
qDebug
()
<<
netInterface
.
hardwareAddress
();
if
(
!
netInterface
.
hardwareAddress
().
isEmpty
())
{
MAC
=
netInterface
.
hardwareAddress
();
break
;
}
}
}
return
MAC
;
}
QString
AbstractDiagnostic
::
get_uptime_string
(
long
sec
)
{
QTime
time
(
0
,
0
);
time
=
time
.
addSecs
(
sec
);
int
fullHours
=
sec
/
3600
;
QString
uptime
=
QString
(
"%1:"
).
arg
(
fullHours
)
+
time
.
toString
(
"mm:ss"
);
return
uptime
;
}
quint64
AbstractDiagnostic
::
get_file_size
(
QString
flag
,
QString
path
)
{
if
(
flag
==
"log"
)
path
+=
"/var/log"
;
else
if
(
flag
==
"DB"
)
path
+=
"/var/lib/global_db"
;
else
if
(
flag
==
"chain"
)
path
+=
"/var/lib/network"
;
else
path
+=
""
;
QDir
currentFolder
(
path
);
quint64
totalsize
=
0
;
currentFolder
.
setFilter
(
QDir
::
Dirs
|
QDir
::
Files
|
QDir
::
NoSymLinks
);
currentFolder
.
setSorting
(
QDir
::
Name
);
QFileInfoList
folderitems
(
currentFolder
.
entryInfoList
()
);
foreach
(
QFileInfo
i
,
folderitems
)
{
QString
iname
(
i
.
fileName
()
);
if
(
iname
==
"."
||
iname
==
".."
||
iname
.
isEmpty
()
)
continue
;
if
(
flag
==
"log"
&&
i
.
suffix
()
!=
"log"
&&
!
i
.
isDir
())
continue
;
else
if
(
flag
==
"DB"
&&
(
i
.
suffix
()
!=
"dat"
&&
!
i
.
suffix
().
isEmpty
())
&&
!
i
.
isDir
())
continue
;
else
if
(
flag
==
"chain"
&&
i
.
suffix
()
!=
"dchaincell"
&&
!
i
.
isDir
())
continue
;
if
(
i
.
isDir
()
)
totalsize
+=
get_file_size
(
""
,
path
+
"/"
+
iname
);
else
totalsize
+=
i
.
size
();
}
return
totalsize
;
}
QString
AbstractDiagnostic
::
get_memory_string
(
long
num
)
{
QString
result
=
QString
::
number
(
num
);
return
result
;
int
gb
=
(
num
/
1024
)
/
1024
;
int
mb
=
(
num
-
gb
*
1024
*
1024
)
/
1024
;
int
kb
=
(
num
-
(
gb
*
1024
*
1024
+
mb
*
1024
));
if
(
gb
>
0
)
result
=
QString
::
number
(
gb
)
+
QString
(
" Gb "
);
else
result
=
QString
(
""
);
if
(
mb
>
0
)
result
+=
QString
::
number
(
mb
)
+
QString
(
" Mb "
);
if
(
kb
>
0
)
result
+=
QString
::
number
(
kb
)
+
QString
(
" Kb "
);
return
result
;
}
QJsonObject
AbstractDiagnostic
::
roles_processing
()
{
QJsonObject
rolesObject
;
QDir
currentFolder
(
"/opt/cellframe-node/etc/network"
);
currentFolder
.
setFilter
(
QDir
::
Dirs
|
QDir
::
Files
|
QDir
::
NoSymLinks
);
currentFolder
.
setSorting
(
QDir
::
Name
);
QFileInfoList
folderitems
(
currentFolder
.
entryInfoList
()
);
foreach
(
QFileInfo
i
,
folderitems
)
{
QString
iname
(
i
.
fileName
()
);
if
(
iname
==
"."
||
iname
==
".."
||
iname
.
isEmpty
()
)
continue
;
if
(
i
.
suffix
()
==
"cfg"
&&
!
i
.
isDir
())
{
QSettings
config
(
i
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
rolesObject
.
insert
(
i
.
completeBaseName
(),
config
.
value
(
"node-role"
,
"unknown"
).
toString
());
}
}
return
rolesObject
;
}
Loading