Is there a script to test a PCs ability to reach the internet (ex.ping 8.8.8.8) and then create a report in KACE with the results?

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

There isn't anything built in, but you could create a script that pipes ping results into a text file and then use a custom inventory rule to have the K1000 put it into inventory.

Something like:

ping 8.8.8.8 > c:\program files (x86)\dell\kace\pingresults.txt

Then use a custom inventory rule like this:

ShellCommandTextReturn(type "c:\program files (x86)\dell\kace\pingresults.txt")

You could then create a report off of the software title you created for the custom inventory rule.

Answered 03/14/2014 by: jknox
Red Belt

  • How would I add this into inventory?
  • I was going to use the following script to test the the PC for connectivity. Instead of echoing the result I would like it to write a txt file if the link is "up" and delete the file if "down". I cannot figure out how to do this. Any suggestions? Does the inventory rule just check to see if the file exists or does it actually read the contents?

    @setlocal enableextensions enabledelayedexpansion
    @echo off
    set ipaddr=%1
    set state=down
    for /f "tokens=5,7" %%a in ('ping -n 1 !ipaddr!') do (
    if "x%%a"=="xReceived" if "x%%b"=="x1," set state=up
    )


    echo.Link is !state!
    ping -n 6 8.8.8.8 >nul: 2>nul:

    endlocal
    • ShellCommandText return will return text for some functions but not all. FileExists will see if the file exists.

      If it outputs to a file, you could use something like findstr to look for up or down in a file.
Please log in to comment
0

I would do this as a registry key instead of a file, and then create a custom invetory field for that reg key. To create the custom inventory field create a custom software item with the following custom inventory rule :

 RegistryValueReturn(HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Kace, InternetLinkState, reg_sz)

This script will write either "up" or "down" to a key called "InternetLinkState" (can change the name easily in the script, will need to change the rule in the custom invetory field software entry to match). I set it up to use the DNS name for google instead of 8.8.8.8 so that it will tell you the link is down if DNS isn't working.

 ping www.google.com
If %errorlevel% == 0 (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Kace" /d Up /v "InternetLinkState" /t REG_SZ /f) else (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Kace" /d Down /v "InternetLinkState" /t REG_SZ /f)

You can then search on, create labels for, or run reports against this field.

Answered 05/21/2014 by: prattk
Senior White Belt

Please log in to comment
Answer this question or Comment on this question for clarity