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
ecf9eb5f
Commit
ecf9eb5f
authored
Sep 25, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SystemHealth) work in progress
parent
1370b96d
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
272 additions
and
194 deletions
+272
-194
SystemHealthController.php
...llers/OPNsense/Diagnostics/Api/SystemHealthController.php
+144
-136
SystemHealthController.php
...ntrollers/OPNsense/Diagnostics/SystemHealthController.php
+3
-3
SettingsController.php
...trollers/OPNsense/SystemHealth/Api/SettingsController.php
+0
-44
systemhealth.volt
...ense/mvc/app/views/OPNsense/Diagnostics/systemhealth.volt
+3
-3
interface-packets.xml
...se/scripts/systemhealth/definitions/interface-packets.xml
+6
-0
system-processor.xml
...nse/scripts/systemhealth/definitions/system-processor.xml
+4
-3
fetchData.py
src/opnsense/scripts/systemhealth/fetchData.py
+24
-5
listReports.py
src/opnsense/scripts/systemhealth/listReports.py
+88
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/
SystemHealth/Api/Service
Controller.php
→
src/opnsense/mvc/app/controllers/OPNsense/
Diagnostics/Api/SystemHealth
Controller.php
View file @
ecf9eb5f
This diff is collapsed.
Click to expand it.
src/opnsense/mvc/app/controllers/OPNsense/
SystemHealth/Index
Controller.php
→
src/opnsense/mvc/app/controllers/OPNsense/
Diagnostics/SystemHealth
Controller.php
View file @
ecf9eb5f
...
@@ -26,18 +26,18 @@
...
@@ -26,18 +26,18 @@
* POSSIBILITY OF SUCH DAMAGE.
* POSSIBILITY OF SUCH DAMAGE.
*
*
*/
*/
namespace
OPNsense\
SystemHealth
;
namespace
OPNsense\
Diagnostics
;
/**
/**
* Class IndexController
* Class IndexController
* @package OPNsense\Proxy
* @package OPNsense\Proxy
*/
*/
class
Index
Controller
extends
\OPNsense\Base\IndexController
class
SystemHealth
Controller
extends
\OPNsense\Base\IndexController
{
{
public
function
indexAction
()
public
function
indexAction
()
{
{
$this
->
view
->
title
=
"System Health"
;
$this
->
view
->
title
=
"System Health"
;
$this
->
view
->
pick
(
'OPNsense/
SystemHealth/index
'
);
$this
->
view
->
pick
(
'OPNsense/
Diagnostics/systemhealth
'
);
}
}
}
}
src/opnsense/mvc/app/controllers/OPNsense/SystemHealth/Api/SettingsController.php
deleted
100644 → 0
View file @
1370b96d
<?php
/**
* Copyright (C) 2015 Deciso B.V. - J. Schellevis
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace
OPNsense\SystemHealth\Api
;
use
\OPNsense\Base\ApiControllerBase
;
/**
* Class SettingsController
* @package OPNsense\SystemHealth
*/
class
SettingsController
extends
ApiControllerBase
{
}
?>
src/opnsense/mvc/app/views/OPNsense/
SystemHealth/index
.volt
→
src/opnsense/mvc/app/views/OPNsense/
Diagnostics/systemhealth
.volt
View file @
ecf9eb5f
...
@@ -172,7 +172,7 @@
...
@@ -172,7 +172,7 @@
}
}
function getRRDlist() {
function getRRDlist() {
ajaxGet(url = "/api/
systemhealth/service
/getRRDlist/", sendData = {}, callback = function (data, status) {
ajaxGet(url = "/api/
diagnostics/systemhealth
/getRRDlist/", sendData = {}, callback = function (data, status) {
if (status == "success") {
if (status == "success") {
var category;
var category;
var tabs="";
var tabs="";
...
@@ -293,7 +293,7 @@
...
@@ -293,7 +293,7 @@
// info bar - show loading info bar while refreshing data
// info bar - show loading info bar while refreshing data
$('#loading').show();
$('#loading').show();
// API call to request data
// API call to request data
ajaxGet(url = "/api/
systemhealth/service
/getSystemHealth/" + rrd_name + "/" + String(from) + "/" + String(to) + "/" + String(maxitems) + "/" + String(inverse) + "/" + String(detail), sendData = {}, callback = function (data, status) {
ajaxGet(url = "/api/
diagnostics/systemhealth
/getSystemHealth/" + rrd_name + "/" + String(from) + "/" + String(to) + "/" + String(maxitems) + "/" + String(inverse) + "/" + String(detail), sendData = {}, callback = function (data, status) {
if (status == "success") {
if (status == "success") {
var stepsize = data["d3"]["stepSize"];
var stepsize = data["d3"]["stepSize"];
var scale = "{{ lang._('seconds') }}";
var scale = "{{ lang._('seconds') }}";
...
@@ -473,7 +473,7 @@
...
@@ -473,7 +473,7 @@
.tickFormat(function (d) {
.tickFormat(function (d) {
return d3.time.format(dtformat)(new Date(d))
return d3.time.format(dtformat)(new Date(d))
});
});
chart.yAxis.axisLabel(data["
x
-axis_label"]);
chart.yAxis.axisLabel(data["
y
-axis_label"]);
chart.useInteractiveGuideline(true);
chart.useInteractiveGuideline(true);
chart.interactive(true);
chart.interactive(true);
...
...
src/opnsense/scripts/systemhealth/definitions/interface-packets.xml
0 → 100644
View file @
ecf9eb5f
<?xml version="1.0"?>
<systemhealth>
<file-match>
.*-packets$
</file-match>
<title>
System Information - Packets
</title>
<y-axis_label>
Packets/Second
</y-axis_label>
</systemhealth>
\ No newline at end of file
src/opnsense/scripts/systemhealth/
metadata
/system-processor.xml
→
src/opnsense/scripts/systemhealth/
definitions
/system-processor.xml
View file @
ecf9eb5f
<?xml version="1.0"?>
<?xml version="1.0"?>
<details>
<systemhealth>
<file-match>
system-processor
</file-match>
<title>
System Information - Utilization and Processes
</title>
<title>
System Information - Utilization and Processes
</title>
<
x-axis_label>
[U]tilization , [#]Number
</x
-axis_label>
<
y-axis_label>
[U]tilization , [#]Number
</y
-axis_label>
<field_units>
<field_units>
<user>
[U]
</user>
<user>
[U]
</user>
<nice>
[U]
</nice>
<nice>
[U]
</nice>
...
@@ -9,4 +10,4 @@
...
@@ -9,4 +10,4 @@
<interrupt>
[#]
</interrupt>
<interrupt>
[#]
</interrupt>
<processes>
[#]
</processes>
<processes>
[#]
</processes>
</field_units>
</field_units>
</details>
</systemhealth>
\ No newline at end of file
\ No newline at end of file
src/opnsense/scripts/systemhealth/
queryDetails
.py
→
src/opnsense/scripts/systemhealth/
fetchData
.py
View file @
ecf9eb5f
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
"""
"""
Copyright (c) 2015 Deciso B.V. -
J.
Schellevis
Copyright (c) 2015 Deciso B.V. -
Ad
Schellevis
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
...
@@ -26,10 +26,29 @@
...
@@ -26,10 +26,29 @@
POSSIBILITY OF SUCH DAMAGE.
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
fetch xmldata from rrd tool, but only if filename is valid (with or without .rrd extension)
"""
"""
import
sys
import
glob
import
tempfile
import
subprocess
import
os.path
rrd_reports_dir
=
'/var/db/rrd'
if
len
(
sys
.
argv
)
>
1
:
filename
=
sys
.
argv
[
1
]
# suffix rrd if not already in request
if
filename
.
split
(
'.'
)[
-
1
]
!=
'rrd'
:
filename
+=
'.rrd'
# scan rrd directory for requested file
for
rrdFilename
in
glob
.
glob
(
'
%
s/*.rrd'
%
rrd_reports_dir
):
if
os
.
path
.
basename
(
rrdFilename
)
==
filename
:
with
tempfile
.
NamedTemporaryFile
()
as
output_stream
:
subprocess
.
check_call
([
'/usr/local/bin/rrdtool'
,
'dump'
,
rrdFilename
],
stdout
=
output_stream
,
stderr
=
subprocess
.
STDOUT
)
output_stream
.
seek
(
0
)
print
(
output_stream
.
read
())
break
file
=
open
(
'/Users/josschellevis/Development/opnsense/scripts/systemhealth/metadata/system-processor.xml'
,
'r'
)
file_contents
=
file
.
read
()
print
(
file_contents
)
file
.
close
()
src/opnsense/scripts/systemhealth/listReports.py
0 → 100755
View file @
ecf9eb5f
#!/usr/local/bin/python2.7
"""
Copyright (c) 2015 Deciso B.V. - Ad Schellevis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
return a list of all available rrd files including additional definition data
"""
import
re
import
glob
import
xml.etree.ElementTree
import
os.path
import
ujson
rrd_definition_dir
=
'
%
s/definitions'
%
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
rrd_reports_dir
=
'/var/db/rrd'
# query all rrd files available and initialize with empty definition
result
=
{}
for
filename
in
glob
.
glob
(
'
%
s/*.rrd'
%
rrd_reports_dir
):
rrdFilename
=
os
.
path
.
basename
(
filename
)
.
split
(
'.'
)[
0
]
# determine topic and item name, fixes naming issues
if
rrdFilename
.
split
(
'-'
)[
0
]
in
(
'system'
)
and
rrdFilename
.
find
(
'-'
)
>
-
1
:
topic
=
rrdFilename
.
split
(
'-'
)[
0
]
itemName
=
'-'
.
join
(
rrdFilename
.
split
(
'-'
)[
1
:])
else
:
topic
=
rrdFilename
.
split
(
'-'
)[
-
1
]
itemName
=
'-'
.
join
(
rrdFilename
.
split
(
'-'
)[:
-
1
])
result
[
rrdFilename
]
=
{
'title'
:
''
,
'y-axis_label'
:
''
,
'field_units'
:
{},
'topic'
:
topic
,
'itemName'
:
itemName
}
# scan all definition files
for
filename
in
glob
.
glob
(
'
%
s/*.xml'
%
rrd_definition_dir
):
rrdFilename
=
os
.
path
.
basename
(
filename
)
.
split
(
'.'
)[
0
]
try
:
ruleXML
=
xml
.
etree
.
ElementTree
.
fromstring
(
open
(
filename
)
.
read
())
rrdDef
=
{}
if
ruleXML
.
tag
==
'systemhealth'
:
# only parse systemhealth items
for
child
in
ruleXML
:
if
len
(
list
(
child
))
==
0
:
# single items
rrdDef
[
child
.
tag
]
=
child
.
text
else
:
# named list items
rrdDef
[
child
.
tag
]
=
{}
for
subchild
in
child
:
rrdDef
[
child
.
tag
][
subchild
.
tag
]
=
subchild
.
text
else
:
rrdDef
[
'__msg'
]
=
'xml metadata not valid'
except
xml
.
etree
.
ElementTree
.
ParseError
:
# no valid xml, always return a valid (empty) data set
rrdDef
=
{
'__msg'
:
'xml metadata load error'
}
# link definition data to rrd file, use property file-match in xml to determine it's targets
if
'file-match'
in
rrdDef
:
# remove file-match property from actual result
file_match
=
rrdDef
[
'file-match'
]
del
rrdDef
[
'file-match'
]
for
rrdFilename
in
result
:
if
re
.
search
(
file_match
,
rrdFilename
)
is
not
None
:
for
fieldname
in
rrdDef
:
result
[
rrdFilename
][
fieldname
]
=
rrdDef
[
fieldname
]
print
(
ujson
.
dumps
(
result
))
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