Client Management Suite

 View Only

Inventory C: Drive Fragmentation and Defrag Using a Custom Inventory and Software Delivery 

Apr 13, 2009 01:46 PM

Need to know if the c: drive on your inventoried systems are fragmented? We do, we also need to defrag them regularly. Here is how I am going to do it. I am piloting this as I type this documentation.

I have written a script using Wise Scripting. I have attached a ZIP file containing the WSE file and the compiled EXE file.

The script runs the defrag.exe command in WindowsXP with -a to analyze the fragmentation, then dumps it to a temporary txt file. It then does some parsing of that file to get the level of fragmentation and whether a defrag is suggested or not. Then it turns those into variables. It then uses the information it has found to create an NSI file for Altiris Inventory Solution. After Inventory Solution collects this info there is now a table in the Altiris DB named Inv__DriveFragmentation_Inv.

To get this into Inventory copy the DriveFragCustInv.EXE file into the \\server\NSCap\Bin\Win32\X86\Inventory Solution folder on your NS server. Then create an INI file named AeXInvSolnDriveFrag1.ini with the following:

DriveFragCustInv.EXE
aexnsinvcollector.exe /hidden /nsctransport /v default /useguidOpen up Inventory Solution in NS. 

In NS setup the Inventory package and task

View > Solutions > Inventory Solution

Expand 'Tasks > Windows > Inventory Tasks' then select one of your current tasks. For example, Software Inventory.

Click 'Go To Program'. You will get the page to modify the package.

Click the new button and enter the following then click Apply and close the window:

Name: Drive Fragmentation definition file
Command line: aexinvsoln.exe /hidden /s AeXInvSolnDriveFrag1.ini
Estimated disk space: 124
Estimated run time: 1
Terminate after: 10
After running: No action required
Start window: Hidden
Run with rights: System Account
Program can run: Whether or not a user is logged on
Minimum connection speed: No network connection required

Right click on 'Software Inventory' and choose Clone. Give the new task a name like 'Drive Fragmentation Inventory'

Select Enable for the new task. Choose program name 'Drive Fragmentation definition file'. Select the collection(s) you want this to run against and when you want it to run.

Here is an example of my task.

When the systems start to report in they will run this custom inventory and the table will be created in the Altiris DB.

Here is an example of a report I created to gather this info. In 'Reports > All Reports' right click on User Defined and choose 'New > Report'

In the report wizard enter a name for your report and choose Enter SQL Directly. Insert the follow SQL statement and click Finish:

select vc.[Name], 
		df.[Fragmentation] as 'C: Drive Fragmentation', 
		df.[Recommendation] as 'Microsoft Recommended Action' ,
		vc.[guid] as '_Resourceguid'
 
from dbo.inv__DriveFragmentation_Inv df 
	left join dbo.vComputer vc on vc.[guid] = df.[_Resourceguid] 
 
order by vc.[Name]

You can now run your report to get the amount of fragmentation on your systems C: drive.

Now you can create a collection of systems that need to be defragmented.

In your console click View > Resources

Expand Collections and right click on the folder you want your collection to reside in and choose New > Collection.

Type a name for your collection, for example, 'Systems that need their C: drive defragmented'.

In the Query section select Resource Type of Computers then click where is says 'No Filters'. Click the 'New Filter...' button. Select the Inv__DriveFragmentation_Inv table, the Recommendation field, and the value of 'You Should defragment this volume'.

Click OK, the Manage Filters window should now show the filter.

Click OK and Apply to finish creating the collection.

Now you can create a Software Delivery task to run against this collection and defragment the drives that need it. I'm sure there are other ways to use task server, etc against the collection. I just don't currently have that implemented so I am going 'old school'. I could have even written the Wise script to do the defrag at the time of the inventory, but I wanted to keep the process' separate, just in case I want to stop defragging and keep getting the inventory.

For example I am running my custom inventory at noon and will run the Software Delivery task every day at 8PM against this collection.

Click View > Solutions > Software Delivery. Expand Tasks > Windows > Software delivery Tasks, then click on the 'Wizard and Status'. You can use this Wizard to create the package to defrag and the task to do it.

Click the Run button to start the Wizard.

Select Create and deliver a new package of software. For the Source select that the package does not contain source files. In the command line type: defrag.exe c: Then click Next

Select System Account for the run rights. Select whether or not a user is logged in and de-select User Input Required. Change the window style to hidden. Click Next

Select your collection of systems that need their drive defragged. Select a time to run this daily, remember this won't run against all systems daily, just the systems in the collection. I also select to run this as soon as possible after the time, this may not be an option you want in your environment. I also select WOL and user can run the task.

Change your Software delivery task name, Package name, and program name to something that makes sense in your environment and click OK. See my screenshot.

You should now have a SWD task similar to this one.

Your mileage may vary with this process. I am just starting out with this process. I'd like to know if this works for others or is necessary in other peoples environments. With budget crunches and such we need to make our systems last longer that the traditional 3 years and we are hoping this will help some with performance.

Statistics
0 Favorited
0 Views
15 Files
0 Shares
0 Downloads
Attachment(s)
jpg file
789241-01.jpg   25 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-02.jpg   44 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-03.jpg   31 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-04.jpg   38 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-05.jpg   19 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-06.jpg   45 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-07.jpg   32 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-08.jpg   5 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-09.jpg   47 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-10.jpg   49 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-11.jpg   64 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-12.jpg   67 KB   1 version
Uploaded - Feb 25, 2020
jpg file
789241-13.jpg   62 KB   1 version
Uploaded - Feb 25, 2020
doc file
Cust Inventory and SWD task to defrag.doc   1.41 MB   1 version
Uploaded - Feb 25, 2020
zip file
DriveFragCustInv.zip   114 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Comments

Jun 16, 2010 04:17 PM

There is no data class for this. When the inventory is collected the table gets created. You may need to give NS a little time to catch up and create the table. All the infomation it needs to crate the table should be in the NSI inventory file.

Jun 16, 2010 02:07 PM

First of all thanks for the article. You mention that "After Inventory Solution collects this info there is now a table in the Altiris DB named Inv__DriveFragmentation_Inv" Did you already create this data class or is this supposed to created it for you? I ran through this exercise and I do not see this table in my database nor does the report work. If you created the dataclass first, can you tell me what attributes did you use?

Apr 10, 2010 12:07 PM

Nice Post

Mar 25, 2010 02:02 PM

The .exe for the custom inventory would need to be modified.  Do you have Wise Studio?  If so you could edit the .WSE file.  I suppose it could also be written to take a command line parameter, but I'm not sure how the INI file would handle it, I have never tried that.

If you don't have Wise I will try to find some time to modify it and post it to this article.

Patrick

Mar 18, 2010 03:03 PM

so Patrick, how can we modify this to report on the D drive (or any other drive besides c)?

Jan 11, 2010 12:21 PM

ok thanks, it didn't fail or error or anything which is good, but then again I don't have a wise server...i'll have to keep these settings in mind if i ever put one up.

so far so good!

Jan 11, 2010 12:06 PM

Not sure, but that is the name of my Wise server.  Must be some background noise that Wise puts in during the compile.

Jan 11, 2010 11:43 AM

Mr. Calvert

I was looking at the code in the WSE and I am unfamiliar with the lines:

WamDB Index=\\deploy2\Wise Share Point\
and
Variable Default4=\\deploy2\Wise Package Studio\WISESC~1

Can you comment on what they do exactly?

Thanks

Related Entries and Links

No Related Resource entered.