Discovery and Inventory Group

 View Only

Using Custom Inventory for User Selectable Maintenance Windows 

Dec 22, 2009 10:31 AM

OK, so it's not a traditional Custom Inventory script.  It is, however, a novel use of Custom Inventory to put some power in the hands of your users to control their own environment.  This process allows your users to tell you when you can beat their machines up without interrupting critical work.  A popular use case is for a user to inform the Symantec Management Platform when they take their lunch break each day.  This is one of most useful time periods, particularly in these days of "Green IT" initiatives, because processor and disk intensive processes are difficult to run in "after hours" times, as many companies have aggressive policies of shutting PCs down after-hours, traditionally an opportunity for IT to do much-needed maintenance and scanning of PCs.

 

Creating a Data Class to Hold the Data

First up, we need to create a Custom Inventory class to hold the information from the user interface.  Under the Settings Menu, select "All Settings".   Then go under "Discovery and Inventory" and "Inventory Solution" and select "Manage Custom Data Classes":
FirstMenu.png

Select the New Data Class button and call the data class "User Maintenance Windows".  You will then need to add two attributes to the data class:  An "Index" of type "Int" and a "Window" of type String 50:

Attributes.png

Finally, beside the "New data class" button, click on the details button.  The important thing hers is to grab to data class GUID:

DCDetails.png

 

Creating the User Interface

You can do this in a number of ways.  Myself, I created my UI in Visual Studio 2005 and wrote the code in C#.  The code itself will run on any computer running .NET 2.0+, and we have fairly universal coverage of that, plus as we're distributing it with the Software Management Framework, we can create a .NET distribution package and create a dependency upon it anyway.

So, I created a pretty simple Windows Form to select maintenance windows from a Check Box List control, along with a "Submit" button.  You can dress this up a lot over my example!  The extra window over to the right is a debug output window you'll see in a bit when we get into the code.  

Form.png

The only code I have here is for the "button1_Click" event.  And it's pretty straightforward:

 

private void button1_Click(object sender, EventArgs e)
{
    Guid maintdc = new Guid("bf11710c-c90b-4f11-a42a-5f983a6c77d1");  //This guid came from when we created the DC
    AeXNSEvent.AeXNSEvent nse = new AeXNSEvent.AeXNSEvent();
   
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}";  // From the Custom Inventory manual, don't change this one
    nse.Priority = 1; //Again, don't mess with this.

    AeXNSEventDataClass dc = nse.AddDataClass("User Maintenance Windows");
    dc.FirstColumn = 0;

   AeXNSEventDataBlock db = nse.AddDataBlock(dc,nse.DefaultResource);
   db.PartialUpdate = 0;
 
    foreach (int current in checkedListBox1.CheckedIndices)
    {

        AeXNSEventDataRow dr = db.AddRow(0);
       
        dr.AddField("Index");
        dr.AddField("Window");
        dr.SetField(0,current);
        dr.SetField(1, checkedListBox1.Items[current].ToString());

    }
    nse.Send("AltirisNS8");  //This is your NS
    textBox1.Text = nse.Xml; //Debug code to dump all the XML out to a text box on screen to look at...won't be in final version
   
}

Create Filters for Your Windows

OK, so now you have a way for your users to get information about when you can hammer their computers back to you.  This provides you with a flexible way to run intensive scans, while providing the users with the opportunity to have some control of their environment!  What's best, the users require zero rights to the console to effect these changes!

Now you need to create filters for each of your maintenance windows.  These are simple Raw SQL filters based on the data class you just created.  For example, to use the Mid-0300 filter, simply use this SQL:
 

select
    _resourceguid as guid
from
     Inv_User_Maintainance_Windows
where
    window = 'Mid-0300'

You need to repeat this process for each window you created in your UI.  One nice thing about how the maintenance windows work is that you don't have to do all the permutations and combinations of maintenance windows, you can stick to making one for each, as if you are part of 2 or more maintenance windows, you can simply add the user to more than one.

Create Your Maintainance Windows

Finally, for each of your windows, create a maintenance window and assign that maintenance window to your filter you just created.  Finally, create a "default" maintenance window, and exclude each of the "User" filters from it, so that even when a user hasn't selected anything you still have something for a window!

MaintWindow.png
 

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jan 18, 2010 01:22 PM

Thank you for the thorough description and novel use of custom inventory. Great job!

Dec 22, 2009 11:36 AM

I really like this idea.  A great way to think outside the box with Custom Inventories.

Related Entries and Links

No Related Resource entered.