Giter Site home page Giter Site logo

perlogix / pal Goto Github PK

View Code? Open in Web Editor NEW
4.0 0.0 0.0 19 KB

A simple webhook API to run system commands or scripts. Great for triggering deployments or other Linux operational tasks.

License: Apache License 2.0

Makefile 9.71% Go 69.58% Shell 20.71%
automation continuous-delivery continuous-integration deployment deployment-automation devops devsecops trigger trigger-events webhook

pal's Introduction

pal

A simple webhook API to run system commands or scripts. Great for triggering deployments or other Linux operational tasks.

Features

  • Auth header restriction
  • Pass a variable to command or script
  • Blocking and non-blocking command runs
  • Command output response or hidden response
  • Dynamic routing based on YAML configurations

Quick Start

Needs Go 1.16 or higher installed

make
make certs
./pal -c ./test/test.yml

Pal runs as https://127.0.0.1:8443 by default. To configure a different listening address and port see Configurations.

YAML Spec

# string: resource name, /v1/pal/deploy
deploy:
  -
    # string: target name, /v1/pal/deploy?target=app
    target: app
    # string: header key and value, curl -H'X-Pal-Auth: some_pass_or_token'
    auth_header: X-Pal-Auth some_pass_or_token
    # bool: return command output, default false
    rc_output: true
    # bool: block to only one request at a time, default false 
    block: true
    # string: put command or call script, you can use $ARG
    cmd: echo "helloworld" && echo "$ARG"

Example Request:

curl -sk -H'X-Pal-Auth: some_pass_or_token' 'https://127.0.0.1:8443/v1/pal/deploy?target=app&arg=helloworld2'

Request Structure

/v1/pal/{{ resource name }}?target={{ target name }}&arg={{ argument }}
  • resource name (Mandatory): name of a YAML key
  • target name (Mandatory): target value of a resource
  • argument (Optional): argument to be passed with variable ARG to command or script

Configurations

Usage of pal:
  -c string
    	Configuration file location (default "./pal.yml")
  -l string
    	Set listening address and port (default "127.0.0.1:8443")
  -t int
    	Set HTTP timeout by minutes (default 10)

Example Run:

./pal -c /dir/file.yml -l 0.0.0.0:8080

Example pal.yml

Create a monitor resource to get system stats. To see another example look at https://github.com/perlogix/pal/blob/main/test/test.yml

monitor:
  -
    target: system
    auth_header: X-Monitor-System q1w2e3r4t5
    block: true
    rc_output: true
    cmd: |
      echo '|===/ DOCKER STATS \===|'
      command -v docker 1>/dev/null && sudo docker stats --no-stream; echo

      echo '|===/ FREE MEMORY \===|'
      free -g; echo

      echo '|===/ DISK SPACE \===|'
      df -hT; echo

      echo '|===/ TOP CPU \===|'
      ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head; echo

      echo '|===/ TOP MEMORY \===|'
      ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head; echo

      echo '|===/ TOP OPEN FILES \===|'
      lsof 2>/dev/null | cut -d" " -f1 | sort | uniq -c | sort -r -n | head; echo

      echo '|===/ UPTIME AND LOAD \===|'
      uptime

Example Request:

curl -sk -H'X-Monitor-System: q1w2e3r4t5' 'https://127.0.0.1:8443/v1/pal/monitor?target=system'

pal's People

Contributors

marshyski avatar

Stargazers

 avatar  avatar  avatar  avatar

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.