Reminders
Question

WUG v15 Active Scripts

15 months ago
OfflineSimon Fisher
Simon Fisher

Hi Guys,

I'm not sure if this is the right place, but here goes anyway.

We are having issues with Critical Monitors, which is a known issue in v15. I was wondering (to overcome this issue) if it's possible (using vbs/jscript) to disable active monitors when Ping goes down, then re-enable then when the monitor comes back up. My theory is this could be a work around for critical monitors until it is fixed in v16 (which isn't due out until July time).

Does anyone know if this is possible or the best way to go about trying this?

Cheers,

Simon

-----
You had this question too1 person has this question.
 
Answered

0 Answers:

9 Replies

OfflinePaul Byers Paul Byers said 15 months ago

I am sure it is possible.  I would be worried about needing to restart the service for it to take affect.  The reason woudl be is you have to modify the database directly and unless the application relizes it (restart of services) it will never take affect.  I had this issues when attempting to runa a script and put things in maintenance.


OfflineRobin Ingmarsson Robin Ingmarsson said 15 months ago

Paul: In this thread http://community.whatsupgold.com/script_library/actions/advanced-device-maintenance-mode

(comments) you will find a script that sends a "change event" notification to WUG. The same change event WUG uses when changing stuff in the web UI. 

Simon: Following Paul's mindset of modifing the database directly, this shouldnt be too hard. What exactly is it that you want under what circumstances? I'll see if I get time to write you a script that does what you want (So.. Give me exact what you need) 

Edit: Added link (Thanks Jason)


OfflineWhatsUp Guru (Jason Williams) WhatsUp Guru (Jason Williams) said 15 months ago

@Robin - I think you forgot the link to the thread.


OfflineSimon Fisher Simon Fisher said 15 months ago

@ Robin - Thanks for your reply. In essence I want to achieve what the critical monitor should do, but doesn't. When the "PING" active monitor goes down, I want to run a script that can then disable any other active monitor on the device, thus achieving the same result as the critical monitor, then when ping comes back up, it can re-enable the active monitors and return to normal.

In my head this would be a simpler fix until V16 is released than going round and adding a new "ping" device for every server to do a device level dependancy.

If you need to know any device specific ID's, please let me know.

Cheers,

Simon


OfflineRobin Ingmarsson Robin Ingmarsson said 15 months ago

Hello Simon, I've finished v1.0 of the script :)

How it works:
You apply an action policy to a ping monitor (on state down & on state up when down has been reached)
What it does:
If device goes down, it checks a field called sStatus on device. This will now have "<MonitorStateID>|Ping". By default, 3 is the monitorstateID for "down". if this field contains "Ping" the script will diable everything but the monitor called "ping" which have a monitorstateID of 3. (Why: So you can have several ping monitors on a device but only the ping with the action policy will stay up/be critical).
If the ping monitor goes up, the script will check the field for "Ping" again. If nothing is returned, the script will update all active monitors on the device to enable.

General warning: Ipswitch does not recommend you to modify the database directly.

Hope it works! Please report back when you've tried it :)

//Robin

Script:

Needs to be changed so it works in your enviroment: 
SQLServer
SqlDB (if non-default DB name is used)
SQLLoginID
and
SQLLoginPW

SqlServer = "10.10.10.10"  'ie. "server1\instance" or "10.0.0.2\instance" , instance can be ignored if using default instance
SqlDb = "Whatsup" ' Name of the whatsup gold database
strConnection = _
"Provider=SQLOLEDB;Data Source=" & SqlServer & ";" & _
"User ID=SQLLoginID;Password=SQLLoginPW;" &_
"Initial Catalog=" & SqlDb & ";"


'constants..Stuff thats needed for various reasons
objDB = context.getDB
context.logmessage objDB & " = objdb "
Const adOpenStatic = 3
Const adLockOptimistic = 3
sysDeviceID = Context.GetProperty("DeviceID")
Set oRS = CreateObject("ADODB.Recordset")
Set objConnection = CreateObject("ADODB.Connection")

'SQL query and opening a recordset with the result'
sqlQuery = "SELECT a.bDisabled as 'disabled', b.sMonitorTypeName as 'monitorname', a.nMonitorStateID as 'State', c.sStatus as 'status' from PivotActiveMonitorTypeToDevice a " &_
"join ActiveMonitorType b on b.nActiveMonitorTypeID = a.nActiveMonitorTypeID " &_
"join device c on c.nDeviceID = a.nDeviceID where a.nDeviceID='" & sysDeviceID & "' "
objConnection.Open strConnection
oRS.Open sqlQuery, objConnection, adOpenStatic, adLockOptimistic

' Checking if there is any monitors that contains "ping" down when script is run. Theory:
' If there is a ping down, that means this should disable all but ping monitor that went down. If not, enable everything as ping isnt down
resInStr = instr(ors("Status"),"Ping")

' If no status down with ping, enable all monits
if resInStr = 0 then
Context.Logmessage"sStatus does not contain ping!"
context.LogMessage "EnableMonitors"
do until oRS.EOF
oRS.Fields("Disabled")=0
oRS.Update
ors.movenext
loop
Else
' If there is a ping monitor that is down, disable all but the ping monitor which is down
context.logmessage "sStatus contains ping!"
do until oRS.EOF
resMonitor = ors("MonitorName")
context.logmessage "DisableMonitorSub on " & resMonitor
if resMonitor = "Ping" then
context.logmessage "resmonitor was ping"
if ors("state") <> 3 then
context.logmessage "resmonitor was ping and not state 3"
oRS.Fields("Disabled")=1
oRS.Update
end if
else
oRS.Fields("Disabled")=1
oRS.Update
end if
ors.movenext
loop
End If

'When done, sending changeevent to WUG so WUG knows stuff hsa been modified'
set oEventHelper = Createobject("CoreAsp.EventHelper")
oEventHelper.SendChangeEvent "2", sysDeviceID, "1"

oRS.Close
Set oRS = Nothing

 


OfflineWhatsUp Guru (Jason Williams) WhatsUp Guru (Jason Williams) said 15 months ago

Be sure to post this in the Script Library Robin.  And we appreciate your disclosure regarding making changes directly to the database.


OfflineWhatsUp Guru (Jason Williams) WhatsUp Guru (Jason Williams) said 15 months ago

On a side note, what is the actual issue you are having with Critical Monitors @Simon?  Have you spoken with support?


OfflineSimon Fisher Simon Fisher said 15 months ago

@Robin - Sorry for the late reply. Thanks a lot for the script. Initial tests look as though this does exactly what I wanted - Will report back once I've tested it a bit further.

@Jason - I have spoken to support and they couldn't offer a fix. The issue I have is critical monitors don't work - they seem to be ignored (in certain circumstances which I have still not isolated). I was told by support it can be when you have 2 or more of the same type of monitor (ie SNMP) which I do. There is no fix for this - but apparently it is sorted out in v16 (which isn't out until atleast July).

I'll report back once I've done some more testing. 

Thanks for all the help!


Would you like to comment?

You must be a member. Sign In if you are already a member.

  • 883 views
  • 1 version
  • 9 replies
  • 3 followers
     
Post Date:
February 27, 2012
Posted By:
Simon Fisher

Related Content

Search this area

About this forum

  • 145k views
  • 2243 topics
  • 55 followers
     

Post questions and find answers for all things related to the Standard and Premium Editions of WhatsUp gold.


Viewed 883 times