-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c4e7c11
Showing
12 changed files
with
573 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
############################################################################### | ||
## OCSINVENTORY-NG | ||
## Copyleft Léa DROGUET 2022 | ||
## Web : http://www.ocsinventory-ng.org | ||
## | ||
## This code is open source and may be copied and modified as long as the source | ||
## code is always made freely available. | ||
## Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt | ||
################################################################################ | ||
|
||
package Apache::Ocsinventory::Plugins::Driveinfos::Map; | ||
|
||
use strict; | ||
|
||
use Apache::Ocsinventory::Map; | ||
$DATA_MAP{driveinfos} = { | ||
mask => 0, | ||
multi => 1, | ||
auto => 1, | ||
delOnReplace => 1, | ||
sortBy => 'NAME', | ||
writeDiff => 0, | ||
cache => 0, | ||
fields => { | ||
NAME => {}, | ||
DRIVELABEL => {}, | ||
DRIVELETTER => {}, | ||
DRIVETYPE => {}, | ||
FILESYSTEM => {}, | ||
CAPACITY => {}, | ||
FREESPACE => {}, | ||
|
||
} | ||
|
||
}; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PerlModule Apache::Ocsinventory::Plugins::Driveinfos::Map; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# driveinfos | ||
Retrieve volumes returned by Win32 Volume | ||
|
||
Powershell script used by the agent gets drives from win32_logicaldisk (already returned by the agent core) and win32_volume, and compares the outputs. | ||
If entries in win32_volume are not found in win32_logicaldisk output, they are added to the plugin's data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# script retrieves drives from win32_logicaldisk and win32_volume | ||
# both outputs are compared, if entries in win32_volume are not found in win32_logicaldisk output, | ||
# they are added to returned data | ||
$drives = Get-WmiObject -Class Win32_LogicalDisk | select DeviceID | ||
$volumes = Get-WmiObject Win32_Volume | ||
|
||
# both drives and volumes are not empty | ||
if ($drives -and $volumes) { | ||
foreach ($volume in $volumes) { | ||
foreach ($drive in $drives) { | ||
$match = 1 | ||
# drive letter does not equal volume letter or drive letter is empty | ||
if ( $drive.DeviceID -eq "" -or $drive.DeviceID -ne $volume.DriveLetter) { | ||
$match = 0 | ||
# volume does correspond to a drive | ||
} else { | ||
break | ||
} | ||
} | ||
|
||
if ($match -eq 0) { | ||
# translate numeric drive type to string value | ||
switch ($volume.DriveType) { | ||
0 { $driveType = "Unknown" } | ||
1 { $driveType = "No Root Directory" } | ||
2 { $driveType = "Removable Disk" } | ||
3 { $driveType = "Local Disk" } | ||
4 { $driveType = "Network Drive" } | ||
5 { $driveType = "Compact Disc" } | ||
6 { $driveType = "RAM Disk" } | ||
} | ||
|
||
# get driveletter | ||
if ($volume.DriveLetter -eq '' -or $volume.Name -match "^[A-Z]:") { | ||
$driveLetter = $Matches.0 | ||
} else { | ||
$driveLetter = "" | ||
} | ||
|
||
|
||
$xml += "<DRIVEINFOS>`n" | ||
$xml += "<NAME>"+ $volume.name +"</NAME>`n" | ||
$xml += "<LABEL>"+ $volume.label +"</LABEL>`n" | ||
$xml += "<DRIVETYPE>"+ $driveType +"</DRIVETYPE>`n" | ||
$xml += "<DRIVELETTER>"+ $driveLetter +"</DRIVELETTER>`n" | ||
$xml += "<FILESYSTEM>"+ $volume.FileSystem +"</FILESYSTEM>`n" | ||
$xml += "<CAPACITY>"+ ($volume.Capacity /1MB) +"</CAPACITY>`n" | ||
$xml += "<FREESPACE>"+ ($volume.FreeSpace /1MB) +"</FREESPACE>`n" | ||
$xml += "</DRIVEINFOS>`n" | ||
} | ||
} | ||
} else { | ||
$xml += "<DRIVEINFOS />" | ||
} | ||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | ||
[Console]::WriteLine($xml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
//==================================================================================== | ||
// OCS INVENTORY REPORTS | ||
// Copyleft Léa Droguet 2022 | ||
// Web: http://www.ocsinventory-ng.org | ||
// | ||
// This code is open source and may be copied and modified as long as the source | ||
// code is always made freely available. | ||
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt | ||
//==================================================================================== | ||
|
||
if(AJAX){ | ||
parse_str($protectedPost['ocs']['0'], $params); | ||
$protectedPost+=$params; | ||
ob_start(); | ||
$ajax = true; | ||
} | ||
else{ | ||
$ajax=false; | ||
} | ||
print_item_header($l->g(51000)); | ||
if (!isset($protectedPost['SHOW'])) | ||
$protectedPost['SHOW'] = 'NOSHOW'; | ||
$form_name="driveinfos"; | ||
$table_name=$form_name; | ||
$tab_options=$protectedPost; | ||
$tab_options['form_name']=$form_name; | ||
$tab_options['table_name']=$table_name; | ||
echo open_form($form_name); | ||
$list_fields=array( $l->g(51001) => 'name', | ||
$l->g(51002) => 'drivelabel', | ||
$l->g(51003) => 'drivetype', | ||
$l->g(51004) => 'driveletter', | ||
$l->g(51005) => 'filesystem', | ||
$l->g(51006) . ' (MB)' => 'capacity', | ||
$l->g(51007) . ' (MB)' => 'freespace', | ||
); | ||
$list_col_cant_del=$list_fields; | ||
$default_fields= $list_fields; | ||
$sql=prepare_sql_tab($list_fields); | ||
$sql['SQL'] .= "FROM $table_name WHERE (hardware_id=$systemid)"; | ||
array_push($sql['ARG'],$systemid); | ||
$tab_options['ARG_SQL']=$sql['ARG']; | ||
$tab_options['ARG_SQL_COUNT']=$systemid; | ||
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del); | ||
echo close_form(); | ||
if ($ajax){ | ||
ob_end_clean(); | ||
tab_req($list_fields,$default_fields,$list_col_cant_del,$sql['SQL'],$tab_options); | ||
ob_start(); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hookstore> | ||
<hook type="lang"> | ||
<value>en_GB</value> | ||
<value>fr_FR</value> | ||
</hook> | ||
<hook type="cdentry"> | ||
<identifier>cd_driveinfos</identifier> | ||
<translation>51000</translation> | ||
<category>hardware</category> | ||
<available>driveinfos</available> | ||
</hook> | ||
</hookstore> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"displayName" : "Drive Infos", | ||
"author" : ["Léa DROGUET"], | ||
"contributor" : [], | ||
"supportedAgent" : ["Windows"], | ||
"version" : "1.0", | ||
"licence" : "GPLv2", | ||
"description" : { | ||
"fr" : "Remonte les disques récupérés par Win32 Volume", | ||
"en" : "Retrieve drives returned by Win32 Volume" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* This function is called on installation and is used to create database schema for the plugin | ||
*/ | ||
function extension_install_driveinfos() | ||
{ | ||
$commonObject = new ExtensionCommon; | ||
|
||
// Drop table first | ||
$commonObject -> sqlQuery("DROP TABLE `driveinfos`;"); | ||
|
||
$commonObject -> sqlQuery("CREATE TABLE `driveinfos` ( | ||
`ID` INT(11) NOT NULL AUTO_INCREMENT, | ||
`HARDWARE_ID` INT(11) NOT NULL, | ||
`NAME` VARCHAR(255) DEFAULT NULL, | ||
`DRIVELABEL` VARCHAR(255) DEFAULT NULL, | ||
`DRIVETYPE` VARCHAR(255) DEFAULT NULL, | ||
`DRIVELETTER` VARCHAR(255) DEFAULT NULL, | ||
`FILESYSTEM` VARCHAR(255) DEFAULT NULL, | ||
`CAPACITY` INTEGER(11) DEFAULT NULL, | ||
`FREESPACE` INTEGER(11) DEFAULT NULL, | ||
PRIMARY KEY (`ID`,`HARDWARE_ID`) | ||
) ENGINE=InnoDB ;"); | ||
} | ||
|
||
/** | ||
* This function is called on removal and is used to destroy database schema for the plugin | ||
*/ | ||
function extension_delete_driveinfos() | ||
{ | ||
$commonObject = new ExtensionCommon; | ||
$commonObject -> sqlQuery("DROP TABLE `driveinfos`;"); | ||
} | ||
|
||
/** | ||
* This function is called on plugin upgrade | ||
*/ | ||
function extension_upgrade_driveinfos() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
51000 Drive Information | ||
51001 Name | ||
51002 Label | ||
51003 Drive Type | ||
51004 Drive Letter | ||
51005 File System | ||
51006 Capacity | ||
51007 Free Space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
51000 Informations Disques | ||
51001 Nom | ||
51002 Label | ||
51003 Type | ||
51004 Lettre | ||
51005 Sytème de fichiers | ||
51006 Capacité | ||
51007 Espace libre |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.