Git Product home page Git Product logo

php-systemd's Introduction

php-systemd

PHP extension allowing native interaction with systemd and journald

Installation

Prerequisites

.deb based

sudo apt install php5-dev  libsystemd-dev

.rpm based

sudo dnf install php-devel systemd-devel

Build

phpize
./configure --with-systemd
make

Setup

sudo make install

Fedora

echo "extension=systemd.so" | sudo tee /etc/php.d/systemd.ini

Debian (PHP 5)

echo "extension=systemd.so" | sudo tee /etc/php5/mods-available/systemd.ini
sudo php5enmod systemd

Basic Test

echo "<?php echo sd_journal_send('MESSAGE=hello world');" | php

Usage

Quick example:

<?php
sd_journal_send('MESSAGE=Hello world.');
// message with priority "3" (warning) and identifier (also called *TAG*) set to "appname" 
sd_journal_send('MESSAGE=Error message','PRIORITY=3', 'SYSLOG_IDENTIFIER=appname');"

Notes:

  • Each argument must be in the form of a KEY=value pair, environmental variable style.
  • Unlike the native C version of journald's sd_journal_send(), printf-style substitution is not supported. Perform any substitution using PHP's sprintf() or similar capabilities first.
  • The base message is usually sent in the form MESSAGE=hello. The MESSAGE field is, however, not required.
  • Invalid arguments result in nothing recorded in the journal.

Viewing Output

Quick way to view output with all fields as it comes in:

sudo journalctl -f --output=json

php-systemd's People

Contributors

davidstrauss avatar

Watchers

 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.