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.

Solving the error in Asterisk “File vm-newn does not exist in any format”

When I called a voicemail number, I noticed the following errors in the Asterisk console:

[Apr 10 17:08:01] WARNING[19135][C-00001cf4]: file.c:701 ast_openstream_full: File digits/1n does not exist in any format
[Apr 10 17:08:01] WARNING[19135][C-00001cf4]: file.c:1017 ast_streamfile: Unable to open digits/1n (format (ulaw)): No such file or directory
[Apr 10 17:08:01] WARNING[19135][C-00001cf4]: file.c:701 ast_openstream_full: File vm-newn does not exist in any format
[Apr 10 17:08:01] WARNING[19135][C-00001cf4]: file.c:1017 ast_streamfile: Unable to open vm-newn (format (ulaw)): No such file or directory

Errors are caused by the lack of sound files, for example, in my case in the voice mail one message and when I try to say “you have one (1n.ulaw) new (vm-newn) message, an error occurs and the handset lies down.

Archive with a set of necessary files is enough to simply download from the official site http://downloads.asterisk.org/pub/telephony/sounds/releases/ and unpack to the directory /usr/share/asterisk/sounds
After this, the error should not be.

How to remove “New User” in Asterisk CallerID

I noticed once that when incoming calls from the Goip4 gateway on SIP phones, not only the caller’s number is displayed, but the name “New User” flashes alternately with the phone number, which is obviously superfluous and hinders.

After viewing the Asterisk configuration files, I noticed some standard values in the /etc/asterisk/users.conf file in the general section, namely:

[general]
fullname = New User

Which need to comment out:

;fullname = New User

And restart Asterisk to apply the changes:

sudo service asterisk restart

Done, now with incoming calls only the phone number will be displayed.

Installing and using trafshow

trafshow – a utility for displaying traffic statistics passing through network interfaces.

Since the utility is included in the Netdiag (Net-Diagnostics) set, everything is installed together.

You can install Netdiag and trafshow in Ubuntu / Debian using the following command:

sudo apt-get install netdiag

In CentOS/RedHat/Fedora:

sudo yum install netdiag

Command viewing guide:

man trafshow

Simple launch:

sudo trafshow

I’ll describe the possible startup options:
-v (view the version of the program)
-n (do not convert the addresses into DNS names, and port numbers for example 80 in http, etc., in the running program, you can toggle the option with the N key)
-a len (summarizing traffic flows using the IP prefix IP netmask len, in the program is switched by pressing the A key)
-с conf (using an alternative color configuration instead of the standard / etc / trafshow)
-i name (indication of the network interface)
-s str (search for an item in the list and go to it)
-u port (listening to the specified UDP port for Cisco Netflow, the default number is 9995, to disable use 0)
-R refresh (update interval, default 2 secs, in the program is changed with the R key)
-P purge (cleaning of obsolete records after the specified time, by default 10 seconds, in the program is changed by the key P)
-F file (using a file for filters)
expr (what packages will be displayed, if not specified, then all)

Installing and using softflowd

Softflowd – NetFlow network traffic analyzer.

You can install in Ubuntu/Debian using the command:

sudo apt-get install softflowd

After installation, you need to open its configuration file, for example, in the nano editor (Ctrl+X for exit, y/n for saving or canceling changes):

sudo nano /etc/default/softflowd

And specify the parameters, for example:

INTERFACE="any"
OPTIONS="-n 192.168.1.40:5556"

After the changes, perform a restart:

sudo /etc/init.d/softflowd restart

Let’s look at the statistics of softflowd:

softflowctl statistics

If it is not running, there will be an error:

ctl connect(“/var/run/softflowd.ctl”) error: Connection refused

Display information about all monitored threads:

sudo softflowctl dump-flows

Information about softflowctl can be viewed by the command:

man softflowctl

I’ll describe other startup options:
-n (specify the network node and port on which will work softflowd)
-i (interface on which will work softflowd)
-r pcap_file (reading information from a file, not a network interface)
-p pidfile (alternative location for storing the process identifier, standard /var/run/softflowd.pid)
-c ctlsock (alternative location for the socket, standard /var/run/softflowd.ctl)
-m max_flows (maximum number of threads for simultaneous tracking)
-6 (consider also IPv6 data)
-D (debug mode)
-T track_level (level of tracking, can be full, proto, ip)
-v netflow_version (netflow version)

Linux snmp OIDs

Example for check:

snmpget -v 1 -c "public" localhost .1.3.6.1.2.1.1.3.0

System load:
In 1 minute: .1.3.6.1.4.1.2021.10.1.3.1
In 5 minutes: .1.3.6.1.4.1.2021.10.1.3.2
In 15 minutes: .1.3.6.1.4.1.2021.10.1.3.3

CPU:
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0

Memory statistics:
Size of the Swap: .1.3.6.1.4.1.2021.4.3.0
Free Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM: .1.3.6.1.4.1.2021.4.5.0
Used RAM: .1.3.6.1.4.1.2021.4.6.0
Free RAM: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0
Mount point: .1.3.6.1.4.1.2021.9.1.2.1
Mount the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1
Total disk/partition size in kilobytes: .1.3.6.1.4.1.2021.9.1.6.1
Free disk space: .1.3.6.1.4.1.2021.9.1.7.1
Used disk space: .1.3.6.1.4.1.2021.9.1.8.1
Disk space used as a percentage: .1.3.6.1.4.1.2021.9.1.9.1

Uptime system: .1.3.6.1.2.1.25.1.1.0
SNMP uptime: .1.3.6.1.2.1.1.3.0

See also:
SNMP OID and MIB for interfaces