''' This script unmanages a Network Performance Monitor Node' Modify the script to include the IP address you would like to unmanage instead of 10.0.0.1' 'Option Explicit Dim Service Dim Application Dim NetPerfMon Dim NetworkNode On Error Resume Next Err.Clear ' ' Connect to the SolarWinds Network Performance Monitor ' Service and get a handle to the running NetPerfMon Engine ' The Network Performance Montior Service should already ' be running ' ' This method only works with the Orion version of Network ' Performance Monitor ' Err.Clear ' Get link to the Running Service Set Service = CreateObject("NetPerfMonService.RunningService") ' Get a Link to the Application Object Set Application = Service.GetAppObject ' Get a Link to the Polling Engine Set NetPerfMon = Application.NetPerfMonEngine If Err <> 0 Then Wscript.Echo "Cannot attach to Network Performance Monitor." & vbCrLf & _ Err.Description Else ' UnManage a Node Set NetworkNode = NetPerfMon.NetObjects.FindNodeByIP("10.0.0.1") NetworkNode.Unmanaged = True NetworkNode.UnManageUntil = #5/1/2005# End If Set NetworkNode = Nothing Set NetPerfMon = NothingEnd Sub
I'm also interested in scripting nodes as unmanaged via a script. Orion seems to roll it back to managed after about 1 minute or two. So, My problem isn't exactly getting it to set to unmanaged but setting to unmanaged it having it stay. Can someone please verify my fields and especially the "UnmanagedUntil" field. thanks in advance.
(Note: I have interfaces ready to be set as unmanaged but I'm just trying to get the nodes to stay first)
use strict;use DBI;use Date::EzDate;my $nodeid = shift or die "NodeID?\n";chomp($nodeid);my $days_suppressed = 2; #Nodesmy $unman="UPDATE Nodesset Unmanaged=1,UnManageUntil=DATEADD(day,$days_suppressed,GETDATE()),Status=9,StatusLED='UnManaged.gif',StatusDescription='Node status is Unmanaged',Severity=0,GroupStatus='UnManaged.gif'where NodeID=$nodeid";=pod# Interfacemy $unman_int="UPDATE Interfacesset AdminStatus=9,OperStatus=9,Status=9,StatusLED='UnManaged.gif',AdminStatusLED='UnManaged.gif',OperStatusLED='UnManaged.gif'where NodeID=$nodeid";=cut#'5/4/2007 12:51:07 PM'my ($sth, $sth2);if ($nodeid) { my $db = "NetPerfMon"; my $dbh = DBI->connect('DBI:ODBC:DSN', 'user', 'password') || die "Can't connect\n$!\n"; $dbh->do("use $db"); $sth = $dbh->prepare($unman) || die "Can't Prepare " . $dbh->errstr();# $sth2 = $dbh->prepare($unman_int) || die "Can't Prepare " . $dbh->errstr(); $sth->execute() or die "Can't Execute " . $sth->errstr();# $sth2->execute() or die "Can't Execute " . $sth2->errstr(); $sth->finish;# $sth2->finish; $dbh->disconnect;} else { print "Bye\n";}exit;
' ' Script Name: unmanage.vbs' Author: Matthew Robson' Desciption: This script unmanages Orion Network Performance Monitor Nodes from a txt list for a specified time' Time is specified in line 48' Date: 01/20/10' ' Option Explicit Dim Service Dim Application Dim NetPerfMon Dim Fso Dim InputFile Dim NetworkNode Dim HostIP Dim Status Dim Counter Dim CurrentDateTime Dim UnmanageDateTime Dim DateFormat Dim TimeFormat Dim OrionDateTime ' Get link to the Running Service Set Service = CreateObject("NetPerfMonService.RunningService") ' Get a Link to the Application Object Set Application = Service.GetAppObject ' Get a Link to the Polling Engine Set NetPerfMon = Application.NetPerfMonEngine ' Configure Input File Set Fso = CreateObject("Scripting.FileSystemObject") Set InputFile = fso.OpenTextFile("c:\test\ServerIP.txt") ' Complete the following for each server in the text file Do While InputFile.AtEndOfStream <> True Status = 0 HostIP = InputFile.ReadLine CStr(HostIP) Counter = 1 ' Try to unmange server 10 times Do While Status <> 9 If Counter = 10 Then exit Do End If ' Collect current date time and configure time to remange CurrentDateTime = Now ' DateAdd (n = minutes, h = hours, d = days) UnmanageDateTime = DateAdd("n", 15, CurrentDateTime) DateFormat = FormatDateTime(UnmanageDateTime, 2) TimeFormat = FormatDateTime(UnmanageDateTime, 4) OrionDateTime = DateFormat &" " &TimeFormat ' Unmange Node Set NetworkNode = NetPerfMon.NetObjects.FindNodeByIP(HostIP) NetworkNode.Unmanaged = True NetworkNode.UnManageUntil = OrionDateTime Status = NetworkNode.Status Counter = Counter + 1 Loop Loop Set NetworkNode = Nothing Set NetPerfMon = Nothing