Pages

Tuesday, June 15, 2021

Fedora 34 : The uresourced resource tool.

The uresourced tool is a daemon that will give resource allocations to active graphical users.
You can enable easy with systemctl command:
[root@desk mythcat]# systemctl status uresourced
○ uresourced.service - User resource assignment daemon
     Loaded: loaded (/usr/lib/systemd/system/uresourced.service; disabled; vend>
     Active: inactive (dead)

[root@desk mythcat]# systemctl enable uresourced
Created symlink /etc/systemd/system/user@.service.wants/uresourced.service → 
/usr/lib/systemd/system/uresourced.service.
[root@desk mythcat]# systemctl start  uresourced
[root@desk mythcat]# systemctl status uresourced
● uresourced.service - User resource assignment daemon
...

Sunday, June 13, 2021

Fedora 34 : Linux tool to prevent OOM Killer.

The OOM Killer or Out of Memory Killer is a process that the Linux kernel employs when the system is critically low on memory
This situation occurs because processes on the server are consuming a large amount of memory, and the system requires more memory for its processes and to allocate to other processes.
A simple example with OOM Killer: if will swap out the desktop environment, drop the whole page cache, and empty every buffer before it will ultimately kill a process.
This tool named earlyoom is a simple, stable, and tiny OOM prevention daemon.
That is written in C and is the best choice for old servers.
It has minimum dependencies and can work with the oldest kernels.
The earlyoom checks the amount of available memory and free swap up.
This command causes memory consumption, and the process will exits before OOM occurs if this tool works.
The tool can be installed with the following command:
[root@desk mythcat]# dnf install earlyoom
Last metadata expiration check: 0:38:00 ago on Sun 13 Jun 2021 11:38:22 AM EEST.
Package earlyoom-1.6.2-3.fc34.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
You can see all options for this tool with this command:
[root@desk mythcat]# earlyoom -h
earlyoom 1.6.2
Usage: earlyoom [OPTION]...
Then the service is activated with:
[root@desk mythcat]# systemctl enable --now earlyoom
My configuration file for this tool is:
[root@desk mythcat]# vim  /etc/default/earlyoom
EARLYOOM_ARGS="-r 1 -m 1 -s 5 -M 1514244 --prefer '^Web Content$' 
--avoid '^(dnf|packagekitd|gnome-shell|gnome-session-c|gnome-session-b|lightdm|
sddm|sddm-helper|gdm|gdm-wayland-ses|gdm-session-wor|gdm-x-session|Xorg|Xwayland|
systemd|systemd-logind|dbus-daemon|dbus-broker|cinnamon|cinnamon-sessio|kwin_x11|
kwin_wayland|plasmashell|ksmserver|plasma_session|startplasma-way|xfce4-session|
mate-session|marco|lxqt-session|openbox|cryptsetup)$'"
You can check the status of the service to be active:
[root@desk mythcat]# systemctl status earlyoom
...
Active: active (running) since 
... 
You can test it easily with these commands:
[root@desk mythcat]# sudo swapoff -a
[root@desk mythcat]# tail /dev/zero
Terminated
The process tail must occupy the entire available RAM on the system, this will low your system and after the earlyoom tool freeing the RAM all works well.
To see the tool on work, use the command:
[root@desk mythcat]# earlyoom 
earlyoom 1.6.2
mem total: 7899 MiB, swap total: 7898 MiB
sending SIGTERM when mem <= 10.00% and swap <= 10.00%,
        SIGKILL when mem <=  5.00% and swap <=  5.00%
mem avail:  4742 of  7899 MiB (60.04%), swap free: 7898 of 7898 MiB (100.00%)
mem avail:  4742 of  7899 MiB (60.04%), swap free: 7898 of 7898 MiB (100.00%)
mem avail:  4751 of  7899 MiB (60.15%), swap free: 7898 of 7898 MiB (100.00%)
mem avail:  4754 of  7899 MiB (60.19%), swap free: 7898 of 7898 MiB (100.00%)

Thursday, June 10, 2021

Fedora 34 : Fix conflicts are between the version of the packages.

You can have conflicts are between the version of the packages, see this example:
[root@desk mythcat]# dnf update --refresh
file /usr/share/doc/gstreamer1-plugins-good/README from install of 
gstreamer1-plugins-good-1.19.1-1.fc34.i686 conflicts with file from package 
gstreamer1-plugins-good-1.18.4-2.fc34.x86_64
This command will fix conflicts are between the version of the packages:
[root@desk mythcat]# dnf remove --duplicates
...
 gstreamer1                          i686    1.19.1-1.fc34       updates  1.4 M
Reinstalling:
 gst-editing-services                x86_64  1.19.1-1.fc34       updates  608 k
     replacing  gst-editing-services.x86_64 1.18.4-1.fc34
 gstreamer1                          x86_64  1.19.1-1.fc34       updates  1.3 M
     replacing  gstreamer1.x86_64 1.18.4-2.fc34
 gstreamer1-plugins-bad-free         x86_64  1.19.1-1.fc34       updates  2.6 M
     replacing  gstreamer1-plugins-bad-free.x86_64 1.18.4-1.fc34
 gstreamer1-plugins-bad-free-extras  x86_64  1.19.1-1.fc34       updates  422 k
     replacing  gstreamer1-plugins-bad-free-extras.x86_64 1.18.4-1.fc34
 gstreamer1-plugins-ugly-free        x86_64  1.19.1-1.fc34       updates  103 k
     replacing  gstreamer1-plugins-ugly-free.x86_64 1.18.4-1.fc34
 gucharmap                           x86_64  13.0.8-1.fc34       updates  514 k
     replacing  gucharmap.x86_64 13.0.7-1.fc34
 gucharmap-libs                      x86_64  13.0.8-1.fc34       updates  1.2 M
     replacing  gucharmap-libs.x86_64 13.0.7-1.fc34
 kernel-headers                      x86_64  5.12.9-300.fc34     updates  1.2 M
     replacing  kernel-headers.x86_64 5.12.5-300.fc34
...
The next command will update you Linux distro:
[root@desk mythcat]# dnf update --refresh
Copr repo for dotnet owned by @dotnet-sig       5.1 kB/s | 3.3 kB     00:00    
Adobe Systems Incorporated                      7.6 kB/s | 2.9 kB     00:00    
Fedora 34 - x86_64                               58 kB/s |  26 kB     00:00    
Fedora 34 - x86_64 - Updates                     41 kB/s |  23 kB     00:00    
google-chrome                                   9.0 kB/s | 1.3 kB     00:00    
RPM Fusion for Fedora 34 - Free                  16 kB/s | 7.9 kB     00:00    
RPM Fusion for Fedora 34 - Free - Updates        18 kB/s | 7.9 kB     00:00    
RPM Fusion for Fedora 34 - Nonfree               21 kB/s | 8.0 kB     00:00    
RPM Fusion for Fedora 34 - Nonfree - Updates     13 kB/s | 8.0 kB     00:00    
The Zeek Network Security Monitor. (Fedora_33)  6.6 kB/s | 1.7 kB     00:00    
Visual Studio Code                              6.0 kB/s | 3.0 kB     00:00    
WineHQ packages                                 9.3 kB/s | 3.2 kB     00:00    
Dependencies resolved.
...
 gstreamer1-plugins-good-1.19.1-1.fc34.i686  
...

Wednesday, June 9, 2021

Fedora 34 : Programming with the ncurses library - part 003.

This is a simple example with ncurses library to see how can define an array and used with random colors:
This example is build with this command:
[mythcat@desk ncursesProject]$ gcc test_008.c -o test_008 -lncurses
This is source code:
#include <ncurses.h>
#include <stdlib.h> 

int main(void) {
    
    initscr();
    
    start_color();
    
    char colors[8][20] = {
    "COLOR_BLACK",
    "COLOR_RED",
    "COLOR_GREEN",
    "COLOR_YELLOW",
    "COLOR_BLUE",
    "COLOR_MAGENTA",
    "COLOR_CYAN",
    "COLOR_WHITE"
    };
    
    int n;
    for ( n=0 ; n<16 ; ++n )
    {
        int aleator1 = rand() % 256 + 1;
        int result1 = *colors[aleator1];
        int aleator2 = rand() % 256 + 1;
        int result2 = *colors[aleator2];
        //printw("%d",result1);
        init_pair(n, result1, result2);
        attron(COLOR_PAIR(n));
        printw("Hello word!\n");
    }
    
    refresh();

    getch();

    endwin();
}

Saturday, June 5, 2021

Fedora 34 : Neix feed reader.

neix is a simple, work in progress terminal feed reader for all common RSS/Atom feeds on the web out there.
Let't install from the GitHub repository.
[mythcat@desk ~]$ git clone https://github.com/tomschwarz/neix.git  
Cloning into 'neix'...
remote: Enumerating objects: 2574, done.
remote: Counting objects: 100% (365/365), done.
remote: Compressing objects: 100% (274/274), done.
remote: Total 2574 (delta 189), reused 198 (delta 77), pack-reused 2209
Receiving objects: 100% (2574/2574), 26.07 MiB | 6.27 MiB/s, done.
Resolving deltas: 100% (1529/1529), done.
[mythcat@desk ~]$ cd neix
[mythcat@desk neix]$ cmake .
-- The C compiler identification is GNU 11.1.1
-- The CXX compiler identification is GNU 11.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
...
-- Found Curses: /usr/lib64/libncursesw.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mythcat/neix
[mythcat@desk neix]$ make 
Scanning dependencies of target neixParser
[  5%] Building CXX object CMakeFiles/neixParser.dir/src/parser/FactoryParser.cpp.o
...
[ 89%] Built target neixFeed
Scanning dependencies of target neix
[ 94%] Building CXX object CMakeFiles/neix.dir/src/main.cpp.o
[100%] Linking CXX executable bin/neix
[100%] Built target neix
[mythcat@desk neix]$ sudo make install
[sudo] password for mythcat: 
[ 26%] Built target neixParser
[ 42%] Built target neixConfig
[ 57%] Built target neixApplication
[ 73%] Built target neixHelper
[ 89%] Built target neixFeed
[100%] Built target neix
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/neix
-- Installing: /usr/local/share/man/man1/neix.1
-- Installing: /usr/local/share/neix/neix.conf
-- Installing: /usr/local/share/neix/feeds.conf
Let's run it:
[mythcat@desk neix]$ neix 
[neix] Starting version v0.1.5
[neix] Loading configuration files
[neix] Loading feeds 
[neix] Launch TUI 
Use feeds.conf to set the list of feeds you want to read.
This is a screenshot with the result of the build:

Saturday, May 29, 2021

Fedora 34 : Upgrade to the last version Fedora 34 Linux distro.

Today I upgraded from the fedora 33 version to the new Fedora 34 Linux distro version.
Here are the commands I used to upgrade this Linux distro:
[root@desk mythcat]# dnf upgrade 
[root@desk mythcat]# dnf --refresh upgrade
[root@desk mythcat]# dnf system-upgrade reboot
The whole process will require a restart and then continue with the following commands:
[root@desk mythcat]# dnf install dnf-plugin-system-upgrade --best
[root@desk mythcat]# dnf system-upgrade download --refresh --releasever=34 --allowerasing --skip-broken
[root@desk mythcat]# dnf system-upgrade reboot
[root@desk mythcat]# rpm --rebuilddb
[root@desk mythcat]# dnf distro-sync --setopt=deltarpm=0
[root@desk mythcat]# dnf install rpmconf
[root@desk mythcat]# rpmconf -a
[root@desk mythcat]# reboot
You can find this version on the official webpage.

Tuesday, May 25, 2021

Fedora 33 : Programming with the ncurses library - part 002.

Another example with this library, see the screenshot:

#include <ncurses.h&gt 

WINDOW *win;
int startx, starty, width, height;
int cport;


WINDOW *makewin(int h, int w, int y, int x)
{
    WINDOW *lwin;

    lwin = newwin(h, w, y, x);
    box(lwin, 0 , 0);
    wrefresh(lwin);

    return lwin;
}

void dewin(WINDOW *lwin)
{
    wborder(lwin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
    wrefresh(lwin);
    delwin(lwin);
}

void getInput(){
    win = makewin(height, width, starty, startx);
    wbkgd(win, COLOR_PAIR(1));
    mvwprintw(win, 0, 8, "Question 1 : ");
    mvwprintw(win, 2, 4, "What is your age?");
    mvwprintw(win, 3, 4, "dd/mm/yy:");
    wrefresh(win);
    wscanw(win, "%d", &cport);
}

int main()
{
    initscr();
    cbreak();
    keypad(stdscr, TRUE);
    start_color();
    init_pair(1,COLOR_WHITE, COLOR_BLACK);
    init_pair(2,COLOR_WHITE, COLOR_BLUE);
    bkgd(COLOR_PAIR(2));
    refresh();
    
    height = 6;
    width = 30;
    starty = (LINES - height) / 2;
    startx = (COLS - width) / 2;
    
    getInput();
    getch();

    dewin(win);
    endwin();
    return 0;
}