Giter Site home page Giter Site logo

Comments (3)

maglub avatar maglub commented on August 16, 2024
if (scriptAction == "powerstate" && namespace == AWS_NAMESPACE_EC2)
  instanceRunning = EC2InstanceRunning(instance_id)
  checkValue = 0
  powerstateMsg = ""

  if ( instanceRunning != "terminated" )
    checkValue = (instanceRunning) ? 1:0
    powerstateMsg = (checkValue == 0 ) ? "off" : "on"
  else
    checkValue = 0
    powerstateMsg = "instance does not exist"
  end

  retCode = checkThresholds(checkValue, thresholdWarning, thresholdCritical)

  printf "#{retCode[:msg]} - Id: #{instance_id} Powerstate: %s\n", powerstateMsg
  exit retCode[:value]

end

from nagios-cloudwatch.

maglub avatar maglub commented on August 16, 2024
def EC2InstanceRunning(instanceId)
  $stderr.puts "* Entering: #{thisMethod()}" if $debug
  $stderr.puts "  - Checking running state of #{instanceId}" if $debug

  aws_api = AWS::EC2.new()

  #--- get the instance running state
  begin
    response = aws_api.client.describe_instances({:instance_ids => [ instanceId ]})[:reservation_set][0][:instances_set][0][:instance_state][:name]
  rescue Exception => e
#    $stderr.puts "ERROR:   - #{e.to_s}"
    $stderr.puts "  - Instance id does not exist" if $debug

    return "terminated"
  end


#  $stderr.puts response if $debug
  $stderr.puts "  - Done checking running state of #{instanceId} (#{response})" if $debug
  if (response == "running")
    return true
  else
    return false
  end
end

from nagios-cloudwatch.

maglub avatar maglub commented on August 16, 2024

Merged with master

from nagios-cloudwatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.