Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
bc37482f
Commit
bc37482f
authored
Oct 04, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(systemhealth) fix for rrd files without topic in them, like ntpd
parent
852b7e71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
23 deletions
+30
-23
SystemhealthController.php
...llers/OPNsense/Diagnostics/Api/SystemhealthController.php
+24
-13
systemhealth.volt
...ense/mvc/app/views/OPNsense/Diagnostics/systemhealth.volt
+2
-10
listReports.py
src/opnsense/scripts/systemhealth/listReports.py
+4
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemhealthController.php
View file @
bc37482f
...
...
@@ -457,7 +457,7 @@ class SystemhealthController extends ApiControllerBase
/**
* retrieve descriptive details of rrd
* @param string $rrd rrd
filename
* @param string $rrd rrd
category - item
* @return array result status and data
*/
private
function
getRRDdetails
(
$rrd
)
...
...
@@ -466,15 +466,22 @@ class SystemhealthController extends ApiControllerBase
$result
=
array
();
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"systemhealth list"
);
$output
=
json_decode
(
$response
,
true
);
if
(
is_array
(
$output
)
&&
array_key_exists
(
$rrd
,
$output
))
{
$result
[
"result"
]
=
"ok"
;
$result
[
"data"
]
=
$output
[
$rrd
];
}
else
{
// always return a valid (empty) data set
$result
[
"result"
]
=
"not found"
;
$result
[
"data"
]
=
[
"title"
=>
""
,
"y-axis_label"
=>
""
,
"field_units"
=>
[]];
$healthList
=
json_decode
(
$response
,
true
);
// search by topic and name, return array with filename
if
(
is_array
(
$healthList
))
{
foreach
(
$healthList
as
$filename
=>
$healthItem
)
{
if
(
$healthItem
[
'itemName'
]
.
'-'
.
$healthItem
[
'topic'
]
==
$rrd
)
{
$result
[
"result"
]
=
"ok"
;
$healthItem
[
'filename'
]
=
$filename
;
$result
[
"data"
]
=
$healthItem
;
return
$result
;
}
}
}
// always return a valid (empty) data set
$result
[
"result"
]
=
"not found"
;
$result
[
"data"
]
=
[
"title"
=>
""
,
"y-axis_label"
=>
""
,
"field_units"
=>
[],
"itemName"
=>
""
,
"filename"
=>
""
];
return
$result
;
}
...
...
@@ -485,7 +492,7 @@ class SystemhealthController extends ApiControllerBase
*/
public
function
getRRDlistAction
()
{
# S
u
urce of data: filelisting of /var/db/rrd/*.rrd
# S
o
urce of data: filelisting of /var/db/rrd/*.rrd
$result
=
array
();
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"systemhealth list"
);
...
...
@@ -536,9 +543,13 @@ class SystemhealthController extends ApiControllerBase
$rrd_details
=
$this
->
getRRDdetails
(
$rrd
)[
"data"
];
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"systemhealth fetch "
,
array
(
$rrd
));
$xml
=
simplexml_load_string
(
$response
);
if
(
$rrd_details
[
'filename'
]
!=
""
)
{
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"systemhealth fetch "
,
array
(
$rrd_details
[
'filename'
]));
$xml
=
simplexml_load_string
(
$response
);
}
else
{
$xml
=
false
;
}
if
(
$xml
!==
false
)
{
// we only use the average databases in any RRD, remove the rest to avoid strange behaviour.
...
...
src/opnsense/mvc/app/views/OPNsense/Diagnostics/systemhealth.volt
View file @
bc37482f
...
...
@@ -188,11 +188,7 @@
}
subitem=data["data"][category][0]; // first sub item
if (category=="system") {
rrd_name = category + '-' + subitem;
} else {
rrd_name = subitem + '-' + category;
}
rrd_name = subitem + '-' + category;
// create dropdown menu
tabs+='<a data-toggle="dropdown" href="#" class="dropdown-toggle pull-right visible-lg-inline-block visible-md-inline-block visible-xs-inline-block visible-sm-inline-block" role="button" style="border-left: 1px dashed lightgray;">';
...
...
@@ -205,11 +201,7 @@
// add subtabs
for (var count=0; count<data["data"][category].length;++count ) {
subitem=data["data"][category][count];
if (category=="system") {
rrd_name = category + '-' + subitem;
} else {
rrd_name = subitem + '-' + category;
}
rrd_name = subitem + '-' + category;
if (subitem==active_subitem) {
tabs += '<li class="active"><a data-toggle="tab" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
...
...
src/opnsense/scripts/systemhealth/listReports.py
View file @
bc37482f
...
...
@@ -46,6 +46,10 @@ for filename in glob.glob('%s/*.rrd' % rrd_reports_dir):
if
rrdFilename
.
split
(
'-'
)[
0
]
==
'system'
and
rrdFilename
.
find
(
'-'
)
>
-
1
:
topic
=
rrdFilename
.
split
(
'-'
)[
0
]
itemName
=
'-'
.
join
(
rrdFilename
.
split
(
'-'
)[
1
:])
elif
rrdFilename
.
find
(
'-'
)
==
-
1
:
# set topic for items without one
topic
=
'services'
itemName
=
rrdFilename
.
split
(
'.'
)[
0
]
else
:
topic
=
rrdFilename
.
split
(
'-'
)[
-
1
]
itemName
=
'-'
.
join
(
rrdFilename
.
split
(
'-'
)[:
-
1
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment