Magic SysRq Key
November 25, 2017 — 22:19

Author: silver  Category: linux  Comments: Off

How to use SysRq (Print Screen key)

( “REISUB” )

enable:

echo 1 > proc/sys/kernel/sysrq

permanently:

/etc/sysctl.d/local.conf
kernel.sysrq=1

To BREAK: CTRL+PAUSE (Serial)

ALT+SysReq+KEY
When logged in using SSH the SysRq may be accessible by writing to /proc/sysrq-trigger
echo s > /proc/sysrq-trigger

useful options:

  • b: Immediately reboot the system, without unmounting or syncing filesystems
    echo b > proc/sysrq-trigger
  • e: Send the SIGTERM signal to all processes except init (PID 1)
  • f: Call oom_kill, which kills a process to alleviate an OOM condition:
  • s: Sync all mounted filesystems:
  • t: Output a list of current tasks and their information to the console:
  • u: Remount all mounted filesystems in read-only mode
  • w: Display list of blocked (D state) tasks
  • space: Print a summary of available magic SysRq keys

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/admin-guide/sysrq.rst
https://en.wikipedia.org/wiki/Magic_SysRq_key

GoAccess
November 25, 2017 — 18:04

Author: silver  Category: linux web  Comments: Off

GoAccess is a “real-time web log analyzer” which can output in CLI or HTML (like webalizer, awstats and piwik etc). It works out of the box with Apache, for lighttpd you probably need to specify the log format. Examples below are for lighttpd. Run “goaccess /var/log/httpd/access.log” without any other arguments and it will ask for the log format and drop you into the Dashboard (text based gui).

CLI

no conf, just arguments:

goaccess /var/log/lighttpd/access.log \
--date-format=%d/%b/%Y \
--time-format='%T %z' \
--log-format='%h %v %e [%d:%t] "%r" %s %b "%R" "%u"'

-or-

change /etc/goaccess.conf:

date-format %d/%b/%Y:%T %z
log-format %h %v %e [%d] "%r" %s %b "%R" "%u"

HTML

Output to “static” html file.

current log:

goaccess /var/log/lighttpd/access.log \
  --date-format=%d/%b/%Y \
  --time-format='%T %z' \
  --log-format='%h %v %e [%d:%t] "%r" %s %b "%R" "%u"' \
  --output=/var/www/html/goaccess.html

use all logs:

zcat -f /var/log/lighttpd/access.log*gz | goaccess \
  --date-format=%d/%b/%Y \
  --time-format='%T %z' \
  --log-format='%h %v %e [%d:%t] "%r" %s %b "%R" "%u"' \
  --ignore-crawlers \
  --with-output-resolver \
  -e 127.0.0.1 -e ::1 -e exclude.example.com
  --output=/var/www/html/goaccess.html

Server

The last option is to run it as Server using WebSocket. This allows it to:

  • output realtime HTML: --real-time-html
  • run as daemon: --daemonize
  • use FIFO: --fifo-in= --fifo-out=
  • use HTTPS: --ssl-cert= --ssl-key= --ws-url=wss://url

live log:

goaccess /var/log/lighttpd/access.log \
 --date-format=%d/%b/%Y \
 --time-format='%T %z' \
 --log-format='%h %v %e [%d:%t] "%r" %s %b "%R" "%u"' \
 --output=/var/www/html/goaccess.html \
 --real-time-html \
 --ssl-cert=//etc/ssl/certs/cert.pem \
 --ssl-key=/etc/ssl/private/privkey.pem --ws-url=wss://example.com:7890

Now https://example.com/goaccess.html should should a live Dashboard (tcp port 7890 needs to be open for client).








We use Matomo free and open source web analytics
We also use Jetpack WordPress.com Stats which honors DNT