WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples From Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Communicate with Big Brother Network Monitor Server

 Keywords: Winsock IP SOCKETS Big Brother Network Monitor Server BBNT.exe

I don't know if anyone's interested but here's a little chunk of code that contains UDFs for communicating directly with a Big Brother Network Monitor Server over IP sockets. I use these functions to write custom Big Brother tests for Win2K3 etc. With this library, you don't need to rely on BBNT.exe to get your test results to the Big Brother Server.

I also posted EventMon - a service for Windows OSs to monitor all system event logs - allowing Big Brother to serve as a central log monitor/alerter. BBNT is limited to Application and System Event Logs only. EventMon can even read the Security log and post user, group and other changes. It's completely configurable. Check out www.deadcat.net.au - look for EventMon.

Jim Graczyk



;
;     Winbatch Big Brother BTF Library
;
;        This library is intended to be used with Big Brother BTF 2.08
;        It may work fine with commercial versions as well but the
;        Better Than Free version does all I need so I've never seen
;        the commercial versions.
;
;        This library can be used to create custom tests for BB using Winbatch.
;        Typically one would create a program that is run as a service (.exs)
;        that executes at a fixed frequency.  You can send Status for display,
;        alarms to trigger pages, as well as enable and disable tests.  The notes
;        and data messages also function, though I don't see great value in them.
;        The datamsg message is posted to the BB server but I cannot determine to
;        what end as the message doesn't seem to be displayed anywhere.  The notes
;        message also seems to work in that the server produces a link once a note
;        is sent, however it appears the note will only work if there is a single bb
;        Page.  If there is more than one BB page, you have to copy all html out
;        of the default notes dir into a notes directory on each BB page.
;
;        This library includes the following functions:
;
;              BBSendStatus     - Sends a status message to a BB display server
;              BBSendAlarm      - Sends an alarm to a BB page server
;              BBSendEnable     - Enables a node or test on a BB server
;              BBSendDisable    - Disables a node or test on a BB server
;              BBSendNotes      - Sends a note for a node to a BB server
;              BBSendData       - Sends a Data message to a BB server for a node
;              BBSend           - routine for raw communications with a BB server
;                                 used by the other functions.
;
;===================================================================

#DefineFunction BBSendStatus(BBHost,BBPort,test,color,header,mess,expirestr,UseFQDNs)
; Send a status message
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; test is the name of the test in text to which BB will apply the
;     status message
; color is a lowercase text bigbrother color and should be red, yellow, green,
;     blue, purple or clear
; header is the text you want to be displayed as the title of the status msg.
; mess is one or more lines to make up the bulk of the status report.  lines in
;     mess should be separated by @crlfs embedded within the string
; expirestr is the amount of time the status being sent is good for before
;     BB issues a purple.  This value overrides the expiration time for the server
;     and can be in days, hours or mins (15m is 15 minutes, 30d is 30 days)
; UseFQDNS can be 1 or 0, @true or @false and toggles use of fully qualified
;     domain names.  Set this to match your server's setting.
;

   If UseFQDNs==@TRUE
      Computername = ComputerNameGet( 107 )
   Else
      Computername = ComputerNameGet( 106 )
   EndIf

   servicename = StrReplace(computername,".",",")
   servicename = StrCat(servicename,".",test)
   now = TimeYmdHms()

   b=TimeJulianDay(now)
   c=(b+5) mod 7
   day=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat", " ")
   EventDate = StrCat(StrSub(now,6,2),"/",StrSub(now,9,2),"/",StrSub(now,1,4))
   Eventtm2 = StrSub(now,12,-1)
   If expirestr <> "" Then expirestr=StrCat("+",expirestr)

   out=StrCat("status",expirestr," ",servicename," ",color," ",Eventdate," ",eventtm2," [",computername,"] ",Header)
   If mess <> ""
      out = StrCat(out,@CRLF,mess)
   EndIf

   err=BBSend(bbhost,bbport,out)

   Return err
#EndFunction

;===================================================================

#DefineFunction BBSendAlarm(BBHost,BBPort,test,color,header,mess,UseFQDNs)
; Send an alarm
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; test is the name of the test in text to which BB will apply the
;     alarm message
; color is a lowercase text bigbrother color and should be red, yellow, green,
;     blue, purple or clear
; header is the text you want to be displayed as the title of the status msg.
; mess is one or more lines to make up the bulk of the status report.  lines in
;     mess should be separated by @crlfs embedded within the string
; expirestr is the amount of time the status being sent is good for before
;     BB issues a purple.  This value overrides the expiration time for the server
;     and can be in days, hours or mins (15m is 15 minutes, 30d is 30 days)
; UseFQDNS can be 1 or 0, @true or @false and toggles use of fully qualified
;     domain names.  Set this to match your server's setting.
;

   If UseFQDNs==@TRUE
      Computername = ComputerNameGet( 107 )
   Else
      Computername = ComputerNameGet( 106 )
   EndIf
   servicename = StrReplace(computername,".",",")
   servicename = StrCat(servicename,".",test)
   now = TimeYmdHms()

   b=TimeJulianDay(now)
   c=(b+5) mod 7
   day=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat", " ")
   EventDate = StrCat(StrSub(now,6,2),"/",StrSub(now,9,2),"/",StrSub(now,1,4))
   Eventtm2 = StrSub(now,12,-1)

   out=StrCat("page ",servicename," ",color," ",Eventdate," ",eventtm2," [",computername,"] ",Header)
   If mess <> ""
      out = StrCat(out,@CRLF,mess)
   EndIf

   err=BBSend(bbhost,bbport,out)

Return err
#EndFunction

;===================================================================

#DefineFunction BBSendEnable(BBHost,BBPort,Testnode,test)
; enable a test or node
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; TestNode is the name of the node BB is monitoring (may be FQDN)
; test is the name of the test in text that BB will apply the
;      message.  Use "*" or "" to enable the entire node

   If test =="" Then test="*"

   out = StrCat("enable ",testnode,".",test)

   err=BBSend(bbhost,bbport,out)

Return err
#EndFunction

;===================================================================

#DefineFunction BBSendDisable(BBHost,BBPort,TestNode,Test,duration,reason)
; disable a test or node
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; TestNode is the node name BB is monitoring
; test is the name of the test in text that BB will apply the
;      message.  Use "*" or "" to enable the entire node
; duration is the number of minutes the node or test is to be disabled
; reason is text that will be displayed much the mess field of the BBSendStatus
;     function when one clicks on a disabled test
; UseFQDNS can be 1 or 0, @true or @false and toggles use of fully qualified
;     domain names.  Set this to match your server's setting.
;

   If test =="" Then test="*"

   out = StrCat("disable ",TestNode,".",test," ",duration," ",reason)

   err=BBSend(bbhost,bbport,out)

Return err
#EndFunction

;===================================================================

#DefineFunction BBSendNotes(BBHost,BBPort,notes,useFQDNs)
; send a note for a node
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; notes is a sinlge or multi-line text variable with a note about
;     a given node
; UseFQDNS can be 1 or 0, @true or @false and toggles use of fully qualified
;     domain names.  Set this to match your server's setting.
;
   If UseFQDNs==@TRUE
      Computername = ComputerNameGet( 107 )
   Else
      Computername = ComputerNameGet( 106 )
   EndIf
   servicename = StrReplace(computername,".",",")


   out = StrCat("notes ",computername,".html ",notes)
   err=BBSend(bbhost,bbport,out)

Return err
#EndFunction

;===================================================================

#DefineFunction BBSendData(BBHost,BBPort,data,useFQDNs)
; send a data message for a given node
; BBhost is the destination Big Brother server (Display and/or page)
; BBPort is the port Big Brother is using (def is 1984)
; data is a sinlge or multi-line text variable that contains the data to
;     record for the node.  I don't know how it is to be displayed
; UseFQDNS can be 1 or 0, @true or @false and toggles use of fully qualified
;     domain names.  Set this to match your server's setting.
;
   If UseFQDNs==@TRUE
      Computername = ComputerNameGet( 107 )
   Else
      Computername = ComputerNameGet( 106 )
   EndIf


   out = StrCat("data ",computername,".data ",data)
   err=BBSend(bbhost,bbport,out)

Return
#EndFunction

;===================================================================

#DefineFunction BBSend(BBHost,BBPort,out)

AddExtender("wwwsk44I.dll")

   If bbport =="" Then bbport = 1984
   talksocket=sOpen()
   err=sConnect(talksocket,BBHost,bbport)
   err1=wxGetLastErr ()
   err=sSendLine(talksocket,out)
   err2=wxGetLastErr ()
   err=sClose(talksocket)

Return ((err1==0) && (err2==0))
#EndFunction

;===================================================================

Article ID:   W17628
Filename:   Communicate with Big Brother Network Monitor Server.txt
File Created: 2008:06:20:08:15:26
Last Updated: 2008:06:20:08:15:26