Friday, August 16, 2013

Device level context switching

UPDATE: I've developed some code to make this a regular view that can be dragged onto the page without any configuration required.  The following code will create the standalone view and add it to all four device context pages:


UPDATE: I've rewritten this widget to make it easier to implement.  Now instead of having to specify the {Item.ItemID} variable in the browser view URL, the widget just grabs the information from the parent URL.  This is also better because any additional arguments you had in the URL will continue through to the other context pages.  Here's the updated code:


Now all you have to do is point to this widget in your custom content directory.

Enjoy!

You may not know about it, but NPC classifies every device as either a router, switch, server, or device.  The device category is for every type of device that isn't a router, switch, or server.  This is too bad because NetVoyant actually has an extendable list of device classifications; you can make as many as you want.  However any additional classes will show up in NPC as 'devices' because NPC doesn't understand them.  This is fine in most cases.  However, certain cases will cause problems.

For example, if I have an F5 load balancer and I'm monitoring the device in SuperAgent as well as NetVoyant, NPC has to choose whether to classify the device as a server (as SuperAgent reports it) or as a device (since NetVoyant either classifies it as 'other' or 'load balancers' if you've classified it).  Turns out the NV classification is last on the list.  If a device is monitored by RA or SA, NPC will classify it as a router or server, respectively, regardless of what classification exists in NV.

In this case, what I usually do is instruct customers how to switch from one context page to another after drilling in.  For example, after I drill into the F5 and get to the server page, I would update the URL to read pg=d instead of pg=s.  This loads the device page for the F5 instead of the server page.  This can be handy since the device page may have specific F5 views on it that don't appear on the server page.
In order to make this easier, I built a simple html page that can be loaded into a browser view that will allow quick switching between all four context view types.  Here's the page:

<html>
<script type="text/javascript">
var url1='<a target="_top" href="/npc/Default.aspx?pg=';
var str=location.search;
str=str.replace("?ItemID=","");
document.write(url1 + 'r' + '&DeviceID=' + str + '">Router</a> ');
document.write(url1 + 'sw' + '&DeviceID=' + str + '">Switch</a> ');
document.write(url1 + 'd' + '&DeviceID=' + str + '">Device</a> ');
document.write(url1 + 's' + '&DeviceID=' + str + '">Server</a> ');
&nbsp;<a target="_blank" href="http://stuart.weenig.com/2012/08/device-level-context-switching.html"><img src="/npc/images/DialogQuestion.gif" border=0></a>
</script>
</html>

Link to this page from a browser view with a title like 'View this device as a...' and a URL like this:
/content/viewdeviceas.html?ItemID={Item.ItemID}
As long as this page is named 'viewdeviceas.html' and it's hosted under a virtual directory on NPC's IIS web server with an alias of 'content' it should load just fine.  Give it a height of 33, turn off the border and hide the scroll bars.  This makes an excellent small browser view that can go right at the top of the page, displayed right under the page tabs.

No comments:

Post a Comment