1

私は現在、サーバー上で実行され、毎週/毎月データ ドメインのテキスト リストに ssh する Powershell スクリプトに取り組んでいます。このリストから、各 DD をループし、接続してコマンドを実行し、各 DD から情報を取得します。私はこれまで Powershell の経験がなく、知識は大学教育レベルの Linux と標準コマンドに限られています。

スクリプトは以下に基づいていました。

http://findnevilleat.blogspot.ca/2013/12/using-powershell-to-check-data-domains.html

現在、自分のニーズに合わせてスクリプトを変更しようとしていますが、出力に固執しています。現在、各データ ドメインに SSH 接続し、"df" と post-comp を使用してデータを引き出すことができますが、他のデータを取得することはまだ謎です (EMC サイトにも多くのソースはありません)。

要約すると、次のコマンドからより多くの情報を取得する方法を誰かが知っているかどうか疑問に思っています。

  • システム - すべてを表示/モデル番号を表示/ハードウェアを表示/統計を表示
  • filesys - スペースを表示

これまでの私のスクリプトの基本的な概要は次のとおりです。

          WriteLog "Checking Data Domain Available Space"
          $includeList="Cleanable GiB|--------|/data: post-comp" #Data domain format command to print
          $DB = Get-Content $answerfile #inputstream from file


          foreach ($Data in $DB){ ##bracket required on same line for foreach / foreach for iteration through data domains
              $hostname = $Data.Trim() #gets host name without new line character for the SSH command.

                #~~~~~~~~~ Password Set up ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                if($hostname -eq "139.12.34.56" -Or $hostname -eq 
 "10.123.11.108") ##if hostname is one of the selected, change password
 to correct 
                {
                $passwd = "12345PASS"
                }
                else #all other servers require this secondary password
                {
                $passwd = "54321PASS" 
                }
                #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                # Options: Hardcoded(current) / Read write from file.
                # With more passwords: Hardcoded = Switch
                #                      ReadWrite = Add to list


                #~~~~~~~~~~  SSH command and exe command Set up Process~~~~~~~~~~~~~~~~~
                $exe = "CMD" #Launch CMD for use


              $command = "/C $plinkcommand $user@$Data -pw ""$passwd"" df" #ssh command
              $Data > 
                #$command2 = "/C $plinkcommand $user@$Data -pw ""$passwd"" System show preformance" #ETC
                #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                # Currently supporting structure(below) to run other commands
                # Commands to be added: System  - (show all, show modelno, show compression, show hardware, show stats)    
                #                       Filesys - Show space
                #                       Possibly more to be added at a later time


                #~~~~~~~~~~~~~ Navigation of directories in host computer ~~~~~~~~~~~~~~
                invoke-expression "cd /" #Change directory to Root          
                invoke-expression "cd /users/kevindong/documents/powershellscripts" #change directory to
                plink location
                #Set up command to navigate to plink (requires set up dependedant on computer)
                #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                # Possible update to "invoke-expression", and possible specific targeted location of operating file directory

                #~~~~~~~~~~~~~ Execution of SSH data grab commands ~~~~~~~~~~~~~~~~~~~~~

              $outputcontents = &$exe $command ##ssh connect execution + "df" command

              if ($outputcontents -ne "") #if SSH is not null
              {

                  $outputcontents | ForEach-Object { #foreach requires bracket on same line
                       if ($_ -match $includeList) { WriteLog $_ }  #run data collection

                    #add commands here and write log them    
                    }
              }
                #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          }

私の問題を調べてくれた/見てくれた人に感謝します。それは有り難いです。

4

0 に答える 0