Download: [download id=”16″]

The file has included test examples and vlc player. The Management Pack is 32Kb

Intro:

This management packs can be used to keep track of the level of coffee in left in the pot.

With this management pack, you will never run dry of, what we all know, is the most important part of a productive environment!

This is mostly made as a proof of concept, as this technique can be transferred to other monitor types. It could be expanded with other types of sensors, like a weight to check the level of coffee instead of a camera, or a thermometer to check the temperature of the coffee.

This is the very first version. It has been tested in test environments.

By default, it will trigger a warning when under 50% is left, and a Critical Alert when under 20% is left.

Please do not hesitate to report any bugs and please send suggestions for the next version you might have.

This was developed by Jakob Gottlieb Svendsen with the help of Kåre Rude Andersen

Requirements

Microsoft System Center Operations Manager 2007 R2

Microsoft .Net Framework 3.5 SP1

A network connected camera

Coffee machine with clear-glass pot and free view to all of the pot, see an example in the video.

The management pack is based upon Microsoft .Net Framework 3.5 SP1. This is required to be installed before the executables can run.

The Monitor requires a Camera to take snapshots of the Coffee pot, and the Monitor application uses the snapshot to count how much coffee is left.

The camera and coffee machine has to be placed correctly and a number of requirements have to be fulfilled. These requirements could become obese if one would spend time at modifying a Coffee Machine to include a web camera.

  1. Coffee pot have to be in clear glass.
  2. The whole of the coffee pot has to be visible from one side from the camera.
  3. The background behind the machine/pot has to be white, or similar very light color. This have only been tested with white background.
  4. Camera have to be level with the coffee pot, and point towards the pot in a 0 degrees horizontal angle. Otherwise the level of coffee could be inconsistent.
  5. The light in the room have to be turned on a all times, while the monitor is scheduled to run, and must not point directly at the pot, since the glass, with black coffee behind, can act as a mirror, making it impossible for the camera to see the coffee level. A Camera with Polaroid lense, or polaroid filter i front of, should in teory overcome this problem, making the measurement much more stable.
  6. The camera have to place a snapshot JPG,PNG or BMP at a specified location once every minute or so, depending on how you setup the monitor. Alternatively, if the camera has a .asf stream, we have included our test setup, that utilizes VLC player to grab a snapshot of the ASF stream every time the monitor script is run (Extra\Debug-version-with-VLC-Snapshot Folder).

Install:

1. Extract all files to a folder on the server drive (C:\CCM etc.)
2. Import the Management Pack “CoretechCoffeeMonitor.xml” into OpsMgr.
3. Setup Coffee Machine and Camera
4. Use CCM-Config.exe to configure maximum and minimum amount of coffee as well as the black thersholm. See the video for more details.
5. Schedule your camera to put a new image in a specific location every minute (default is c:\CCM\snap.png).Pictures can be JPG, BMP or PNG
5. Setup the image file location in the script parameters in the unit monitor called “Coretech Coffee Monitor”
6. System is now ready!

Configuration:

You should use CCM-Config.exe to create a config.xml file. See Video for more details.

This file have to be placed in the same directory as the executables (etc. C:\CCM)

The path for the image file have to be setup in the Script parameters in the Unit Monitor called “Coretech Coffee Monitor”

Files:

CoretechCoffeeMonitor.exe Main executable, this is used by the management pack to count the number of black pixels in the snapshots
CCM-config.exe Configuration application, is used to create the nessesary config.xml file.
config.xml This have to be placed in the same folder as the executables for the system to work. Is generated by CCM-Config.exe
CoretechCoffeeMonitor.xml Main Management Pack XML file.

Management Pack Content:

<?xml version="1.0" encoding="utf-8"?><ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <Manifest>
    <Identity>
      <ID>CoretechCoffeeMonitor</ID>
      <Version>0.0.0.1</Version>
    </Identity>
    <Name>CoretechCoffeeMonitor</Name>
    <References>
      <Reference Alias="Windows">
        <ID>Microsoft.Windows.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="System">
        <ID>System.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SC">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Health">
        <ID>System.Health.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <Monitoring>
    <Monitors>
      <UnitMonitor ID="CoretechCoffeeMonitor.Monitor" Accessibility="Internal" Enabled="true" Target="SC!Microsoft.SystemCenter.RootManagementServer" ParentMonitorID="Health!System.Health.EntityState" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
        <Category>AvailabilityHealth</Category>
        <AlertSettings AlertMessage="CoretechCoffeeMonitor.Monitor_AlertMessageResourceID">
          <AlertOnState>Warning</AlertOnState>
          <AutoResolve>true</AutoResolve>
          <AlertPriority>Normal</AlertPriority>
          <AlertSeverity>MatchMonitorHealth</AlertSeverity>
          <AlertParameters>
            <AlertParameter1>$Data/Context/Property[@Name='percentCoffee']$</AlertParameter1>
          </AlertParameters>
        </AlertSettings>
        <OperationalStates>
          <OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success" />
          <OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning" />
          <OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error" />
        </OperationalStates>
        <Configuration>
          <IntervalSeconds>60</IntervalSeconds>
          <SyncTime />
          <ScriptName>CoretechCoffeeMonitor.vbs</ScriptName>
          <Arguments>"C:\CCM\Snap.png"</Arguments>
          <ScriptBody>Dim WshShell, oExec
Dim oAPI, oBag

If Wscript.Arguments.Count = 1 Then
	strImageFile = Wscript.Arguments.Item(0)
Else
	Call oAPI.LogScriptEvent("CoretechCoffeeMonitor.vbs",101,1,"CoffeeMonitor failed: Please specify no more or less than 1 Argument (Image file Path)")
	Wscript.Quit(2)
End if

'Setup objects
Set WshShell = CreateObject("WScript.Shell")
Set wshFso = WScript.CreateObject("Scripting.Filesystemobject")

'Setup property bag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()

'Calculate Coffee Status
Set oExec = WshShell.Exec("C:\CCM\CoretechCoffeeMonitor.exe " &amp; strImageFile)

Do while Not oExec.StdOut.AtEndOfStream
	output = oExec.StdOut.ReadLine
	'Display each line as it is received.
	WScript.Sleep 100
Loop

'Try converting the result
On Error Resume Next
percentCoffee = Cint(output)
If Err Then
	Call oAPI.LogScriptEvent("CoretechCoffeeMonitor.vbs",101,1,"CoffeeMonitor failed: " &amp; output)
	Wscript.Quit(1)
End if
On Error Goto 0

Call oBag.AddValue("percentCoffee",percentCoffee)

'Return result
Call oAPI.Return(oBag)

</ScriptBody>
          <TimeoutSeconds>60</TimeoutSeconds>
          <ErrorExpression>
            <And>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Property[@Name='percentCoffee']</XPathQuery>
                  </ValueExpression>
                  <Operator>LessEqual</Operator>
                  <ValueExpression>
                    <Value Type="Double">20</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Property[@Name='percentCoffee']</XPathQuery>
                  </ValueExpression>
                  <Operator>GreaterEqual</Operator>
                  <ValueExpression>
                    <Value Type="Double">0</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </And>
          </ErrorExpression>
          <WarningExpression>
            <And>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Property[@Name='percentCoffee']</XPathQuery>
                  </ValueExpression>
                  <Operator>Less</Operator>
                  <ValueExpression>
                    <Value Type="Double">50</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Property[@Name='percentCoffee']</XPathQuery>
                  </ValueExpression>
                  <Operator>Greater</Operator>
                  <ValueExpression>
                    <Value Type="Double">20</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </And>
          </WarningExpression>
          <SuccessExpression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="Double">Property[@Name='percentCoffee']</XPathQuery>
              </ValueExpression>
              <Operator>GreaterEqual</Operator>
              <ValueExpression>
                <Value Type="Double">50</Value>
              </ValueExpression>
            </SimpleExpression>
          </SuccessExpression>
        </Configuration>
      </UnitMonitor>
    </Monitors>
  </Monitoring>
  <Presentation>
    <StringResources>
      <StringResource ID="CoretechCoffeeMonitor.Monitor_AlertMessageResourceID" />
    </StringResources>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="DAN" IsDefault="false">
      <DisplayStrings>
        <DisplayString ElementID="CoretechCoffeeMonitor">
          <Name>Coretech Coffee Monitor</Name>
          <Description>Monitor the Coffee Status! 

More info: https://blog.ctglobalservices.com</Description>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor">
          <Name>Coretech Coffee Monitor</Name>
          <Description>Monitor for checking the level of Coffee left in the Machine.

Please visit https://blog.ctglobalservices.com for more info</Description>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor" SubElementID="Error">
          <Name>Error</Name>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor" SubElementID="Success">
          <Name>Success</Name>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor" SubElementID="Warning">
          <Name>Warning</Name>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor_AlertMessageResourceID">
          <Name>Coretech Coffee Monitor</Name>
          <Description>Coffee Status: {0} %</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="CoretechCoffeeMonitor">
          <Name>Coretech Coffee Monitor</Name>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor">
          <Name>Coretech Coffee Monitor</Name>
        </DisplayString>
        <DisplayString ElementID="CoretechCoffeeMonitor.Monitor_AlertMessageResourceID">
          <Name>Coretech Coffee Monitor</Name>
          <Description>{0}</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>

That should be it for now!

Please bring your feedback 🙂