Advanced Panelboxes for Confluence | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
|
Earlier, you saw how NightWatchman clients are viewed on the Clients view in the NightWatchman console, and that this view provides two grouping structures (Location and Organization) through which clients are presented. You may have already found that it is difficult to find clients that are buried within the two grouping structures – the search function only works within groups at the lowest tier level, so you must know what group a client is in before you can search for it.
NightWatchman 7 introduced an additional tab on the Clients view labelled Queries. The Queries tab allows an administrator to execute a number of pre-defined queries and display the results in the console using the format of any of a number of predefined views. It is possible to define additional queries and views, but this requires directly editing the AgilityFrameworkReporting database. Once the results have been returned to the console, they can be copied to the clipboard or exported to a CSV file.
One or more machines can be selected from the query results in the console and woken up using a simple right-click action. This is similar in concept to being able to wake up one or more clients within a Location or Organization group, but now you can select the machines you want to wake up using various queries rather than being restricted to your current group definitions. NightWatchman 7 also introduced a feature that allows administrators to define custom actions that can be executed from this right-click menu that can use columns from the query results as parameters in the action command line. For example, you could create an action that opens the NightWatchman log file from a client (or multiple clients) selected in the query results.
In this lab, you will explore the query user interface, have a go at adding a new query and view and then add a custom action that can be executed by right-clicking one or more clients in the query results.
Using Pre-defined Queries and Views
In this exercise, you will observe the queries and display views that are predefined when NightWatchman is installed.
To execute a query, you must select a Query and a Display. The Display defines the columns that will be returned in the results and is directly related to a SQL View in the AgilityFrameworkReporting database. The table below provides the mapping between the Displays and the associated SQL Views.
Query Display | AgilityFrameworkReporting Database View |
Hardware | dbo.vwNWM_Query_Hardware |
Hierarchy | dbo.vwNWM_Query_Hierarchy |
Network adapters | dbo.vwNWM_Query_Network |
Power | dbo.vwNWM_Query_Power |
Software | dbo.vwNWM_Query_Software |
Summary | dbo.vwNWM_Query_Summary |
The Query and Criteria fields help limit and filter the results returned from the selected Display.
The Query will default to All computers and the Display to Hardware. If any query other than All Computers is selected, the Criteria box will be enabled. For some queries, the Criteria field will be a drop-down or combo-box control, which has a number of options you can select, or it will be a free text box where you can simply type your criteria. By default, Obsolete machines are excluded from the results, so if you want to include these you must check the Include obsolete machines in results option.
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Adding Custom Queries and Views
In this exercise, you will learn how the pre-defined queries and views are stored in the AgilityFrameworkReporting database and how to add your own custom queries. For this exercise, you will use an example SQL query and view as it is not within the scope of this course to cover the details of the AgilityFrameworkReporting database or SQL query structure. In your production environment, you can always use 1E Professional Services to define new queries and views according to your requirements if you do not have the skills to do this yourself.
Examining the Pre-defined Queries
The Queries presented in the Query drop-down box in the NightWatchman Console are defined in the AgilityFrameworkReporting database, specifically in the tbNWM_Query_QueryList table. In this task, you will examine one of the pre-defined queries and learn the requirements for defining queries.
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||
|
Code Block |
---|
SELECT DISTINCT [SubNet] AS [Criteria] FROM [dbo].[tbAFR_Dimension_NetworkAdapters] WHERE LEN(Subnet) > 0 ORDER BY [SubNet] |
1ediscussion point |
---|
This 'sub-query' returns a distinct list of subnets from the inventoried Network Adapters and returns these in alphanumeric order in a column named Criteria. This will be used to populate the Criteria dropdown list in the NightWatchman console. The selected option will be substituted in the {CRITERIA} placeholder in the main query in the Sql column. |
1ediscussion point |
---|
CriteriaSql must return a single column, aliased as Criteria, which should be de-duplicated and ordered as it should appear in the drop-down list. |
Adding a Custom Query
You will now learn how to add a custom query to the Query drop-down. The purpose of this task is to show you how custom Queries can be added rather than how to build the SQL query, so you will use a query that has been prepared for you.
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||
|
1ediscussion point |
---|
It is important to ensure the SQL queries used to create custom queries in NightWatchman have been properly tested before inserting into the table for use by the console. Incorrect queries could result in inaccurate data being generated via the queries. |
Examining the Pre-defined Views
In the previous task, you saw that the Query only returns a single column (tbAFR_Dimension_ConfigurationItem.Id). The columns that are displayed in the console when a query is executed are determined by the view selected in the Display drop-down. In this task, you will examine one of the predefined views and learn the requirements for defining views.
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||
|
Code Block |
---|
SELECT [Base].[Id] , [Base].[NetbiosName] , [Base].[DomainName] , [Base].[Obsolete] |
1ediscussion point |
---|
These columns are required in every view and should always be obtained from the predefined vwNWM_Query_Base view, which is then joined with the other database tables that include the columns we want in the result set. |
Adding a Custom View
In this task, you will learn how to add a custom view. Again, we will use a prepared example, as the purpose is to familiarise you with the process rather than the actual SQL coding.
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
|
Working with Console Extensions
The console extensions feature enables an administrator to define custom actions that can be executed against (or using parameters from) the selected items in the Query result set. In this exercise, you will create a simple custom action that will start a Remote Desktop Connection to the selected computer.
Adding a Console Extension
Console extensions are defined in Console.Extensions.xml, which is located in the Console sub-folder of the NightWatchman Management Center installation directory. When the console is first installed, this file has an additional .template extension, which you remove when you are ready to start adding console extensions to the file.
1ediscussion point |
---|
Note that because this is a local file in the Console installation directory, any extensions defined will only be available on the local machine. If you have the NightWatchman Console installed on multiple computers, you can change the location that the console looks for this file to a network share, so the custom actions can be shared by all users. The location of the file is defined in the Extensions.Folder key in the NWM.Console.exe.config file. By default, this key is commented out and the Console installation folder is the expected location of Console.Extensions.xml. |
1evirtualmachine |
---|
1ETRNAP |
1eolstart | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||
|
1ediscussion point |
---|
Note that the custom actions initiated through the console are executed in the security context of the logged-on user – the user must have whatever permissions are required to execute the action. |
1ediscussion point |
---|
Console extensions are essentially command lines executed when initiated. Thus, you can script any custom action within the NightWatchman environment as long as it can be executed via a command line. The command line for remote desktop, for example, is mstsc /v {$netbiosname}. |
Lab Summary
In this lab, you have learned how to use the Query feature of the NightWatchman Console to find clients using various pre-defined queries. You have seen how the results of the query can be modified using the display options. There are a number of common queries and display views pre-defined, but you have also learned how you can create your own queries and display views by editing the database directly.
You then learned how you can extend the functionality of the NightWatchman Console by defining custom command-line actions in Console.Extensions.xml. These actions are then available by right-clicking the query results. The action executes a command line that can include substitution strings for properties of the selected item (such as NetBIOS Name), enabling you to do things like start a Remote Desktop session, ping the computer or open the 1E Agent log files remotely. You use the Scope setting in the console extension definition to determine whether the action should be available to just a single computer, to a set of computers or to a grouping tier. Where an action is applied to a set of computers, the console will generate a comma-separated file containing the ConfigItemID, NetBIOS Name and Domain Name of each computer selected. The action (e.g. a script) would then need to use the {$ComputerListFileName} substitution string to identify the full path and name of that file, then parse the file and execute the desired actions for each row in the file.