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
2734f2a0
Commit
2734f2a0
authored
May 05, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(dashboard, widgets) work in progress system_information.widget.php
parent
23619829
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
65 deletions
+45
-65
system.inc
src/www/widgets/api/plugins/system.inc
+20
-1
system_information.widget.php
src/www/widgets/widgets/system_information.widget.php
+25
-64
No files found.
src/www/widgets/api/plugins/system.inc
View file @
2734f2a0
...
...
@@ -57,6 +57,10 @@ function system_api_cpu_stats()
$cpustats
[
'cur.freq'
]
=
!
empty
(
$tmp
)
?
$tmp
:
"-"
;
$cpustats
[
'freq_translate'
]
=
sprintf
(
gettext
(
"Current: %s MHz, Max: %s MHz"
),
$cpustats
[
'cur.freq'
],
$cpustats
[
'max.freq'
]);
// system load
exec
(
"/usr/bin/uptime | /usr/bin/sed 's/^.*: //'"
,
$load_average
);
$cpustats
[
'load'
]
=
explode
(
','
,
$load_average
[
0
]);
return
$cpustats
;
}
...
...
@@ -72,10 +76,25 @@ function system_api_config()
function
system_api_kernel
()
{
global
$config
;
$result
=
array
(
"pf"
=>
array
());
$result
=
array
();
$result
[
'pf'
]
=
array
();
$result
[
'pf'
][
'maxstates'
]
=
!
empty
(
$config
[
'system'
][
'maximumstates'
])
?
$config
[
'system'
][
'maximumstates'
]
:
default_state_size
();
exec
(
'/sbin/pfctl -si |grep "current entries" 2>/dev/null'
,
$states
);
$result
[
'pf'
][
'states'
]
=
count
(
$states
)
>
0
?
filter_var
(
$states
[
0
],
FILTER_SANITIZE_NUMBER_INT
)
:
0
;
$result
[
'mbuf'
]
=
array
();
exec
(
'/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use"'
,
$mbufs
);
$result
[
'mbuf'
][
'total'
]
=
count
(
$mbufs
)
>
0
?
explode
(
'/'
,
$mbufs
[
0
])[
2
]
:
0
;
$result
[
'mbuf'
][
'max'
]
=
count
(
$mbufs
)
>
0
?
explode
(
' '
,
explode
(
'/'
,
$mbufs
[
0
])[
3
])[
0
]
:
0
;
$totalMem
=
get_single_sysctl
(
"vm.stats.vm.v_page_count"
);
$inactiveMem
=
get_single_sysctl
(
"vm.stats.vm.v_inactive_count"
);
$cachedMem
=
get_single_sysctl
(
"vm.stats.vm.v_cache_count"
);
$freeMem
=
get_single_sysctl
(
"vm.stats.vm.v_free_count"
);
$result
[
'memory'
][
'total'
]
=
get_single_sysctl
(
'hw.physmem'
)
;
$result
[
'memory'
][
'used'
]
=
round
((((
$totalMem
-
(
$inactiveMem
+
$cachedMem
+
$freeMem
)))
/
$totalMem
)
*
$result
[
'memory'
][
'total'
],
0
);
return
$result
;
}
...
...
src/www/widgets/widgets/system_information.widget.php
View file @
2734f2a0
...
...
@@ -133,7 +133,20 @@ $filesystems = get_mounted_filesystems();
$
(
"
#system_information_widget_states .progress-bar
"
).
css
(
"
width
"
,
states_perc
+
"
%
"
).
attr
(
"
aria-valuenow
"
,
states_perc
+
"
%
"
);
var
states_text
=
states_perc
+
"
%
"
+
"
(
"
+
data
[
'
kernel
'
][
'
pf
'
][
'
states
'
]
+
"
/
"
+
data
[
'
kernel
'
][
'
pf
'
][
'
maxstates
'
]
+
"
)
"
$
(
"
#system_information_widget_states .state_text
"
).
html
(
states_text
);
//$("#system_information_widget_states").html(states_perc);
var
mbuf_perc
=
parseInt
((
parseInt
(
data
[
'
kernel
'
][
'
mbuf
'
][
'
total
'
])
/
parseInt
(
data
[
'
kernel
'
][
'
mbuf
'
][
'
max
'
]))
*
100
);
$
(
"
#system_information_widget_mbuf .progress-bar
"
).
css
(
"
width
"
,
mbuf_perc
+
"
%
"
).
attr
(
"
aria-valuenow
"
,
mbuf_perc
+
"
%
"
);
var
mbuf_text
=
mbuf_perc
+
"
%
"
+
"
(
"
+
data
[
'
kernel
'
][
'
mbuf
'
][
'
total
'
]
+
"
/
"
+
data
[
'
kernel
'
][
'
mbuf
'
][
'
max
'
]
+
"
)
"
$
(
"
#system_information_widget_mbuf .state_text
"
).
html
(
mbuf_text
);
$
(
"
#system_information_widget_load
"
).
html
(
data
[
'
cpu
'
][
'
load
'
].
join
(
'
,
'
));
var
mem_perc
=
parseInt
(
data
[
'
kernel
'
][
'
memory
'
][
'
used
'
]
/
data
[
'
kernel
'
][
'
memory
'
][
'
total
'
]
*
100
);
$
(
"
#system_information_widget_memory .progress-bar
"
).
css
(
"
width
"
,
mem_perc
+
"
%
"
).
attr
(
"
aria-valuenow
"
,
mem_perc
+
"
%
"
);
var
mem_text
=
mem_perc
+
"
%
"
+
"
(
"
+
parseInt
(
data
[
'
kernel
'
][
'
memory
'
][
'
used
'
]
/
1024
/
1024
)
+
"
/
"
;
mem_text
+=
parseInt
(
data
[
'
kernel
'
][
'
memory
'
][
'
total
'
]
/
1024
/
1024
)
+
"
MB )
"
$
(
"
#system_information_widget_memory .state_text
"
).
html
(
mem_text
);
}
/**
...
...
@@ -159,29 +172,6 @@ $filesystems = get_mounted_filesystems();
});
</script>
<script
type=
"text/javascript"
>
//
<!
[
CDATA
[
jQuery
(
function
()
{
jQuery
(
"
#statePB
"
).
css
(
{
width
:
'
<?php
echo
get_pfstate
(
true
);
?>
%
'
}
);
jQuery
(
"
#mbufPB
"
).
css
(
{
width
:
'
<?php
echo
get_mbuf
(
true
);
?>
%
'
}
);
jQuery
(
"
#cpuPB
"
).
css
(
{
width
:
0
}
);
jQuery
(
"
#memUsagePB
"
).
css
(
{
width
:
'
<?php
echo
mem_usage
();
?>
%
'
}
);
<?php
$d
=
0
;
?>
<?php
foreach
(
$filesystems
as
$fs
)
:
?>
jQuery
(
"
#diskUsagePB
<?php
echo
$d
++
;
?>
"
).
css
(
{
width
:
'
<?php
echo
$fs
[
'percent_used'
];
?>
%
'
}
);
<?php
endforeach
;
?>
<?php
if
(
$showswap
==
true
)
:
?>
jQuery
(
"
#swapUsagePB
"
).
css
(
{
width
:
'
<?php
echo
swap_usage
();
?>
%
'
}
);
<?php
endif
;
?>
<?php
if
(
get_temp
()
!=
""
)
:
?>
jQuery
(
"
#tempPB
"
).
css
(
{
width
:
'
<?php
echo
get_temp
();
?>
%
'
}
);
<?php
endif
;
?>
});
//]]>
</script>
<table
class=
"table table-striped table-condensed"
data-plugin=
"system"
data-callback=
"system_information_widget_update"
>
<tbody>
<tr>
...
...
@@ -235,59 +225,30 @@ $filesystems = get_mounted_filesystems();
</div>
</td>
</tr>
<tr>
<td>
<?=
gettext
(
"MBUF Usage"
);
?>
</td>
<td>
<?php
$mbufstext
=
get_mbuf
();
$mbufusage
=
get_mbuf
(
true
);
?>
<div
class=
"progress"
>
<div
id=
"mbufPB"
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"60"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 0%;"
>
<span
class=
"sr-only"
></span>
</div>
</div>
<span
id=
"mbufusagemeter"
>
<?=
$mbufusage
.
'%'
;
?>
</span>
(
<span
id=
"mbuf"
>
<?=
$mbufstext
?>
</span>
)
</td>
</tr>
<?php
if
(
get_temp
()
!=
""
)
:
?>
<tr>
<td>
<?=
gettext
(
"Temperature"
);
?>
</td>
<td>
<?php
$TempMeter
=
$temp
=
get_temp
();
?>
<div
class=
"progress"
>
<div
id=
"tempPB"
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"60"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 0%;"
>
<span
class=
"sr-only"
></span>
</div>
<td
id=
"system_information_widget_mbuf"
>
<div
class=
"progress"
style=
"text-align:center;"
>
<span
class=
"state_text"
style=
"position:absolute;right:0;left:0;z-index:200;"
></span>
<div
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"0"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 0%;"
></div>
</div>
<span
id=
"tempmeter"
>
<?=
$temp
.
"°C"
;
?>
</span>
</td>
</tr>
<?php
endif
;
?>
<tr>
<td>
<?=
gettext
(
"Load average"
);
?>
</td>
<td>
<div
id=
"load_average"
title=
"Last 1, 5 and 15 minutes"
>
<?=
get_load_average
();
?>
</div>
</td>
<td
id=
"system_information_widget_load"
></td>
</tr>
<tr>
<td>
<?=
gettext
(
"Memory usage"
);
?>
</td>
<td>
<?php
$memUsage
=
mem_usage
();
?>
<div
class=
"progress"
>
<div
id=
"memUsagePB"
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"60"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 0%;"
>
<span
class=
"sr-only"
></span>
</div>
<td
id=
"system_information_widget_memory"
>
<div
class=
"progress"
style=
"text-align:center;"
>
<span
class=
"state_text"
style=
"position:absolute;right:0;left:0;z-index:200;"
></span>
<div
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"0"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 0%;"
></div>
</div>
<span
id=
"memusagemeter"
>
<?=
$memUsage
.
'%'
;
?>
</span>
used
<?=
sprintf
(
"%.0f/%.0f"
,
$memUsage
/
100.0
*
get_single_sysctl
(
'hw.physmem'
)
/
(
1024
*
1024
),
get_single_sysctl
(
'hw.physmem'
)
/
(
1024
*
1024
))
?>
MB
</td>
</tr>
<?php
if
(
$showswap
==
true
)
:
?>
<tr>
...
...
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