title: How to add ping module in aws lambda using python
body: <p>I want to monitor a server using AWS Lambda function with Python 3.9 version.</p>
  <p>I'm using ping test connection and here's my code</p>
  <pre><code>import subprocess
  import platform
  
  def lambda_handler(event, context):
      SERVERS = [
          ('203.124.136.164', 'Local Host 1')
      ]
  
      for (server, name) in SERVERS:
          check_connection(server, name)
              
  def check_connection(server, name):
      if ping(server):
          print(&quot;%s is UP&quot; % (name))
      else:
          print(&quot;%s is DOWN&quot; % (name))
  
  def ping(server):
      try:
          output = subprocess.check_output(&quot;ping -{} 1 {}&quot;.format('n' if platform.system().lower() == &quot;windows&quot; else 'c', server ), shell=True, universal_newlines=True)
          if 'unreachable' in output:
              print('unreachable')
              return False
          elif 'timed out' in output:
              print('timed out')
              return False
          else:
              print('success')
              return True
      except Exception as err:
          print(&quot;An error occurred: %s&quot; % (err.__str__()))
          return False
  </code></pre>
  <p>But I got an error:</p>
  <pre><code>/bin/sh: ping: command not found
  An error occurred: Command 'ping -c 1 203.124.136.164' returned non-zero exit status 127.
  </code></pre>
  <p>Why I got that error and what is the right implementation to monitor a server using IP?
  I'm just a beginner. Please help!</p>
  <p>Disclaimer: the IP provided on the code is just dummy.</p>