{"id":23479490,"url":"https://github.com/plinker-rpc/system","last_synced_at":"2025-04-13T17:59:12.569Z","repository":{"id":57042730,"uuid":"103998517","full_name":"plinker-rpc/system","owner":"plinker-rpc","description":"A system component which gives you access to server information.","archived":false,"fork":false,"pushed_at":"2018-07-16T20:55:36.000Z","size":152,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T08:15:52.419Z","etag":null,"topics":["composer-package","php","plinker-rpc","rpc","system-information"],"latest_commit_sha":null,"homepage":"https://plinker-rpc.github.io/system","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plinker-rpc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-18T22:29:02.000Z","updated_at":"2023-07-27T05:48:08.000Z","dependencies_parsed_at":"2022-08-23T23:40:27.121Z","dependency_job_id":null,"html_url":"https://github.com/plinker-rpc/system","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinker-rpc%2Fsystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinker-rpc%2Fsystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinker-rpc%2Fsystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinker-rpc%2Fsystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plinker-rpc","download_url":"https://codeload.github.com/plinker-rpc/system/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758435,"owners_count":21156957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","php","plinker-rpc","rpc","system-information"],"created_at":"2024-12-24T19:29:52.210Z","updated_at":"2025-04-13T17:59:12.548Z","avatar_url":"https://github.com/plinker-rpc.png","language":"PHP","readme":"# PlinkerRPC - System\n\nA system component which gives you access to server information.\n\n## Install\n\nRequire this package with composer using the following command:\n\n``` bash\n$ composer require plinker/system\n```\n\n## Client\n\nCreating a client instance is done as follows:\n\n\n    \u003c?php\n    require 'vendor/autoload.php';\n\n    /**\n     * Initialize plinker client.\n     *\n     * @param string $server - URL to server listener.\n     * @param string $config - server secret, and/or a additional component data\n     */\n    $client = new \\Plinker\\Core\\Client(\n        'http://example.com/server.php',\n        [\n            'secret' =\u003e 'a secret password'\n        ]\n    );\n    \n    // or using global function\n    $client = plinker_client('http://example.com/server.php', 'a secret password');\n    \n\n## Methods\n\nOnce setup, you call the class though its namespace to its method.\n\n### Enumerate\n\nThe enumerate method is used to call multiple methods in a single call to reduce RPC requests.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| methods     | string|array   | A string or an array of methods | `[]`     |\n| params      | array          | An array of params  | `[]`     |\n\nThe method could be used to call a single method, or multiple with parameters.\n\n**Call**\n``` php\n$client-\u003esystem-\u003eenumerate([\n    'arch',\n    'hostname',\n    'disks' =\u003e ['/'],\n    'ping' =\u003e ['https://google.com'],\n]);\n\n// or single method\n$client-\u003esystem-\u003eenumerate('disks', ['/']);\n```\n\n**Response**\n``` text\nArray\n(\n    [arch] =\u003e x86_64\n    [hostname] =\u003e plinker\n    [disks] =\u003e Array\n        (\n            [0] =\u003e Array\n                (\n                    [Filesystem] =\u003e /dev/sdb1\n                    [Type] =\u003e ext4\n                    [Size] =\u003e 95G\n                    [Used] =\u003e 85G\n                    [Avail] =\u003e 5.2G\n                    [Used (%)] =\u003e 95%\n                    [Mounted] =\u003e /\n                )\n\n        )\n\n    [ping] =\u003e -1\n)\n```\n\n### Arch\n\nReturns the system architecture.\n\n**Call**\n``` php\n$client-\u003esystem-\u003earch();\n```\n\n**Response**\n``` text\nx86_64\n```\n\n### Clear Swap\n\nClear swap space, **requires root, so should be used with task**.\n\n**Call**\n``` php\n$client-\u003esystem-\u003eclear_swap();\n```\n\n**Response**\n``` text\n\n```\n\n### CPU Info\n\nReturns information about the CPU.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| parse       | bool           | Parse output into an array | `true` |\n\n**Call**\n``` php\n$client-\u003esystem-\u003ecpu_info();\n```\n\n**Response**\n``` text\nArray\n(\n    [Architecture] =\u003e x86_64\n    [CPU op-mode(s)] =\u003e 32-bit, 64-bit\n    [Byte Order] =\u003e Little Endian\n    [CPU(s)] =\u003e 2\n    [On-line CPU(s) list] =\u003e 0,1\n    [Thread(s) per core] =\u003e 1\n    [Core(s) per socket] =\u003e 2\n    [Socket(s)] =\u003e 1\n    [NUMA node(s)] =\u003e 1\n    [Vendor ID] =\u003e AuthenticAMD\n    [CPU family] =\u003e 16\n    [Model] =\u003e 4\n    [Model name] =\u003e AMD Phenom(tm) II X2 555 Processor\n    [Stepping] =\u003e 3\n    [CPU MHz] =\u003e 3200.000\n    [CPU max MHz] =\u003e 3200.0000\n    [CPU min MHz] =\u003e 800.0000\n    [BogoMIPS] =\u003e 6429.27\n    [Virtualization] =\u003e AMD-V\n    [L1d cache] =\u003e 64K\n    [L1i cache] =\u003e 64K\n    [L2 cache] =\u003e 512K\n    [L3 cache] =\u003e 6144K\n    [NUMA node0 CPU(s)] =\u003e 0,1\n    [Flags] =\u003e fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate retpoline retpoline_amd rsb_ctxsw vmmcall npt lbrv svm_lock nrip_save\n)\n```\n\n### Disk Space\n\nReturns disk space left in percentage.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| path        | string         | A directory of the filesystem or disk partition. | `/` |\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003edisk_space();\n```\n\n**Response**\n``` text\n71\n```\n\n### Disks\n\nReturn mounted disks.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| parse       | bool           | Parse output into an array | `true` |\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003edisks();\n\n// dont parse\n$client-\u003esystem-\u003edisks(false);\n```\n\n**Response**\n``` text\n// Parsed\nArray\n(\n    [0] =\u003e Array\n        (\n            [Filesystem] =\u003e /dev/sdb1\n            [Type] =\u003e ext4\n            [Size] =\u003e 95G\n            [Used] =\u003e 85G\n            [Avail] =\u003e 5.2G\n            [Used (%)] =\u003e 95%\n            [Mounted] =\u003e /\n        )\n\n)\n\n// Unparsed\nFilesystem     Type  Size  Used Avail Use% Mounted on\n/dev/sdb1      ext4   95G   85G  5.2G  95% /\n```\n\n### Distro\n\nGet system distro name.\n\n**Call**\n``` php\n$client-\u003esystem-\u003edistro();\n```\n\n**Response**\n``` text\nUBUNTU\n```\n\n### Drop Cache\n\nDrop memory caches, **requires root, so should be used with task**.\n\n**Call**\n``` php\n$client-\u003esystem-\u003edrop_cache();\n```\n\n**Response**\n``` text\ntrue\n```\n\n### Hostname\n\nGet the systems hostname.\n\n**Call**\n``` php\n$client-\u003esystem-\u003ehostname();\n```\n\n**Response**\n``` text\nplinker\n```\n\n### Load\n\nGet the systems load averages.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| parse       | bool           | Parse output into an array | `true` |\n\n**Call**\n``` php\n$client-\u003esystem-\u003eload();\n```\n\n**Response**\n``` text\nArray\n(\n    [1m] =\u003e 1.71\n    [5m] =\u003e 1.21\n    [15m] =\u003e 1.14\n    [curr_proc] =\u003e 3\n    [totl_proc] =\u003e 1437\n    [last_pid] =\u003e 3272\n)\n```\n\n### Logins\n\nReturns an array of system logins.\n\n**Call**\n``` php\n$client-\u003esystem-\u003elogins();\n```\n\n**Response**\n``` text\nArray\n(\n    [0] =\u003e Array\n        (\n            [User] =\u003e root\n            [Terminal] =\u003e pts/1tmux(2972).%0\n            [Date] =\u003e Fri May 11 08:25\n            [Disconnected] =\u003e 11:01\n            [Duration] =\u003e 02:35\n        )\n\n    [1] =\u003e Array\n        (\n            [User] =\u003e root\n            [Terminal] =\u003e pts/1tmux(542).%0\n            [Date] =\u003e Thu May 10 15:01\n            [Disconnected] =\u003e 08:11\n            [Duration] =\u003e 17:09\n        )\n\n    [2] =\u003e Array\n        (\n            [User] =\u003e Reboot\n            [Terminal] =\u003e \n            [Date] =\u003e \n            [Disconnected] =\u003e \n            [Duration] =\u003e \n        )\n\n    [3] =\u003e Array\n        (\n            [User] =\u003e root\n            [Terminal] =\u003e pts/1tmux(5310).%0\n            [Date] =\u003e Thu May 10 07:42\n            [Disconnected] =\u003e crash\n            [Duration] =\u003e 07:19\n        )\n    )\n    ... snip\n)\n```\n\n### Machine ID\n\nReturns the [machine-id](http://man7.org/linux/man-pages/man5/machine-id.5.html) for the system, generates one if does not have one.\n\n**Call**\n``` php\n$client-\u003esystem-\u003emachine_id();\n```\n\n**Response**\n``` text\n82c887bcf6da43e5952fad9fd6ed15b6\n```\n\n### Memory Stats\n\nReturns an array of memory stats for, used, cached and free in percentage values.\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003ememory_stats();\n```\n\n**Response**\n``` text\nArray\n(\n    [used] =\u003e 15\n    [cache] =\u003e 0\n    [free] =\u003e 85\n)\n```\n\n### Memory Total\n\nGet the total amount of memory in kB\n\n**Call**\n``` php\n$client-\u003esystem-\u003ememory_total();\n```\n\n**Response**\n``` text\n16167888\n```\n\n### Netstat\n\nGet network connections.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| parse       | bool           | Parse output into an array | `true` |\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003enetstat();\n```\n\n**Response**\n``` text\nArray\n(\n    [0] =\u003e Array\n        (\n            [Proto] =\u003e tcp\n            [Recv-Q] =\u003e 0\n            [Send-Q] =\u003e 0\n            [Local Address] =\u003e 0.0.0.0:80\n            [Foreign Address] =\u003e 0.0.0.0:*\n            [State] =\u003e LISTEN\n            [PID/Program] =\u003e 1169/nginx:\n            [Process Name] =\u003e worker\n        )\n    ... snip\n)\n```\n\n### Ping\n\nPing a hostname and return connection timing in milliseconds.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| host        | string         | Server hostname |  |\n| port        | int            | Service port, defaults to web | `80` |\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003eping('google.com');\n```\n\n**Response**\n``` text\n31.18\n```\n\n### PStree\n\nReturn system process tree\n\n**Call**\n``` php\n$client-\u003esystem-\u003epstree();\n```\n\n**Response**\n``` text\nsystemd-+-Brackets-+-Brackets---Brackets---Brackets-+-{Chrome_ChildIOT}\n        |          |                                |-2*[{CompositorTileW}]\n        |          |                                |-{Compositor}\n        |          |                                |-{HTMLParserThrea}\n        |          |                                |-{Renderer::FILE}\n        |          |                                |-{WorkerPool/203}\n        |          |                                |-{WorkerPool/210}\n        |          |                                |-{WorkerPool/212}\n        |          |                                `-{WorkerPool/213}\n        |          |-Brackets-node-+-5*[{Brackets-node}]\n        |          |               `-4*[{V8 WorkerThread}]\n        |          |-{AudioThread}\n        |          |-2*[{Brackets}]\n        |          |-3*[{BrowserBlocking}]\n        |          |-{CachePoolWorker}\n        |          |-{Chrome_CacheThr}\n        |          |-{Chrome_DBThread}\n        |          |-{Chrome_DevTools}\n        |          |-{Chrome_FileThre}\n        |          |-{Chrome_FileUser}\n        |          |-{Chrome_IOThread}\n        |          |-{Chrome_ProcessL}\n        |          |-{CompositorTileW}\n        |          |-{IndexedDB}\n        |          |-{NetworkChangeNo}\n        |          |-{WorkerPool/1747}\n        |          |-{gdbus}\n        |          |-{gmain}\n        |          |-{inotify_reader}\n        |          |-{sandbox_ipc_thr}\n        |          `-{threaded-ml}\n        |-LXDui-0.0.9-x86---{LXDui-0.0.9-x86}\n... snip\n```\n\n### Reboot\n\nReboot the server, **requires root, so should be used with task**.\n\n**Call**\n``` php\n$client-\u003esystem-\u003ereboot();\n```\n\n**Response**\n``` text\ntrue\n```\n\n### CPU Usage\n\nReturns the current CPU usage in percentage value.\n\n**Call**\n``` php\n$client-\u003esystem-\u003ecpu_usage();\n```\n\n**Response**\n``` text\n23\n```\n\n### System Updates\n\nCheck whether the system has updates.\n\n**Call**\n``` php\n$client-\u003esystem-\u003esystem_updates();\n```\n\n**Response**\n``` text\n1=has updates, 0=no updates, -1=unknown\n```\n\n### Top\n\nGet top output as an array.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| parse       | bool           | Parse output into an array | `true` |\n\n**Call**\n``` php\n$client-\u003esystem-\u003etop();\n```\n\n**Response**\n``` text\nArray\n(\n    [0] =\u003e Array\n        (\n            [PID] =\u003e 27475\n            [USER] =\u003e user\n            [PR] =\u003e 20\n            [NI] =\u003e 0\n            [VIRT] =\u003e 1785692\n            [RES] =\u003e 671316\n            [SHR] =\u003e 140004\n            [S] =\u003e S\n            [%CPU] =\u003e 43.8\n            [%MEM] =\u003e 4.2\n            [TIME+] =\u003e 29:44.62\n            [COMMAND] =\u003e chrome\n        )\n    ... snip\n)\n```\n\n### Total Disk Space\n\nGet total disk space in bytes.\n\n| Parameter   | Type           | Description   | Default        |\n| ----------  | -------------  | ------------- |  ------------- | \n| path        | string         | A directory of the filesystem or disk partition. | `/` |\n\n\n**Call**\n``` php\n$client-\u003esystem-\u003etotal_disk_space();\n```\n\n**Response**\n``` text\n101369536512\n```\n\n### Uname\n\nGet system name/kernel version.\n\n**Call**\n``` php\n$client-\u003esystem-\u003euname();\n```\n\n**Response**\n``` text\nLinux 4.13.0-41-generic\n```\n\n### Uptime\n\nGet system uptime string.\n\n**Call**\n``` php\n$client-\u003esystem-\u003euptime();\n```\n\n**Response**\n``` text\nup 1 day, 17 hours, 31 minutes\n```\n\n## Testing\n\nThere are no tests setup for this component.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/plinker-rpc/system/blob/master/CONTRIBUTING) for details.\n\n## Security\n\nIf you discover any security related issues, please contact me via [https://cherone.co.uk](https://cherone.co.uk) instead of using the issue tracker.\n\n## Credits\n\n- [Lawrence Cherone](https://github.com/lcherone)\n- [All Contributors](https://github.com/plinker-rpc/system/graphs/contributors)\n\n\n## Development Encouragement\n\nIf you use this project and make money from it or want to show your appreciation,\nplease feel free to make a donation [https://www.paypal.me/lcherone](https://www.paypal.me/lcherone), thanks.\n\n## Sponsors\n\nGet your company or name listed throughout the documentation and on each github repository, contact me at [https://cherone.co.uk](https://cherone.co.uk) for further details.\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/plinker-rpc/system/blob/master/LICENSE) for more information.\n\nSee the [organisations page](https://github.com/plinker-rpc) for additional components.\n","funding_links":["https://www.paypal.me/lcherone"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplinker-rpc%2Fsystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplinker-rpc%2Fsystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplinker-rpc%2Fsystem/lists"}