2014年08月20日のつぶやき

0
    17:15
    chefのメモなど http://t.co/An4MiYFOAY #jugem_blog
    • 2014.08.21 Thursday
    • -
    • 03:02
    • -
    • -
    • -
    • -
    • by orz

    chefのメモなど

    0
      レシピの中で、仕方なく実行しているbashの実行を一回だけにしたい時のメモ
      actionをnothingにして、notifiesでrun bashすればいいのか
       
      bash "mysql56_install" do
        code <<-EOC
          cd /usr/local/
          tar xvzf /usr/local/src/mysql-5.6.20-linux-glibc2.5-i686.tar.gz
          mv mysql-5.6.20-linux-glibc2.5-i686 mysql
          chown -R mysql:mysql /usr/local/mysql
        EOC
        action :nothing
      end

      cookbook_file "/usr/local/src/mysql-5.6.20-linux-glibc2.5-i686.tar.gz" do
        action :create
        source "mysql56/mysql-5.6.20-linux-glibc2.5-i686.tar.gz"
        mode 0755
        notifies :run, "bash[mysql56_install]"
      end


       

      2014年08月05日のつぶやき

      0
        14:02
        awsのメンテンススケジュール監視メモ http://t.co/uc0JJWcfzY #jugem_blog
        • 2014.08.06 Wednesday
        • -
        • 03:02
        • -
        • -
        • -
        • -
        • by orz

        awsのメンテンススケジュール監視メモ

        0
          先日、EC2のメンナンスを見逃して、メンドクサイことになったので、
          監視することにしました。
          AWSで使用しているスクリプトは、perlを使用していたのだけども、
          describeInstanceStatusを取得できないので、
          phpのSDKをためしてみよと思うわけであります。

          Composerのinstall
          composerは手順通りであります。
          http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html

          とりあえず、チェックスクリプト
          <?php

          require_once("/hogehoge/aws-sdk-php/vendor/autoload.php");
          use Aws¥Ec2¥Ec2Client;

          $OK         = 0;
          $WARNING    = 1;
          $CRITICAL   = 2;
          $UNKNOWN    = 3;
          $evenet_flg = 1;

          $client = Ec2Client::factory(array(
              'key' => 'hogehoge',
              'secret' =>  'hogehoge',
              'region' => 'ap-northeast-1'
          ));

          try{
             $result = $client->describeInstanceStatus();
           }catch(Exception $e){
             echo "can not get status ¥n¥n";
             exit($UNKNOWN);
          }

          $v = array() ;

          foreach ( $result["InstanceStatuses"] as $key => $value) {
             $instance_id =  $value['InstanceId'];

             if ( array_key_exists('Events', $value)) {
                $event_code       = $value['Events']['Code'];
                $event_not_before = $value['Events']['NotBefore'];
                $event_not_after  = $value['Events']['NotAfter'];
                $evenet_flg       = 1;
             }
             else {
                 $event_code       = 0;
                 $event_not_before = 0;
                 $event_not_after  = 0;
                 $evenet_flg       = 0;
             }

             $v[$instance_id]['event_flg']       =  $event_code;
             $v[$instance_id]['event_code']      =  $event_not_before;
             $v[$instance_id]['event_not_before']=  $event_not_after;
             $v[$instance_id]['evenet_flg']      =  $evenet_flg;
             $v[$instance_id]['instance_id']      =  $instance_id;
          }

          foreach ( $v as $key => $value ) {

             if ( $value['evenet_flg'] == 1 ) {
               print $value['instance_id'].":ERROR¥n";
               print $v[$instance_id]['event_code'];
               exit($CRITICAL);
             }
             else {
               print $value['instance_id'].":OK¥n";
             }
          }

          exit($OK);

          ?>

          これで、アカウント内の全インスタンスを検索する予定ではありますが・・・
          動くのだろうか・・・

          1

          calendar

          S M T W T F S
               12
          3456789
          10111213141516
          17181920212223
          24252627282930
          31      
          << August 2014 >>

          selected entries

          categories

          archives

          recent comment

          recent trackback

          recommend

          links

          profile

          書いた記事数:219 最後に更新した日:2022/09/09

          search this site.

          others

          mobile

          qrcode

          powered

          無料ブログ作成サービス JUGEM