UPDATE: An additional tool now available for download lets you set the default timeframe for a page. Do you have a page that you always want to show the last 24 hours of data? Just add this widget.
UPDATE: The newest version is out. I updated the script to fix a problem when going back to NPC when a page using the default page context setter was used. I also have released a modified version that allows you to set the default IP SLA test type on an IP SLA test report page.
Page IPSLA Type Default
Page Group Default
UPDATE: I went back and simplified the code. I also built some intelligence into the code walking you through the steps necessary to configure it. Now, you don't even have to read and manually parse the URL to figure out what GroupID to use.
Here are the new instructions:
- Add a browser view to the page and point it to the script without any parameters in the target URL property.
- The widget shows that a group hasn't been configured and instructs you how to select a group so a GroupID can be obtained.
- You select a group using the built in controls.
- The widget shows you what the target URL should be.
- You edit the browser view and modify the target URL as instructed.
- The widget confirms that it has been properly configured and instructs the user to optionally minimize the widget.
UPDATE: I went back and worked on a way to make this easier to do. Now, no interaction is needed beyond the initial installation.
Usage: First of all, this widget needs to be on the page for which you want to set the default page context. The second part is to pass the group number through to the widget by adding a groupnumber parameter to the url. So, set the browser URL to something like this:
The group number defined in this way will be interpreted by the script and the page context will change accordingly. If the groupnumber parameter is not defined, the browser view will show some help content.
The script itself, has only changed slightly. Instead of relying on you to set the group number within the script, the first half of the script reads the group number from the browser view's browserurl property. It's looking for a parameter called 'groupnumber'. The second part of the script is just like before. Now that the group number isn't tied to the widget code, the same widget can be reused on any page, where the difference is the parameter passed in the browserurl property on that page.
Here is the actual content of the script:
You can get the file on the right side of this page under the section called "My Tools". Put this html file into your custom content directory. Then add a browser view to your page, either at the very top or the very bottom. I put it at the very top and change the title to "This page defaults to /All Groups/Applications/MyApp". Point the browser to the widget html file in your custom content directory and set the height to 0. You can set it to a non-zero value, but I only use that for debugging, so it doesn't always show useful data. Setting the height to 0 effectively minimizes the browser view so it's only taking up space for the title.
ORIGINAL POST
There are three different types of pages in NPC: Overview, device, and poll instance. Technically, there are more, but they aren't important to this post. In fact, only the Overview pages factor in here. Historically, NPC overview pages have a page context that filters the views on the page according to the group specified in the group context. There are several mechanisms in place that make this handy (i.e. page context following, bread crumbs, permission levels, etc.). However, one feature that is missing is the ability to set the default context for a page. What I mean is overriding the currently selected page context (selected while on a report to which the user previously navigated) and setting a new context.
For example, I have an application that is segmented into production and beta, and we're monitoring both environments in SuperAgent and NetVoyant. So, logically, I created a group with the application name, then created a prod and a beta group underneath that group. I placed all the server and application CIs into those sub groups. Then I built a page that shows all the relevant SA and NV data. The page is a generic page and could be used for other applications, but I want this one to only be for my application. This means, there are three possible contexts I would like to apply to the page: MyApp (the parent group), MyApp Prod, and MyApp Beta.
The easiest part of solving this problem is look at an easy way to set the children groups as context; in other words, to filter the report to either show MyApp Prod or MyApp Beta. This can be done today without any real trickery (e.g. it's designed to be used this way). I simply put a group list on the page whose view context was fixed to the parent group. This means that the group list will always show my two children groups and the bonus is that they're both links. Clicking on either link sets the current page to that group's context. Problem solved.
The other side of the coin is that until you click on one of the sub groups in the group list, the page defaults either to the current user's 'My Groups' or to the current session's page context (the context selected on a previously navigated to report). Ideally, I'd like to make it so that when this page loads, the page context switches to my parent group no matter what the previous group was.
Unfortunately, there's no real way to do this using the built in options. I could tell the users to click on one of the children groups then click on the bread crumb link to get back to the parent, but that's too many clicks. Naturally, I set about designing something to force a change in the page context when this page loads.
There are two components to this solution: the script and the browser view. The script changes the page context. The browser view actually puts the script onto the page. Without further ado, here's the script:
There are a couple of things to know about this script. This script as written works for my group. Notice on line 4 that a groupnumber variable is specified. This is the ID number of my parent group. In your case, it will be different. It's easy to find out the group number. Simply navigate to your page and set the page context to the desired group. Then look at the URL for the GroupID parameter. That's the group number that needs to be filled in here.
Simply save this script to an html file. I recommend saving the html file with the name of the group number so I know which one to put on the page. Put the html file into your custom content directory. The add a browser view to your page, either at the very top or the very bottom. I put it at the very top and change the title to "This page defaults to /All Groups/Applications/MyApp". Point the browser to your html file in your custom content directory and set the height to 0. You can set it to a non-zero value, but I only use that for debugging, so it doesn't always show useful data. Setting the height to 0 effectively minimizes the browser view so it's only taking up space for the title.
I'll probably end up needing to apply this to other pages, so I may end up moving the script into a .js file as a function then calling the function from the html in my custom content directory. I tried to do that already, but NPC wasn't cooperating (anybody with fancy javascript skills who wants to help me get it working, let me know in the comments below). For now, to replicate this for another page, just copy the html file, rename it, and change the groupnumber value.
No comments:
Post a Comment