Configuring FreeRADIUS DHCP for ABillS

Suppose you installed FreeRADIUS 2 as written in this article – Installation and configuration of the ABillS billing system
Now copy the dhcp.conf file into the FreeRADIUS configuration:

sudo cp /usr/abills/misc/freeradius/v2/dhcp.conf /usr/local/freeradius/etc/raddb/sites-enabled/

Continue reading “Configuring FreeRADIUS DHCP for ABillS”

The solution of the error “Unable to create channel of type ‘SIP’ (cause 20 – Subscriber absent)”

I noticed one time when I received a call from the Asterisk console:

dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 – Subscriber absent)

In the context of the dialplan, I make a call simultaneously to two phones:

exten => s,5,DIAL(SIP/204&SIP/203,19)

Sometimes one of the IP phones is turned off, which is why this error occurs, informing that there is no subscriber.
To solve it, you just need to turn on the IP phone.

You can see information about SIP in the Asterisk console:

asterisk -rvv
sip show peers
sip show peer NUMBER
quit

If the client’s IP address is null and expire is -1, the SIP client is not online:

Expire: -1
Addr->IP: (null)

Linux disk test for errors and broken sectors

Switch directly to the root user:

sudo -i

Let’s see the list of disks:

fdisk -l
df -h

You can see the information and model of the disk as follows:

hdparm -i /dev/sda

If SMART is supported, install the utilities and see the SMART statistics:

apt-get install smartmontools
smartctl -a /dev/sda
smartctl -a /dev/sda|grep -i reallocated

Run SMART tests and view information (smartctl -X to stop the long test):

smartctl -H /dev/sda
smartctl --test=long /dev/sda
smartctl -l selftest /dev/sda

Now we will perform a disk check on the broken sectors (-s will display information about scanning, -v more detailed mode):

badblocks -sv /dev/sda1

You can save the result to a file:

badblocks -sv /dev/sda1 > ~/badblocks.list

You may need to unmount the disk to check:

umount /dev/sda1

You can run the test using e2fsck like this:

e2fsck /dev/sda1

See also:
Description of SMART attributes
Diagnostics HDD using smartmontools

Installing and using iotop

iotop – a console program that displays statistics on the use of disk space.

You can install Debian, Ubuntu, Mint with the command:

sudo apt-get install iotop

In Red Hat, Fedora, CentOS:

yum install iotop

Normal startup:

iotop

Running with the option:

iotop OPTION

I’ll describe the possible startup options:
–version (view version)
-h (view help)
-o (display only active processes or threads that read or write, instead of displaying all)
-b (inclusion of non-interactive mode, convenient for example to output information to a file)
-t (display time in each line, for non-interactive mode -b)
-n NUMBER (the number of iterations after which the output will be executed, if not specified, then the output is not standardized)
-d NUMBER (the delay between iterations in seconds, you can specify not an integer, a standard value of 1)
-p PID (display statistics only for the specified processes / threads, standard for all)
-u USER (display statistics only for specified users, standard for all)
-P (display only processes)
-a (accumulation of statistics from the start of the launch of iotop)
-k (statistics in kilobytes)
-q (shortened view, some header lines are removed, when used with the -b option. There are more abbreviated, for example -qq without title names and -qqq without a general summary)

Using the acct utility

The acct utility allows you to see statistics of user activity in the system.

Installation in Ubuntu:

sudo apt-get install acct

Removed in Ubuntu with the following command:

sudo apt-get remove acct

Installation in Fedora:

su -c 'yum install psacct'

Running in Ubuntu:

/etc/init.d/acct start

Running in Fedora:

su -c 'service acct start'

I will list and describe several commands of the acct utility:
ac – statistics on the time spent by users in the system
ac -d (per day)
ac -y (in a year)
ac -p (individual statistics)
ac –version (display version of the utility)
man ac (help on the team)

sa – information about executed commands and running applications
sa -c (statistics in percent)
man sa (help on the command)

lastcomm – last executed commands
sudo accton on/off – on and off collection of information

Disabling ecryptfs encryption at home directory

It took one day to disable the ecryptfs encryption of the home directory, which was once set up when installing the system.

First of all, we make a copy of the home directory of the right user:

sudo cp -rp /home/user /home/user_backup

Get the mount point in the directory:

PRIVATE=`cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private`

Unmount the directory:

ecryptfs-umount-private

Install the rights to the directory:

chmod 750 $PRIVATE

Delete the directory and directories ~/.Private, ~/.ecryptfs:

rm -rf $PRIVATE ~/.Private ~/.ecryptfs

And also in the made copy:

rm -rf /home/user_backup/.Private /home/user_backup/.ecryptfs

If ecryptfs is no longer used in the system, then we will delete the utilities:

sudo apt-get remove ecryptfs-utils libecryptfs0

Install the right user directory:

sudo chmod 750 /home/user
sudo chown user:user -R /home/user

Copy the necessary files from the backup copy of the home directory.

Done.

You can see the built-in statement with the command:

ecryptfs-setup-private --undo

See also:
The solution to the error “Could not chdir to home directory /home/user: Permission denied”

nice and ionice. Process Priorities

nice – allows you to specify the priority of the processor performing various tasks, the range of priorities is -20 to 19, where 19 is the smallest, if not specified, then there will be a standard priority of 0. Convenient for example when packing data into archives so that this task does not load the server or when many processes need to be started, distributing the load, which occupy all CPU time.

Example of the execution of the command with the lowest priority:

nice -n 19 COMMAND

See the table of processes and their priorities as follows (column NI):

ps axl
ps -l

If the table is large, you can redirect the output of the command to Less and look at the page:

ps axl | less

To change the priority:

renice -n 19 PROCESS(PID)

Checking the default priority value (standard 0):

nice

ionice – allows you to specify the priority for I/O operations, for example, to reduce the load on the disk. The first class is from 1 to 3, then the priority is from 0 to 7, where 7 is the smallest.
There are three classes:
1) Real time – Preemptive without paying attention to other processes, indicating priorities from 0 to 7.
2) Best Effort — Standard with priorities from 0 to 7.
3) Idle — With idle time without priority.

Example of executing the command with the lowest I/O priority:

ionice -c2 -n7 COMMAND

To change the priority:

ionice -c2 -n7 -p PROCESS(PID)

To view the set priority:

ionice -p PROCESS(PID)

You can specify priorities at the same time via nice and ionice:

nice -n 19 ionice -c2 -n7 COMMAND

To specify high priorities, for example, you might need root permissions, this command should be executed as root user or added before the sudo command.