@@ -195,6 +195,7 @@ function get_distname() {
195195 // TODO: what monitoring is done should be a config-var
196196 function doMonitor () {
197197 /* Calls the single Monitoring steps */
198+ $ this ->monitorHDQuota ();
198199 $ this ->monitorServer ();
199200 $ this ->monitorOSVer ();
200201 $ this ->monitorIspCVer ();
@@ -219,7 +220,84 @@ function doMonitor() {
219220 $ this ->monitorFail2ban ();
220221 $ this ->monitorSysLog ();
221222 }
223+
224+ function monitorHDQuota () {
225+ global $ app ;
226+ global $ conf ;
227+
228+ /* Initialize data array */
229+ $ data = array ();
230+
231+ /* the id of the server as int */
232+ $ server_id = intval ($ conf ["server_id " ]);
233+
234+ /** The type of the data */
235+ $ type = 'harddisk_quota ' ;
236+
237+ /** The state of the harddisk_quota. */
238+ $ state = 'ok ' ;
239+
240+ /** Fetch the data for all users*/
241+ $ dfData = shell_exec ("repquota -asu " );
242+
243+ // split into array
244+ $ df = explode ("\n" , $ dfData );
245+
246+ /*
247+ * ignore the first 5 lines, process the rest
248+ */
249+ for ($ i =5 ; $ i <= sizeof ($ df ); $ i ++) {
250+ if ($ df [$ i ] != '' ) {
251+ /*
252+ * Make a array of the data
253+ */
254+ $ s = preg_split ("/[\s]+/ " , $ df [$ i ]);
255+ $ username = $ s [0 ];
256+ $ data ['user ' ][$ username ]['used ' ] = $ s [2 ];
257+ $ data ['user ' ][$ username ]['soft ' ] = $ s [3 ];
258+ $ data ['user ' ][$ username ]['hard ' ] = $ s [4 ];
259+ }
260+ }
261+
262+ /** Fetch the data for all users*/
263+ $ dfData = shell_exec ("repquota -asg " );
264+
265+ // split into array
266+ $ df = explode ("\n" , $ dfData );
222267
268+ /*
269+ * ignore the first 5 lines, process the rest
270+ */
271+ for ($ i =5 ; $ i <= sizeof ($ df ); $ i ++) {
272+ if ($ df [$ i ] != '' ) {
273+ /*
274+ * Make a array of the data
275+ */
276+ $ s = preg_split ("/[\s]+/ " , $ df [$ i ]);
277+ $ groupname = $ s [0 ];
278+ $ data ['group ' ][$ groupname ]['used ' ] = $ s [1 ];
279+ $ data ['group ' ][$ groupname ]['soft ' ] = $ s [2 ];
280+ $ data ['group ' ][$ groupname ]['hard ' ] = $ s [3 ];
281+ }
282+ }
283+
284+ /*
285+ Insert the data into the database
286+ */
287+ $ sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
288+ "VALUES ( " .
289+ $ server_id . ", " .
290+ "' " . $ app ->dbmaster ->quote ($ type ) . "', " .
291+ time () . ", " .
292+ "' " . $ app ->dbmaster ->quote (serialize ($ data )) . "', " .
293+ "' " . $ state . "' " .
294+ ") " ;
295+ $ app ->dbmaster ->query ($ sql );
296+
297+ /* The new data is written, now we can delete the old one */
298+ $ this ->_delOldRecords ($ type , 4 );
299+ }
300+
223301 function monitorServer () {
224302 global $ app ;
225303 global $ conf ;
0 commit comments