Kaseya Community

Alarm when Internet goes slow?

  • Procedure_Cure_Ping_Test.xml

    Attached is a scriptthat i have been playing with and it works well in telling us when the ping is high for a specifc customer.   We run this script every hour at our customers.  I changed the IP to 8.8.8.8 in our script however if you use it I would recommend doing sometihng on our LAN like we do so you don't get a nasty call from Google or something :)

    Anyway we are having problems when users take their laptops home or go on cell mifi's that their ping is high but it's understandable.  Has anyone done this differently or know how to group this ping data into a pool and just take a average from all the computers?

     

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Cure Ping Test" treePres="3" id="777028924">
        <Body description="This procedure will check network latency to a given hostname or IP address that is entered when the procedure is executed.">
          <Statement description="" name="GetVariable" continueOnFail="false" osType="Windows">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="ConstantValue" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="8.8.8.8" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="hostname" />
          </Statement>
          <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="MachineGroupID" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="mac" />
          </Statement>
          <Statement description="" name="GetVariable" continueOnFail="false" osType="Windows">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="ConstantValue" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="Average" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="type" />
          </Statement>
          <Statement description="" name="ExecuteShellCommand" continueOnFail="false" osType="Windows">
            <Parameter xsi:type="StringParameter" name="Command" value="cmd.exe /c &quot;for /f &quot;tokens=10 delims=;=;ms&quot; %s in ('ping -n 200 #hostname# ^| find &quot;#type#&quot;') do echo%s&gt;&gt;&quot;#vAgentConfiguration.AgentTempDir#\#type#.txt&quot;&quot;" />
            <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
            <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
          </Statement>
          <Statement description="" name="GetVariable" continueOnFail="false" osType="Windows">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="#vagentconfiguration.agenttempdir#\#type#.txt" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="results" />
          </Statement>
          <Statement description="" name="UpdateSystemInfo" continueOnFail="false" osType="Windows">
            <Parameter xsi:type="StringParameter" name="ColumnName" value="Cure Ping" />
            <Parameter xsi:type="StringParameter" name="Value" value="#results#" />
          </Statement>
          <Statement description="Display a message dialog to the user." name="SendMessage" continueOnFail="false" osType="None">
            <Parameter xsi:type="StringParameter" name="Message" value="Your ping is #results#" />
            <Parameter xsi:type="BooleanParameter" name="Immediate" value="True" />
          </Statement>
          <If description="">
            <Condition name="CheckVariable">
              <Parameter xsi:type="StringParameter" name="VariableName" value="#results#" />
              <Parameter xsi:type="EnumParameter" name="Condition" value="GreaterThan" />
              <Parameter xsi:type="StringParameter" name="Value" value="300" />
            </Condition>
            <Then>
              <Statement description="Send an email from the server (address specified in the Configure function in the System module)." name="SendEmail" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="To" value="sam@curesolutions.com" />
                <Parameter xsi:type="StringParameter" name="Subject" value="Ping is high on #mac# with #results#" />
                <Parameter xsi:type="StringParameter" name="Body" value="Your Ping is #results#" />
              </Statement>
              <Statement description="Display a message dialog to the user." name="SendMessage" continueOnFail="false" osType="None">
                <Parameter xsi:type="StringParameter" name="Message" value="You have High Ping Too" />
                <Parameter xsi:type="BooleanParameter" name="Immediate" value="True" />
              </Statement>
            </Then>
          </If>
        </Body>
      </Procedure>
    </ScriptExport>

  • Nice!  If you haven't already, upload this to community.kaseya.com/.../default.aspx the knowledge script exchange so it's easily found by others.

    Thumbs up!