Open-AudIT
https://www.open-audit.org/phpBB3/

PATCH: Partition free space less than 1000 MB AND size > 0
https://www.open-audit.org/phpBB3/viewtopic.php?f=9&t=3740
Page 1 of 1

Author:  jonbendtsen [ Fri Jul 30, 2010 1:52 am ]
Post subject:  PATCH: Partition free space less than 1000 MB AND size > 0

Hi

I was a little annoyed about the front page function Partition free space less than 1000 MB because it also shows linux software raid partitions :-( which have size 0.
Code:
IP Address    Hostname    Free Space MB    Size MB    Free Space %    Drive Letter    Volume Name
Not-Networked       0 MB    0 MB    0 %    /dev/hda1    
Not-Networked       0 MB    0 MB    0 %    /dev/hda2    
Not-Networked       0 MB    0 MB    0 %    /dev/hdb1    
Not-Networked       0 MB    0 MB    0 %    /dev/hdb2    
Not-Networked       0 MB    0 MB    0 %    /dev/hdc1    
Not-Networked       0 MB    0 MB    0 %    /dev/hdc2    
Not-Networked       0 MB    0 MB    0 %    /dev/md3    
Not-Networked       0 MB    0 MB    0 %    /dev/sda1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdb1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdc1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdd1    
Not-Networked       0 MB    0 MB    0 %    /dev/sde1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdf1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdg1    
Not-Networked       0 MB    0 MB    0 %    /dev/sdh1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hda1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hda2    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hdb1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hdb2    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hdc1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/hdc2    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/md2    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/md3    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sda1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdb1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdc1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdc1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdd1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdd1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sde1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sde1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdf1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdf1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdg1    
10.7.0.26    DK2    0 MB    0 MB    0 %    /dev/sdh1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hda1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hda2    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hda3    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hdb1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hdb2    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/hdb3    
10.7.0.10    DKSRV003    0 MB    10088 MB    0 %    /dev/md0    /
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sda1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdb1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdc1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdd1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sde1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdf1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdg1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdh1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdi1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdj1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdk1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdl1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdm1    
10.7.0.10    DKSRV003    0 MB    0 MB    0 %    /dev/sdn1    
10.7.0.1    DKVPN1    219 MB    2114 MB    10.4 %    /dev/hda1    /


So i made this patch that fixes the problem by only showing partitions with a size larger than 0.
Code:
dkopen-audit:/var/www/open-audit# svn diff index_data.php
Index: index_data.php
===================================================================
--- index_data.php   (revision 1245)
+++ index_data.php   (working copy)
@@ -369,7 +369,7 @@
    
   $sql  = "SELECT sys.system_name, sys.net_ip_address, par.partition_uuid, par.partition_volume_name, par.partition_caption, par.partition_free_space, par.partition_size, par.partition_timestamp ";
   $sql .= "FROM system sys, partition par ";
-  $sql .= "WHERE par.partition_free_space < '$partition_free_space' AND sys.system_uuid = par.partition_uuid AND par.partition_timestamp = sys.system_timestamp ";
+  $sql .= "WHERE par.partition_free_space < '$partition_free_space' AND par.partition_size > 0 AND sys.system_uuid = par.partition_uuid AND par.partition_timestamp = sys.system_timestamp ";
   $sql .= "ORDER BY sys.system_name, par.partition_caption";
   
    $result = mysql_query($sql, $db) or die (mysql_error());
@@ -1471,4 +1471,4 @@
    return;
 }
 
-?>
\ No newline at end of file
+?>



And now it only shows
Code:
10.7.0.10    DKSRV003    0 MB    10088 MB    0 %    /dev/md0    /
10.7.0.1    DKVPN1    219 MB    2114 MB    10.4 %    /dev/hda1    /


Much better :mrgreen:

Author:  shanimal [ Wed Oct 06, 2010 3:55 am ]
Post subject:  Re: PATCH: Partition free space less than 1000 MB AND size > 0

Thumbs up, I implemented your tweak to index_data.php and it works like a charm!

Author:  jonbendtsen [ Tue Oct 12, 2010 11:23 pm ]
Post subject:  Re: PATCH: Partition free space less than 1000 MB AND size > 0

shanimal wrote:
Thumbs up, I implemented your tweak to index_data.php and it works like a charm!

I had to reimplement it, because open mac audit open mac audit showed (null) for some mac partitions.

Code:
dkopen-audit:/var/www/open-audit# svn diff index_data.php
Index: index_data.php
===================================================================
--- index_data.php    (revision 1247)
+++ index_data.php    (working copy)
@@ -367,9 +367,9 @@
   global $db, $partition_free_space;
     $tr_class='npb_highlight_row';
     
-  $sql  = "SELECT sys.system_name, sys.net_ip_address, par.partition_uuid, par.partition_volume_name, par.partition_caption, par.partition_free_space, par.partition_size, par.partition_timestamp ";
+  $sql  = "SELECT sys.system_name, sys.net_ip_address, par.partition_uuid, par.partition_volume_name, par.partition_caption, par.partition_free_space, par.partition_file_system, par.partition_timestamp ";
   $sql .= "FROM system sys, partition par ";
-  $sql .= "WHERE par.partition_free_space < '$partition_free_space' AND sys.system_uuid = par.partition_uuid AND par.partition_timestamp = sys.system_timestamp ";
+  $sql .= "WHERE par.partition_free_space < '$partition_free_space' AND par.partition_file_system!='(null)' AND par.partition_volume_name!='(null)' AND par.partition_file_system!='linux_raid_member' AND par.partition_file_system!='LVM2_member' AND sys.system_uuid = par.partition_uuid AND par.partition_timestamp = sys.system_timestamp ";
   $sql .= "ORDER BY sys.system_name, par.partition_caption";
   
     $result = mysql_query($sql, $db) or die (mysql_error());
@@ -1471,4 +1471,4 @@
     return;
 }
 
-?>
\ No newline at end of file
+?>
dkopen-audit:/var/www/open-audit#

Page 1 of 1 All times are UTC + 10 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/