Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Fri Mar 29, 2024 6:36 am

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Audit Harddrive SMART.
PostPosted: Sat Feb 16, 2008 2:42 am 
Offline
Newbie

Joined: Sat Feb 16, 2008 2:33 am
Posts: 1
To add SMART Harddrive audit you need to change some lines in the audit.vbs, system_viewdef_hardware.php, admin_pc_add_2.php and if you want on the sql script open_audit.sql. The Hard Drive SMART attribute is called hard_drive_status (refer to hdd smart status)

Audit.vbs Changes

[code]
'''''''''''''''''''''''''''
' H.Drive Information '
'''''''''''''''''''''''''''
comment = "Hard Disk Info"
if verbose = "y" then
wscript.echo comment
end if
On Error Resume Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive",,48)
For Each objItem in colItems
form_input = "harddrive^^^" _
& clean(objItem.Caption) & "^^^" & clean(objItem.Index) & "^^^" & clean(objItem.InterfaceType) & "^^^" _
& clean(objItem.Manufacturer) & "^^^" & clean(objItem.Model) & "^^^" & clean(objItem.Partitions) & "^^^" _
& clean(objItem.SCSIBus) & "^^^" & clean(objItem.SCSILogicalUnit) & "^^^" & clean(objItem.SCSIPort) & "^^^" _
& clean(int(objItem.Size /1024 /1024)) & "^^^" & clean(objItem.Status) & "^^^" & clean(objItem.PNPDeviceID)
entry form_input,comment,objTextFile,oAdd,oComment
form_input = ""
if online = "p" then
oIE.document.WriteLn "<tr bgcolor=""#F1F1F1""><td>Hard Drive Type: </td><td>" & clean(objItem.InterfaceType) & "</td></tr>"
oIE.document.WriteLn "<tr><td>Hard Drive Size: </td><td>" & clean(int(objItem.Size /1024 /1024)) & " mb</td></tr>"
oIE.document.WriteLn "<tr bgcolor=""#F1F1F1""><td>Hard Drive Model: </td><td>" & clean(objItem.Model) & "</td></tr>"
oIE.document.WriteLn "<tr><td>Hard Drive Partitions: </td><td>" & clean(objItem.Partitions) & "</td></tr>"
oIE.document.WriteLn "<tr bgcolor=""#F1F1F1""><td>Hard Drive Status: </td><td>" & clean(objItem.Status) & "</td></tr>"
end if
Next
[/code]

system_viewdef_hardware.php Changes

[code]
"hard_drive"=>array(
"headline"=>__("Fixed Disks"),
"sql"=>"SELECT hard_drive_index, hard_drive_manufacturer, hard_drive_interface_type, hard_drive_model, hard_drive_partitions, hard_drive_size, hard_drive_status, hard_drive_scsi_bus, hard_drive_scsi_logical_unit, hard_drive_scsi_port
FROM hard_drive, system
WHERE hard_drive_uuid=system_uuid AND hard_drive_uuid = '" . $_GET["pc"] . "' AND hard_drive_timestamp = '".$GLOBAL["system_timestamp"]."' ORDER BY hard_drive_index",
"image"=>"images/harddisk_l.png",
"fields"=>array("10"=>array("name"=>"hard_drive_index", "head"=>__("Index"),),
"20"=>array("name"=>"hard_drive_manufacturer", "head"=>__("Manufacturer"),),
"30"=>array("name"=>"hard_drive_interface_type", "head"=>__("Type"),),
"40"=>array("name"=>"hard_drive_model", "head"=>__("Model"),),
"50"=>array("name"=>"hard_drive_partitions", "head"=>__("Partitions"),),
"60"=>array("name"=>"hard_drive_size", "head"=>__("Size"),),
"70"=>array("name"=>"hard_drive_status", "head"=>__("Status"),),
"80"=>array("name"=>"hard_drive_scsi_bus", "head"=>__("SCSI Bus"),),
"90"=>array("name"=>"hard_drive_scsi_logical_unit", "head"=>__("SCSI Logical Unit"),),
"100"=>array("name"=>"hard_drive_scsi_port", "head"=>__("SCSI Port"),),
),
),
[/code]

admin_pc_add_2.php Changes

[code]
function insert_harddrive ($split){
global $timestamp, $uuid, $verbose, $hard_drive_timestamp;
if ($verbose == "y"){echo "<h2>Hard Drive</h2><br />";}
$extended = explode('^^^',$split);
$hard_drive_caption = trim($extended[1]);
$hard_drive_index = trim($extended[2]);
$hard_drive_interface_type = trim($extended[3]);
$hard_drive_manufacturer = trim($extended[4]);
$hard_drive_model = trim($extended[5]);
$hard_drive_partitions = trim($extended[6]);
$hard_drive_scsi_bus = trim($extended[7]);
$hard_drive_scsi_logical_unit = trim($extended[8]);
$hard_drive_scsi_port = trim($extended[9]);
$hard_drive_size = trim($extended[10]);
$hard_drive_status = trim($extended[11]);
$hard_drive_pnpid = trim($extended[12]);
if (is_null($hard_drive_timestamp)){
$sql = "SELECT MAX(hard_drive_timestamp) FROM hard_drive WHERE hard_drive_uuid = '$uuid'";
if ($verbose == "y"){echo $sql . "<br />\n\n";}
$result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql);
$myrow = mysql_fetch_array($result);
if ($myrow["MAX(hard_drive_timestamp)"]) {$hard_drive_timestamp = $myrow["MAX(hard_drive_timestamp)"];} else {$hard_drive_timestamp = "";}
} else {}
$sql = "SELECT count(hard_drive_uuid) AS count FROM hard_drive WHERE hard_drive_uuid = '$uuid' AND hard_drive_caption = '$hard_drive_caption' AND ";
$sql .= "hard_drive_index = '$hard_drive_index' AND hard_drive_interface_type = '$hard_drive_interface_type' AND ";
$sql .= "hard_drive_manufacturer = '$hard_drive_manufacturer' AND hard_drive_model = '$hard_drive_model' AND ";
$sql .= "hard_drive_partitions = '$hard_drive_partitions' AND hard_drive_scsi_bus = '$hard_drive_scsi_bus' AND ";
$sql .= "hard_drive_scsi_logical_unit = '$hard_drive_scsi_logical_unit' AND hard_drive_scsi_port = '$hard_drive_scsi_port' AND ";
$sql .= "hard_drive_size = '$hard_drive_size' AND hard_drive_status = '$hard_drive_status' AND (hard_drive_timestamp = '$hard_drive_timestamp' OR hard_drive_timestamp = '$timestamp')";
if ($verbose == "y"){echo $sql . "<br />\n\n";}
$result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql);
$myrow = mysql_fetch_array($result);
if ($verbose == "y"){echo "Count: " . $myrow['count'] . "<br />\n\n";}
if ($myrow['count'] == "0"){
// Insert into database
$sql = "INSERT INTO hard_drive (hard_drive_uuid, hard_drive_caption, hard_drive_index, ";
$sql .= "hard_drive_interface_type, hard_drive_manufacturer, hard_drive_model, ";
$sql .= "hard_drive_partitions, hard_drive_scsi_bus, hard_drive_scsi_logical_unit, ";
$sql .= "hard_drive_scsi_port, hard_drive_size, hard_drive_status, hard_drive_timestamp, ";
$sql .= "hard_drive_first_timestamp, hard_drive_pnpid) VALUES (";
$sql .= "'$uuid', '$hard_drive_caption', '$hard_drive_index', ";
$sql .= "'$hard_drive_interface_type', '$hard_drive_manufacturer', '$hard_drive_model', ";
$sql .= "'$hard_drive_partitions', '$hard_drive_scsi_bus', '$hard_drive_scsi_logical_unit', ";
$sql .= "'$hard_drive_scsi_port', '$hard_drive_size', '$hard_drive_status', '$timestamp', '$timestamp', '$hard_drive_pnpid')";
if ($verbose == "y"){echo $sql . "<br />\n\n";}
$result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql);
} else {
// Already present in database - update timestamp
$sql = "UPDATE hard_drive SET hard_drive_timestamp = '$timestamp', hard_drive_pnpid = '$hard_drive_pnpid' WHERE hard_drive_index = '$hard_drive_index' AND ";
$sql .= "hard_drive_uuid = '$uuid' AND hard_drive_timestamp = '$hard_drive_timestamp'";
if ($verbose == "y"){echo $sql . "<br />\n\n";}
$result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql);
}
}
[/code]

Changes on open_audit.sql

[code]
DROP TABLE IF EXISTS `hard_drive`;
CREATE TABLE `hard_drive` (
`hard_drive_id` int(10) unsigned NOT NULL auto_increment,
`hard_drive_uuid` varchar(100) NOT NULL default '',
`hard_drive_caption` varchar(100) NOT NULL default '',
`hard_drive_index` int(11) unsigned NOT NULL default '0',
`hard_drive_interface_type` varchar(10) NOT NULL default '',
`hard_drive_manufacturer` varchar(100) NOT NULL default '',
`hard_drive_model` varchar(100) NOT NULL default '',
`hard_drive_partitions` int(11) unsigned NOT NULL default '0',
`hard_drive_scsi_bus` varchar(10) NOT NULL default '',
`hard_drive_scsi_logical_unit` varchar(100) NOT NULL default '',
`hard_drive_scsi_port` varchar(10) NOT NULL default '',
`hard_drive_size` int(11) unsigned NOT NULL default '0',
`hard_drive_status` varchar(100) NOT NULL default '',
`hard_drive_pnpid` varchar(200) NOT NULL default '',
`hard_drive_timestamp` bigint(20) unsigned NOT NULL default '0',
`hard_drive_first_timestamp` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`hard_drive_id`),
KEY `id` (`hard_drive_uuid`),
KEY `id2` (`hard_drive_timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[/code]


Can you add this to the svn Version. :wink: :wink:


Top
 Profile  
Reply with quote  
PostPosted: Sat Feb 16, 2008 7:03 am 
Offline
Open-AudIT Fellow

Joined: Thu May 17, 2007 5:47 pm
Posts: 568
Location: Italy
This feature is present since SVN rev. 959
Don't rely on the reported status in case of disk arrays, I'm not sure if this value could be or not accurate in this case.

_________________
Edoardo


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group