Kaseya Community

Hard Drive Diagnostics

  • I would like to perform hardware diagnostics via Kaseya, mainly for the hard drive, but something like the Dell quick diagnostics would be handy.

    I know there are tools out there to check for at least hard drive issues even through Windows. Has anyone spent the time to get some good diags via a Kaseya script? Would using chkdsk /f be good enough? Any thoughts would be appreciated.

    Legacy Forum Name: Hard Drive Diagnostics,
    Legacy Posted By Username: CCG
  • I'm going to add up to this to this post. I use defrag script from kaseya (runs pretty good) but for some agents the script will write that ran successfully but agent hard drive stills needs to be defragged because of the fact that some file cannot be moved.
    It will be nice to have another tool for this type of issues...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: christian@syneteksolutions.com
  • christian@syneteksolutions.com
    I'm going to add up to this to this post. I use defrag script from kaseya (runs pretty good) but for some agents the script will write that ran successfully but agent hard drive stills needs to be defragged because of the fact that some file cannot be moved.


    There will always be files that cannot be moved during a defrag. The quest for "the perfect defrag" drove my former boss almost completely insane. Don't be that guy. Seriously.

    For what it's worth, I script JkDefrag's command-line version but just point it at the %WINDIR% and %PROGRAMFILES% locations so I'm not bogging the machine down for hours. It's a fair balance, for us, between gaining some performance benefit and making the client's life miserable on a weekly basis.

    Script Name: JkDefrag Processing
    Script Description: Defragmentation of %WINDIR% and %PROGRAMFILES% using JkDefrag. Results files are retrieved for perusal if so desired.

    IF True
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : ATemp
    OS Type : 1
    Write File
    Parameter 1 : #ATemp#\JkDefragCmd.exe
    Parameter 2 : VSASharedFiles\JkDefragCmd.exe
    OS Type : 1
    Execute Shell Command
    Parameter 1 : #ATemp#\JkDefragCMD.exe -a 3 "%windir%" -l "#ATemp#\DefragWindows.log"
    Parameter 2 : 1
    OS Type : 1
    Execute Shell Command
    Parameter 1 : #ATemp#\JkDefragCMD.exe -a 3 -e *.stm -e *.edb "%programfiles%" -l "#ATemp#\DefragProgFiles.log"
    Parameter 2 : 1
    OS Type : 1
    Get File
    Parameter 1 : #ATemp#\DefragWindows.log
    Parameter 2 : DefragWindows.log
    Parameter 3 : 1
    OS Type : 1
    Get File
    Parameter 1 : #ATemp#\DefragProgFiles.log
    Parameter 2 : DefragProgFiles.log
    Parameter 3 : 1
    OS Type : 1
    Delete File
    Parameter 1 : #ATemp#\JkDefragCmd.exe
    OS Type : 1
    ELSE


    Share and enjoy!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • We have a script that uses Sysinternal's PageDefrag utility to defragment the page file and registry hive upon system reboot here:

    http://www.securemycompany.com/forum/viewtopic.php?t=65

    NOTE: PageDefrag may not work correctly on Windows Vista

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: ed@securemycompany.com
  • I've found plenty of defrag scripts, using DIRMS seems to work good. But that wasn't my question at all. I want to do diagnostics on either the hard drive or all hardware, I think that would be a huge selling point for Kaseya.

    Thanks for all the other feedback, however!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: CCG
  • We are working on the implementation of SMART monitoring within Kaseya. SMART is a feature that most (ATA) drives support. We have our first script working but are not that far that we would like to share this. Basically we run a SMART scan on all physical drives, check the result file on the occurrence of the overall health status. If there is something to be concerned about it create an alarm and an email alert. For SCSI drives we use RAID diagnostics supplied by our server (mostly HP).

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: BertHaver
  • Here is a little utility that I use for monitoring SMART status on drives. The utility is a few years old, but SMART hasent changed in ages.

    http://www.beyondlogic.org/solutions/smart/smart.htm

    You can easily create alerts or monitoring sets off this tools. I have.

    God Bless,
    Marty

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Missing Link
  • Thanks Grey Duck (Kaseya Guru) !!! I'll give this a try... and also i'll do my best not to drive myself insane...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: christian@syneteksolutions.com
  • Missing Link
    Here is a little utility that I use for monitoring SMART status on drives. The utility is a few years old, but SMART hasent changed in ages.

    http://www.beyondlogic.org/solutions/smart/smart.htm

    You can easily create alerts or monitoring sets off this tools. I have.

    God Bless,
    Marty


    Would you happen to have a monitor set (or something to start off with) for use with this program? I find the idea really great since a SMART-status can sometimes be a great tool to find out a HD's condition but don't really know where to start reading it out from the DOS-box...
    Thanks in advance!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jotheman
  • Missing Link
    Here is a little utility that I use for monitoring SMART status on drives. The utility is a few years old, but SMART hasent changed in ages.

    http://www.beyondlogic.org/solutions/smart/smart.htm


    Marty,

    I can probably whip up a nifty alert mechanism from this... if I can figure out what a not-OK status looks like. I don't have any failing drives handy and there's no documentation anywhere, apparently, so... what does a bad status code look like? (I can use egrep much more effectively if I tell it to look for 'X' rather than for 'not-X'.)

    Thanks! I will, of course, share my work with the class. Big Smile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • I have found this script in passing, and tweaked it to our liking.
    I havent looked at it or edited it since the 5.0 Upgrade so it could be archaic now.

    In any event I thought I would extend a hand to our other Kaseya partners as it does work well.

    It works in two steps, and uses grep

    (http://www.opbarnes.com/blog/Software/OPB/grep_for_windows.html)

    Post criticism / praise here.

    Good Luck!

    Dustin
    Quicktech

    Script Name: SMART - SMART Disk Check
    Script Description: This script runs smartctl.exe against 4 potential hard drives (hda-hdd) and dumps the output to a log file. That file is then parsed for the 'overall-health' line which is dumped to a final results file which is then written to the log.

    IF Test File
    Parameter 1 : C:\Quicktech\SMARTMon\smartctl.exe
    Absent :
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : agentDrv
    OS Type : 0
    Write Directory
    Parameter 1 : #agentDrv#\SMARTMon
    Parameter 2 : VSASharedFiles\Maintenance\SMARTMon
    OS Type : 0
    Write File
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe
    Parameter 2 : VSASharedFiles\Maintenance\SMARTMon\smartctl.exe
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hda >> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdb >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdc >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdd >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\grep -U overall-health "#agentDrv#\smartout.txt" >> "#agentDrv#\smartresults.txt"
    Parameter 2 : 1
    OS Type : 0
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #agentDrv#\smartresults.txt
    Parameter 3 : smartresults
    OS Type : 0
    Execute Script
    Parameter 1 : SMART - Email on SMART failure (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0
    ELSE
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : agentDrv
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hda >> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdb >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdc >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\smartctl.exe -a hdd >>>> "#agentDrv#\smartout.txt"
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #agentDrv#\SMARTMon\grep -U overall-health "#agentDrv#\smartout.txt" >> "#agentDrv#\smartresults.txt"
    Parameter 2 : 1
    OS Type : 0
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #agentDrv#\smartresults.txt
    Parameter 3 : smartresults
    OS Type : 0
    Execute Script
    Parameter 1 : SMART - Email on SMART failure (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0


    Script Name: SMART - Email on SMART failure
    Script Description: Emails helpdesk@quicktech.ca if S.M.A.R.T status fails

    IF Check Variable
    Parameter 1 : #SmartResults#
    Contains Stick out tongueASSED
    THEN
    Write Script Log Entry
    Parameter 1 : S.M.A.R.T Status PASSED
    OS Type : 0
    ELSE
    Get Variable
    Parameter 1 : 6
    Parameter 2 :
    Parameter 3 : machine.groupid
    OS Type : 0
    Send Email
    Parameter 1 : helpdesk@quicktech.ca
    Parameter 2 : S.M.A.R.T Status Failed on #machine.groupid#
    Parameter 3 :
    OS Type : 0


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: quicktech
  • Dustin, that's fairly slick. (Though, because I have the soul of a nitpicking ***, I have to point out that there's not much use in getting or using the Agent Temp variable if what you're testing for in the If/Then is a hard-coded location on C:. Of course, how often is the system/agent directory not on C:, right?)

    What I came up with on Monday (and was too busy to post yesterday) is a three-script system centered on the BeyondLogic utility from up-thread. I would have used 'grep' (I'm a big fan of the GnuWin32 utils) but for the fact that the If/Then in the child scripts can do that job for me, so using 'grep' was a bit redundant even for me. So, here's another way to skin this particular cat, presented for the sake of those who want to see just how many ways Kaseya's delightful scripting system can be turned to a single, relatively simple task... Big Smile

    First, the processing. I'm not particularly worried about secondary drives in workstations (which are the only SMART-compliant systems I'm likely to run into) so I just let the utility run against the main system drive naturally and capture the whole output.

    Script Name: SMART drive check - kk
    Script Description: Runs BeyondLogic's "smart.exe" on system drive, generates email alert on "Failed" in output (via child script).

    IF True
    THEN
    Get Variable
    Parameter 1 : 6
    Parameter 2 :
    Parameter 3 : MachID
    OS Type : 0
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : TempDir
    OS Type : 0
    Write File
    Parameter 1 : #TempDir#\smart.exe
    Parameter 2 : VSASharedFiles\smart.exe
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #TempDir#\smart.exe >> #TempDir#\SMARToutput.txt
    Parameter 2 : 1
    OS Type : 0
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #TempDir#\SMARToutput.txt
    Parameter 3 : SMARToutput
    OS Type : 0
    Execute Script
    Parameter 1 : SMART error alert - kk (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0
    Execute Script
    Parameter 1 : SMART compliance alert - kk (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0
    ELSE


    We're looking for any line which reads "Failed," which in a happy coincidence includes the output from Vista due to a failure to read drive info at all.

    Script Name: SMART error alert - kk
    Script Description: Generates email alert & script log entry on detection of "Failed" in output of BeyondLogic's "smart.exe" utility (from parent script).

    IF Test File
    Parameter 1 : #TempDir#\SMARToutput.txt
    Contains :Failed
    THEN
    Send Email
    Parameter 1 : email@email.com
    Parameter 2 : SMART failure detected on #MachID#
    Parameter 3 : Detected one or more SMART monitor failures on #MachID#, as follows: #SMARToutput#
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : Detected one or more SMART monitor failures, as follows: #SMARToutput#
    OS Type : 0
    ELSE


    And just for grins & chuckles, an email notification if this script suite is run against a server for which SMART data is unavailable. (That's what we have HP Insight Manager event IDs for, anyway.)

    Script Name: SMART compliance alert - kk
    Script Description: Generates email alert & script log entry on detection of a SMART compliance error in output of BeyondLogic's "smart.exe" utility (from parent script). Parent script should be DESCHEDULED if this alert activates!

    IF Test File
    Parameter 1 : #TempDir#\SMARToutput.txt
    Contains :compliant
    THEN
    Send Email
    Parameter 1 : email@email.com
    Parameter 2 : SMART compliance error on #MachID#
    Parameter 3 : Detected SMART compliance error on #MachID#, as follows: #SMARToutput#
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : Detected SMART compliance error on #MachID#, as follows: #SMARToutput#
    OS Type : 0
    ELSE


    Ah, isn't scripting fun?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • GreyDuck
    (Though, because I have the soul of a nitpicking ***, I have to point out that there's not much use in getting or using the Agent Temp variable if what you're testing for in the If/Then is a hard-coded location on C:.


    Very nice scripting GreyDuck. But I'll also nitpick and ask why get the machine ID variable when it's automatically available using this syntax:

    #vmachine.Machine_GroupID#

    No need to run a Get Variable step!

    Michael

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: RCS-Michael
  • [QUOTE=RCS-Michael;27977]Very nice scripting GreyDuck. But I'll also nitpick and ask why get the machine ID variable when it's automatically available using this syntax:

    #vmachine.Machine_GroupID#

    No need to run a Get Variable step!

    Michael[/QUOTE]

    Hey, that's nifty. I've had mixed luck with using the database access feature (let's not go into the weeks I spent trying to create an app-version-checker script) so I tend not to consider some of those variables. This is a great tip, thanks!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • Big Smile
    Fantastic scripts guys! I've been needed a SMART util in my script arsenal!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jamie177