Skip to content

Rage Against the Shell

Linux tips and other things…

  • Home
  • Contact
  • Privacy Policy

Month: April 2016

Nginx status module

Posted on April 30, 2016 - September 25, 2016 by Mr. Reboot

Tested on Debian 7 / NGINX 1.10

You can watch the nginx connections stats compiling nginx with the option http_stub_status_module:

~ $ ./configure --sbin-path=/usr/local/sbin --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --with-http_ssl_module --with-http_addition_module --with-pcre-jit --with-http_stub_status_module

Make and install:

~ $ make && make install

Now add this to the section server in the vhost config:

location /nginx_status {
                stub_status on;
                access_log off;
                allow x.x.x.x;
                deny all;
        }

Where x.x.x.x is your IP address. Also you can protect URL by http auth:

location /nginx_status {
                stub_status on;
                access_log off;
                auth_basic "Auth required";
                auth_basic_user_file /etc/nginx/htpasswd;
        }

Generate password file:

~ $ htpasswd -c /etc/nginx/htpasswd administrator
New password: 
Re-type new password: 
Adding password for user administrator
~ $ cat /etc/nginx/htpasswd
administrator:$apr1$kpTScFHe$A8W0.xtVq.gfiCY/9SdO71

Then reload nginx:

~ $ /etc/init.d/nginx reload

On load http://mydomain.com/nginx_status you will see:

Active connections: 2 
server accepts handled requests
 xxx yyy zzz 
Reading: 0 Writing: 2 Waiting: 0

Where:

mydomain.com: is your domain
xxx: total accepted connections
yyy: total handled connections
zzz: total handled requests

Posted in NginxLeave a comment

Creating lost+found directory

Posted on April 3, 2016 - September 18, 2016 by Mr. Reboot

Directory lost+found is a system directory placed on the root partition of the file system. e2fsck uses this special directory to deposit unlinked files after a file system repair.

Extracted from the man help: “mklost+found pre-allocates disk blocks to the lost+found directory so that when e2fsck is being run to recover a filesystem, it does not need to allocate blocks in the filesystem to store a large number of unlinked files. This ensures that e2fsck will not have to allocate data blocks in the filesystem during recovery.”

So it’s important this directory exists, if it was erased accidentally it’s necessary to create it:

~ $ cd /
~ $ mklost+found
~ $ cd /lost+found
~ $ ls -lha
total 20K
drwx------  2 root root  16K May  3  2016 .
drwxr-x--x 24 root root 4.0K Nov 1 23:23 ..

On the file system root partition.

Posted in File systemsLeave a comment

Using MAKEDEV

Posted on April 2, 2016 - September 18, 2016 by Mr. Reboot

You can use MAKEDEV command to create a structure of devices files under /dev using for example in chroot environment or for virtualization.

In Debian/Ubuntu install:

~ $ apt-get install makedev

Go to the /dev directory (or wherever you want to create dev files) and exec MAKEDEV:

~ $ cd /dev
~ $ MAKEDEV std

With the option “std” MAKEDEV create a standard devices group, mem, kmem, loop, null, port, core, full, ram, zero, random and tty:

~ $ ls -lha /dev

lrwxrwxrwx  1 root  root     11 abr  2 21:34 core -> /proc/kcore
crw-rw-rw-  1 root  root  1,  7 abr  2 21:34 full
crw-r-----  1 root  kmem  1,  2 abr  2 21:34 kmem
brw-rw----  1 root  disk  7,  0 abr  2 21:34 loop0
brw-rw----  1 root  disk  7,  1 abr  2 21:34 loop1
brw-rw----  1 root  disk  7,  2 abr  2 21:34 loop2
brw-rw----  1 root  disk  7,  3 abr  2 21:34 loop3
brw-rw----  1 root  disk  7,  4 abr  2 21:34 loop4
brw-rw----  1 root  disk  7,  5 abr  2 21:34 loop5
brw-rw----  1 root  disk  7,  6 abr  2 21:34 loop6
brw-rw----  1 root  disk  7,  7 abr  2 21:34 loop7
crw-r-----  1 root  kmem  1,  1 abr  2 21:34 mem
crw-rw-rw-  1 root  root  1,  3 abr  2 21:34 null
crw-r-----  1 root  kmem  1,  4 abr  2 21:34 port
lrwxrwxrwx  1 root  root      4 abr  2 21:34 ram -> ram1
brw-rw----  1 root  disk  1,  0 abr  2 21:34 ram0
brw-rw----  1 root  disk  1,  1 abr  2 21:34 ram1
brw-rw----  1 root  disk  1, 10 abr  2 21:34 ram10
brw-rw----  1 root  disk  1, 11 abr  2 21:34 ram11
brw-rw----  1 root  disk  1, 12 abr  2 21:34 ram12
brw-rw----  1 root  disk  1, 13 abr  2 21:34 ram13
brw-rw----  1 root  disk  1, 14 abr  2 21:34 ram14
brw-rw----  1 root  disk  1, 15 abr  2 21:34 ram15
brw-rw----  1 root  disk  1, 16 abr  2 21:34 ram16
brw-rw----  1 root  disk  1,  2 abr  2 21:34 ram2
brw-rw----  1 root  disk  1,  3 abr  2 21:34 ram3
brw-rw----  1 root  disk  1,  4 abr  2 21:34 ram4
brw-rw----  1 root  disk  1,  5 abr  2 21:34 ram5
brw-rw----  1 root  disk  1,  6 abr  2 21:34 ram6
brw-rw----  1 root  disk  1,  7 abr  2 21:34 ram7
brw-rw----  1 root  disk  1,  8 abr  2 21:34 ram8
brw-rw----  1 root  disk  1,  9 abr  2 21:34 ram9
crw-rw-rw-  1 root  root  1,  8 abr  2 21:34 random
crw-rw-rw-  1 root  tty   5,  0 abr  2 21:34 tty
crw-rw-rw-  1 root  root  1,  9 abr  2 21:34 urandom
crw-rw-rw-  1 root  root  1,  5 abr  2 21:34 zero
Posted in File systemsLeave a comment

Search

Calendar

April 2016
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  
« Jan   May »

Categories

  • Apache
  • Cisco
  • Command line
  • Distros
  • Dovecot
  • File systems
  • Gadgets
  • GlusterFS
  • MySQL
  • Nginx
  • NTP
  • Opendkim
  • Pacemaker + Corosync
  • Postfix
  • Raspberrypi
  • SSH
  • SSL
  • Varnish

RSS RSS

  • Using qrencode January 16, 2022
  • Compile varnish module vmod_vsthrottle April 22, 2020
  • SSH vpn with sshuttle April 9, 2020
  • Disable swap in systemd December 16, 2019
  • Getting the parent process pid October 12, 2018
Proudly powered by WordPress | Theme: micro, developed by DevriX.