no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:lsmon [2010/04/28 06:45] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== lsmon.vbs ====== | ||
+ | |||
+ | ^ Author | [[ goldfndr@gmail.com | Richard Finegold ]] | | ||
+ | ^ Compatibility | Xymon or Big Brother | | ||
+ | ^ Requirements | VBScript and BBWin and lsmon.exe on client | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2010-02-25 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | This reports (and optionally graphs) licenses used by Sentinel RMS (formerly known as SentinelLM). For example, [[http:// | ||
+ | * Simple check for server: '' | ||
+ | * Simple check for client: '' | ||
+ | * Simple software check: '' | ||
+ | |||
+ | ===== Installation ===== | ||
+ | === Client side === | ||
+ | * Check for presence of '' | ||
+ | * Copy lsmon.vbs (below) to your BBWin' | ||
+ | * Edit your BBWin' | ||
+ | * Add a line in the '' | ||
+ | <load value=" | ||
+ | </ | ||
+ | * If the externals agent was disabled in the '' | ||
+ | <load name=" | ||
+ | </ | ||
+ | |||
+ | === Server side === | ||
+ | <hidden onHidden=" | ||
+ | * Add the following to $BBHOME/ | ||
+ | [lsmon] | ||
+ | FNPATTERN lsmon.(.*).rrd | ||
+ | TITLE SafeNet Utilization | ||
+ | YAXIS Percent Used | ||
+ | DEF: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | [lsmon1] | ||
+ | FNPATTERN lsmon.(.*).rrd | ||
+ | TITLE SafeNet Utilization | ||
+ | YAXIS Used | ||
+ | DEF: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | </ | ||
+ | * In $BBHOME/ | ||
+ | TEST2RRD=" | ||
+ | GRAPHS=" | ||
+ | </ | ||
+ | * In $BBHOME/ | ||
+ | * If it has '' | ||
+ | * If it doesn' | ||
+ | --extra-tests=lsmon --extra-script=$BBHOME/ | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | # extra-rrd.sh | ||
+ | |||
+ | # Input parameters: Hostname, testname (column), and messagefile | ||
+ | HOSTNAME=" | ||
+ | TESTNAME=" | ||
+ | FNAME=" | ||
+ | |||
+ | if [ " | ||
+ | #echo " | ||
+ | #go with disk ordering: percent then used | ||
+ | echo " | ||
+ | echo " | ||
+ | sed -n '/ | ||
+ | | sed 's/.*: //; | ||
+ | | sed ' | ||
+ | | while read line; do | ||
+ | #Not sure why, but on my machine there are hidden characters after feature name | ||
+ | #feature here is name-version | ||
+ | feature=`echo " | ||
+ | used=`echo " | ||
+ | avail=`echo " | ||
+ | total=$(( used + avail )) | ||
+ | pct=$(( used * 100 / total )) | ||
+ | echo " | ||
+ | echo " | ||
+ | done | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Source ===== | ||
+ | ==== lsmon.vbs ==== | ||
+ | |||
+ | <hidden onHidden=" | ||
+ | <code vb> | ||
+ | Option Explicit | ||
+ | |||
+ | const LSMONEXE=" | ||
+ | |||
+ | Dim TimerStart : TimerStart = Timer | ||
+ | Dim FSO : Set FSO = CreateObject(" | ||
+ | Dim WSH : Set WSH = CreateObject(" | ||
+ | const dbg=False | ||
+ | |||
+ | Phase 1 | ||
+ | WSH.Run " | ||
+ | |||
+ | Phase 2 | ||
+ | With FSO.OpenTextFile(" | ||
+ | Dim a : a = .ReadLine : a = Split(.ReadAll, | ||
+ | .Close | ||
+ | End With | ||
+ | |||
+ | Phase 3 | ||
+ | 'These are filtering from the first part (overall license characteristics). | ||
+ | 'Note that 8.x and 7.2 have a space in front of each line, 7.0 does not. | ||
+ | Dim i : for each i in Array(" | ||
+ | , " Able to issue", | ||
+ | , " Application-server locking", | ||
+ | , "Held licenses", | ||
+ | , " | ||
+ | a = Filter(a, i, False) | ||
+ | next | ||
+ | for each i in Array(" | ||
+ | a = Filter(a, i, False) | ||
+ | next | ||
+ | |||
+ | Phase 4 | ||
+ | 'These are filtering from the details (each user token) | ||
+ | for each i in Array(" | ||
+ | , "X display name", ": DefaultGrp" | ||
+ | a = Filter(a, i, False) | ||
+ | next | ||
+ | |||
+ | Phase 5 | ||
+ | 'This strips the last line | ||
+ | for each i in Array(" | ||
+ | a = Filter(a, i, False) | ||
+ | next | ||
+ | |||
+ | Phase 6 | ||
+ | 'These change the output on a 7.0 lsmon.exe from combined lines to pure NCV | ||
+ | 'And compensate for 7.2's tab | ||
+ | for i = 0 to UBound(a) - 1 | ||
+ | Dim n : n = Instr(a(i), " | ||
+ | If n > 5 Then | ||
+ | a(i) = Left(a(i), n - 3) & vbCRLF & Mid(a(i), n) | ||
+ | a(i) = Replace(a(i), | ||
+ | End If | ||
+ | n = Instr(a(i), " | ||
+ | If n > 5 Then | ||
+ | a(i) = Left(a(i), n - 3) & vbCRLF & Mid(a(i), n) | ||
+ | a(i) = Replace(a(i), | ||
+ | End If | ||
+ | n = Instr(a(i), " | ||
+ | if n = 2 then | ||
+ | a(i) = Replace(a(i), | ||
+ | end if | ||
+ | |||
+ | next | ||
+ | |||
+ | Phase 7 | ||
+ | 'This concatenates the output, putting an <HR> between each feature | ||
+ | 'Note that 8.x outputs " | ||
+ | a = Replace(Join(a, | ||
+ | |||
+ | a = Replace(a, vbCRLF & vbCRLF & " | ||
+ | , vbCRLF & "< | ||
+ | a = Replace(a, vbCRLF & vbCRLF & " | ||
+ | , vbCRLF & "< | ||
+ | |||
+ | WriteStatus " | ||
+ | |||
+ | |||
+ | '###################################################################### | ||
+ | 'Write out the status; depends on FSO and WSH; will use TimerStart if available for duration | ||
+ | Sub WriteStatus(column, | ||
+ | 'Why so long? Assume that client might collect file while writing, so make temp file and rename it. | ||
+ | '###################################################################### | ||
+ | Dim FSO : Set FSO = CreateObject(" | ||
+ | Dim WSH : Set WSH = CreateObject(" | ||
+ | Dim HKLMSoft : HKLMSoft=" | ||
+ | if WSH.Environment(" | ||
+ | Const LEAKYMAX = 8500, BBWinreg = " | ||
+ | Const Questreg = " | ||
+ | 'On error resume next | ||
+ | ' | ||
+ | Dim colfn, src : colfn = "" | ||
+ | If "" | ||
+ | If "" | ||
+ | colfn = colfn & " | ||
+ | Dim tmpfn : tmpfn = colfn & " | ||
+ | If FSO.FileExists(tmpfn) Then WScript.Quit 183 ' | ||
+ | Phase " | ||
+ | On Error Resume Next | ||
+ | With FSO.CreateTextFile(tmpfn, | ||
+ | if err then WScript.Quit err ' | ||
+ | if Len(line) > LEAKYMAX and src = " | ||
+ | .Write " | ||
+ | .WriteLine color & " " & WeekdayName(Weekday(Now), | ||
+ | & Mid(Now, | ||
+ | & " [" & WSH.Environment(" | ||
+ | .WriteLine line | ||
+ | .Write "< | ||
+ | FSO.GetFile(WScript.ScriptFullName).DateLastModified)) | ||
+ | if not IsNull(TimerStart) then .Write "; run time " & Timer - TimerStart & " | ||
+ | .Write " | ||
+ | .Close | ||
+ | End With | ||
+ | ' | ||
+ | ' | ||
+ | 'Or send directly with bbwincmd.exe if over 8kB | ||
+ | ' | ||
+ | Phase " | ||
+ | on error goto 0 | ||
+ | ' | ||
+ | if Len(line) > LEAKYMAX and src = " | ||
+ | Dim XML : Set XML = CreateObject(" | ||
+ | If XML.Load(WSH.RegRead(HKLMSoft & " | ||
+ | Phase " | ||
+ | Dim x : for each x in XML.SelectNodes("// | ||
+ | WSH.Run " | ||
+ | & " uploadmessage """ | ||
+ | next | ||
+ | Else | ||
+ | WScript.Echo "Error parsing " & WSH.RegRead(HKLMSoft & " | ||
+ | End If | ||
+ | FSO.DeleteFile tmpfn | ||
+ | else | ||
+ | if FSO.FileExists(colfn) then FSO.DeleteFile(colfn) | ||
+ | FSO.MoveFile tmpfn, colfn | ||
+ | end if | ||
+ | End Sub | ||
+ | |||
+ | '###################################################################### | ||
+ | 'If the script gets stuck, we can use Process Explorer to examine its environment | ||
+ | '###################################################################### | ||
+ | Sub Phase(n) | ||
+ | if dbg then wscript.echo n | ||
+ | CreateObject(" | ||
+ | End Sub | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | * This filters out a lot of lines from the lsmon output that I felt weren' | ||
+ | * It leaves behind a '' | ||
+ | * I have it working with lsmon.exe 8.0.5 and 7.2.0 and 7.0.0. Each formats somewhat differently (7.0 combines some lines; 7.2 and 8.0 use leading spaces; 7.2 uses a tab in Feature name, 8.0 does not) so there might be other versions that doesn' | ||
+ | |||
+ | ===== To Do ===== | ||
+ | * Change color to clear if "No licensed features" | ||
+ | * Change color for expiration: yellow if already expired (presume don't care), red if near expiration | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | * **2010-04-28** | ||
+ | * WriteStatus: | ||
+ | * WriteStatus: | ||
+ | * **2010-03-01** | ||
+ | * Modified for lsmon.exe version 7.0 and 7.2 | ||
+ | * Minor code improvements: | ||
+ | * **2010-02-25** | ||
+ | * Initial release | ||