Giter Club home page Giter Club logo

beacon's Introduction

Beacon

Beacon

Beacon provides a command-line interface to apnscp API + module introspection.

Usage

Prerequisites

Beacon requires a key to be setup first in the control panel. Visit Dev > API Keys to generate a key. Beacon also requires at least PHP7, which restricts operation to v6.5+ platforms. Set the key by running exec with --key. Overwrite a previously configured key with -s:

beacon exec --key=somekey -s common_get_uptime

Commands

show

show service Display underlying code for given service

Example

beacon show common_get_load

Example response

/**
 * array get_load (void)
 *
 * @privilege PRIVILEGE_ALL
 * @return array returns an assoc array of the 1, 5, and 15 minute
 * load averages; indicies of 1,5,15
 */
 public function get_load()
 {
     $fp = fopen('/proc/loadavg', 'r');
     $loadData = fgets($fp);
     fclose($fp);
     $loadData = array_slice(explode(" ", $loadData), 0, 3);
     return array_combine(array(1, 5, 15), $loadData);
 }

exec

exec flags service [args, ...] Executes named service with optional args

Example

beacon exec common_get_uptime

Example response

25 days 10 mins
Optional flags
  • format [json, bash, php] Alter output format
beacon exec --format=json common_get_load
{"1":"0.00","5":"0.00","15":"0.00"}
beacon exec --format=php common_get_load
Array
(
    [1] => 0.04
    [5] => 0.01
    [15] => 0.00
)
beacon exec --format=bash common_get_load
(["1"]="0.04" ["5"]="0.01" ["15"]="0.00")

Bash formatting can be used in shell scripting to populate variables, e.g.

declare -a load=`beacon exec --format=bash common_get_load`
echo ${load[1]}
  • set Set API key as default on exit

  • key key Specify an API key, key

  • keyfile file Specify a file, file that contains the API key to use. The file should be formatted as empty consisting of nothing but the key.

  • endpoint url Use the endpoint url instead of http://localhost:2082/soap.

arrays and hashes

Arrays and hashes are fed using a bracketed expression [] which may also be nested.

beacon e file_delete '[/tmp/a, /tmp/b]'
beacon e user_add_user "newuser" "newpassword" "some new user" '[imap:1,smtp:1]'

null and bool types

null and false may be passed verbatim to indicate a null or true/false parameter. To pass a string literal of the corresponding type, surround the argument with both single and double quotes,

Clear ACLs for user myuser

beacon e file_set_acls /home/foo myuser null

This is interchangeable, due to shell parsing mechanics, to,

beacon e file_set_acls /home/foo myuser "null"

Set read, write, execute for user "null"

beacon e file_set_acls /home/foo "'null'" 7

API reference

All modules are available through api.apnscp.com. Modules that follow the naming XXX_Module are exposed as xxx, for example methods in File_Module are exposed as file_<method> and set_acls in File_Module is referenced as file_set_acls.

beacon's People

Contributors

msaladna avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fairhopeweb

beacon's Issues

Permission denied , what are required permissions to read monitrc for beacon

[root@cp beacon]# beacon exec argos_list_monitored
PHP Notice:  Undefined property: SoapClient::$trace in phar:///usr/local/sbin/beacon/src/apisnetworks/Beacon/Client.php on line 41

In Client.php line 35:
                                                                           
  monit: Cannot open the control file '/etc/monitrc' -- Permission denied  
                                                                           
  Failed to query monit                                                    
                                                                           

exec [-k|--key KEY] [--set] [--keyfile KEYFILE] [--format FORMAT] [--endpoint ENDPOINT] [--] <service> [<vars>]...

[root@cp beacon]# less /etc/monitrc
[root@cp beacon]# stat /etc/monitrc
  File: /etc/monitrc
  Size: 13353     	Blocks: 32         IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 140917250   Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-17 23:01:00.064497990 +0200
Modify: 2022-05-10 19:49:53.272642006 +0200
Change: 2022-05-10 19:49:53.272642006 +0200
 Birth: 2022-05-10 19:49:53.272642006 +0200
[root@cp beacon]# 

What permissions would suffice for beacon to read the file.

Deploying beacon on latest ApisCP

[root@cp beacon]# composer install
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - roave/better-reflection 2.0.0 requires php >7.1.0,<7.3.0 -> your php version (7.4.29) does not satisfy that requirement.
    - roave/better-reflection[2.0.1, ..., 2.0.2] require php >=7.1.0,<7.3.0 -> your php version (7.4.29) does not satisfy that requirement.
    - Root composer.json requires roave/better-reflection ^2.0 -> satisfiable by roave/better-reflection[2.0.0, 2.0.1, 2.0.2].

Seems some packages are behind, and some completely replaced.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.

Maybe it can be updated in main composer.json . Or should I submit a PR?

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.