Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dirk Dankhoff
ISPConfig 3
Commits
44641656
Commit
44641656
authored
Jun 30, 2010
by
tbrehm
Browse files
Implemented: FS#1025 - Harddisk Quota Usage
parent
0f7d3e23
Changes
7
Hide whitespace changes
Inline
Side-by-side
interface/web/sites/lib/lang/en_user_quota_stats_list.lng
0 → 100644
View file @
44641656
<?php
$wb
[
"list_head_txt"
]
=
'Website harddisk quota'
;
$wb
[
"domain_txt"
]
=
'Domain / Website'
;
$wb
[
"system_user_txt"
]
=
'Linux user'
;
$wb
[
"used_txt"
]
=
'Used space'
;
$wb
[
"hard_txt"
]
=
'Hard limit'
;
$wb
[
"soft_txt"
]
=
'Soft limit'
;
?>
\ No newline at end of file
interface/web/sites/lib/module.conf.php
View file @
44641656
...
...
@@ -124,6 +124,11 @@ $items[] = array( 'title' => 'Web traffic',
'link'
=>
'sites/web_sites_stats.php'
,
'html_id'
=>
'websites_stats'
);
$items
[]
=
array
(
'title'
=>
'Website quota (Harddisk)'
,
'target'
=>
'content'
,
'link'
=>
'sites/user_quota_stats.php'
,
'html_id'
=>
'user_quota_stats'
);
$module
[
'nav'
][]
=
array
(
'title'
=>
'Statistics'
,
'open'
=>
1
,
...
...
interface/web/sites/list/user_quota_stats.list.php
0 → 100644
View file @
44641656
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste
[
"name"
]
=
"user_quota_stats"
;
// Database table
$liste
[
"table"
]
=
"web_domain"
;
// Index index field of the database table
$liste
[
"table_idx"
]
=
"domain_id"
;
// Search Field Prefix
$liste
[
"search_prefix"
]
=
"search_"
;
// Records per page
$liste
[
"records_per_page"
]
=
15
;
// Script File of the list
$liste
[
"file"
]
=
"user_quota_stats.php"
;
// Script file of the edit form
$liste
[
"edit_file"
]
=
"web_domain_edit.php"
;
// Script File of the delete script
$liste
[
"delete_file"
]
=
"web_domain_del.php"
;
// Paging Template
$liste
[
"paging_tpl"
]
=
"templates/paging.tpl.htm"
;
// Enable auth
$liste
[
"auth"
]
=
"yes"
;
/*****************************************************
* Suchfelder
*****************************************************/
$liste
[
"item"
][]
=
array
(
'field'
=>
"domain"
,
'datatype'
=>
"VARCHAR"
,
'formtype'
=>
"TEXT"
,
'op'
=>
"like"
,
'prefix'
=>
"%"
,
'suffix'
=>
"%"
,
'width'
=>
""
,
'value'
=>
""
);
$liste
[
"item"
][]
=
array
(
'field'
=>
"system_user"
,
'datatype'
=>
"VARCHAR"
,
'formtype'
=>
"TEXT"
,
'op'
=>
"like"
,
'prefix'
=>
"%"
,
'suffix'
=>
"%"
,
'width'
=>
""
,
'value'
=>
""
);
?>
\ No newline at end of file
interface/web/sites/templates/user_quota_stats_list.htm
0 → 100644
View file @
44641656
<h2><tmpl_var
name=
"list_head_txt"
></h2>
<div
class=
"panel panel_list_user_quota_stats"
>
<div
class=
"pnl_listarea"
>
<fieldset><legend><tmpl_var
name=
"list_head_txt"
></legend>
<table
class=
"list"
>
<thead>
<tr>
<th
class=
"tbl_col_domain"
scope=
"col"
><tmpl_var
name=
"domain_txt"
></th>
<th
class=
"tbl_col_system_user"
scope=
"col"
><tmpl_var
name=
"system_user_txt"
></th>
<th
class=
"tbl_col_system_user"
scope=
"col"
><tmpl_var
name=
"used_txt"
></th>
<th
class=
"tbl_col_system_user"
scope=
"col"
><tmpl_var
name=
"soft_txt"
></th>
<th
class=
"tbl_col_system_user"
scope=
"col"
><tmpl_var
name=
"hard_txt"
></th>
<th
class=
"tbl_col_buttons"
scope=
"col"
>
</th>
</tr>
<tr>
<td
class=
"tbl_col_domain"
><input
type=
"text"
name=
"search_domain"
value=
"{tmpl_var name='search_domain'}"
/></td>
<td
class=
"tbl_col_system_user"
><input
type=
"text"
name=
"search_system_user"
value=
"{tmpl_var name='search_system_user'}"
/></td>
<td
class=
"tbl_col_system_user"
>
</td>
<td
class=
"tbl_col_system_user"
>
</td>
<td
class=
"tbl_col_system_user"
>
</td>
<td
class=
"tbl_col_buttons"
><div
class=
"buttons"
><button
type=
"button"
class=
"icons16 icoFilter"
name=
"Filter"
id=
"Filter"
value=
"{tmpl_var name="
filter_txt
"}"
onClick=
"submitForm('pageForm','sites/user_quota_stats.php');"
><span>
{tmpl_var name="filter_txt"}
</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop
name=
"records"
>
<tr
class=
"tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>"
>
<td
class=
"tbl_col_domain"
><a
href=
"#"
onClick=
"loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');"
>
{tmpl_var name="domain"}
</a></td>
<td
class=
"tbl_col_system_user"
><a
href=
"#"
onClick=
"loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');"
>
{tmpl_var name="system_user"}
</a></td>
<td
class=
"tbl_col_used"
><a
href=
"#"
onClick=
"loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');"
>
{tmpl_var name="used"}
</a></td>
<td
class=
"tbl_col_soft"
><a
href=
"#"
onClick=
"loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');"
>
{tmpl_var name="soft"}
</a></td>
<td
class=
"tbl_col_hard"
><a
href=
"#"
onClick=
"loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');"
>
{tmpl_var name="hard"}
</a></td>
<td
class=
"tbl_col_buttons"
>
<div
class=
"buttons icons16"
>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td
class=
"tbl_footer tbl_paging"
colspan=
"6"
><tmpl_var
name=
"paging"
></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
interface/web/sites/user_quota_stats.php
0 → 100644
View file @
44641656
<?php
require_once
(
'../../lib/config.inc.php'
);
require_once
(
'../../lib/app.inc.php'
);
/******************************************
* Begin Form configuration
******************************************/
$list_def_file
=
"list/user_quota_stats.list.php"
;
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app
->
auth
->
check_module_permissions
(
'sites'
);
$app
->
load
(
'listform_actions'
);
$tmp_rec
=
$app
->
db
->
queryOneRecord
(
"SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC"
);
$monitor_data
=
unserialize
(
$app
->
db
->
unquote
(
$tmp_rec
[
'data'
]));
class
list_action
extends
listform_actions
{
function
prepareDataRow
(
$rec
)
{
global
$app
,
$monitor_data
;
$rec
=
$app
->
listform
->
decode
(
$rec
);
//* Alternating datarow colors
$this
->
DataRowColor
=
(
$this
->
DataRowColor
==
'#FFFFFF'
)
?
'#EEEEEE'
:
'#FFFFFF'
;
$rec
[
'bgcolor'
]
=
$this
->
DataRowColor
;
$username
=
$rec
[
'system_user'
];
$rec
[
'used'
]
=
$monitor_data
[
'user'
][
$username
][
'used'
];
$rec
[
'soft'
]
=
$monitor_data
[
'user'
][
$username
][
'soft'
];
$rec
[
'hard'
]
=
$monitor_data
[
'user'
][
$username
][
'hard'
];
if
(
$rec
[
'soft'
]
==
'0K'
)
$rec
[
'soft'
]
=
$app
->
lng
(
'unlimited'
);
if
(
$rec
[
'hard'
]
==
'0K'
)
$rec
[
'hard'
]
=
$app
->
lng
(
'unlimited'
);
//* The variable "id" contains always the index variable
$rec
[
'id'
]
=
$rec
[
$this
->
idx_key
];
return
$rec
;
}
}
$list
=
new
list_action
;
$list
->
SQLExtWhere
=
"type = 'vhost'"
;
$list
->
onLoad
();
?>
\ No newline at end of file
interface/web/sites/web_sites_stats.php
View file @
44641656
...
...
@@ -58,6 +58,8 @@ class list_action extends listform_actions {
}
$list
=
new
list_action
;
$list
->
SQLExtWhere
=
"type = 'vhost'"
;
$list
->
onLoad
();
...
...
server/mods-available/monitor_core_module.inc.php
View file @
44641656
...
...
@@ -195,6 +195,7 @@ class monitor_core_module {
// TODO: what monitoring is done should be a config-var
function
doMonitor
()
{
/* Calls the single Monitoring steps */
$this
->
monitorHDQuota
();
$this
->
monitorServer
();
$this
->
monitorOSVer
();
$this
->
monitorIspCVer
();
...
...
@@ -219,7 +220,84 @@ class monitor_core_module {
$this
->
monitorFail2ban
();
$this
->
monitorSysLog
();
}
function
monitorHDQuota
()
{
global
$app
;
global
$conf
;
/* Initialize data array */
$data
=
array
();
/* the id of the server as int */
$server_id
=
intval
(
$conf
[
"server_id"
]);
/** The type of the data */
$type
=
'harddisk_quota'
;
/** The state of the harddisk_quota. */
$state
=
'ok'
;
/** Fetch the data for all users*/
$dfData
=
shell_exec
(
"repquota -asu"
);
// split into array
$df
=
explode
(
"
\n
"
,
$dfData
);
/*
* ignore the first 5 lines, process the rest
*/
for
(
$i
=
5
;
$i
<=
sizeof
(
$df
);
$i
++
)
{
if
(
$df
[
$i
]
!=
''
)
{
/*
* Make a array of the data
*/
$s
=
preg_split
(
"/[\s]+/"
,
$df
[
$i
]);
$username
=
$s
[
0
];
$data
[
'user'
][
$username
][
'used'
]
=
$s
[
2
];
$data
[
'user'
][
$username
][
'soft'
]
=
$s
[
3
];
$data
[
'user'
][
$username
][
'hard'
]
=
$s
[
4
];
}
}
/** Fetch the data for all users*/
$dfData
=
shell_exec
(
"repquota -asg"
);
// split into array
$df
=
explode
(
"
\n
"
,
$dfData
);
/*
* ignore the first 5 lines, process the rest
*/
for
(
$i
=
5
;
$i
<=
sizeof
(
$df
);
$i
++
)
{
if
(
$df
[
$i
]
!=
''
)
{
/*
* Make a array of the data
*/
$s
=
preg_split
(
"/[\s]+/"
,
$df
[
$i
]);
$groupname
=
$s
[
0
];
$data
[
'group'
][
$groupname
][
'used'
]
=
$s
[
1
];
$data
[
'group'
][
$groupname
][
'soft'
]
=
$s
[
2
];
$data
[
'group'
][
$groupname
][
'hard'
]
=
$s
[
3
];
}
}
/*
Insert the data into the database
*/
$sql
=
"INSERT INTO monitor_data (server_id, type, created, data, state) "
.
"VALUES ("
.
$server_id
.
", "
.
"'"
.
$app
->
dbmaster
->
quote
(
$type
)
.
"', "
.
time
()
.
", "
.
"'"
.
$app
->
dbmaster
->
quote
(
serialize
(
$data
))
.
"', "
.
"'"
.
$state
.
"'"
.
")"
;
$app
->
dbmaster
->
query
(
$sql
);
/* The new data is written, now we can delete the old one */
$this
->
_delOldRecords
(
$type
,
4
);
}
function
monitorServer
()
{
global
$app
;
global
$conf
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment