Is this content useful for you? Support this site by donating any amount....(takes you to Paypal website)
Other Amount

Categories

Linux Monitoring Article Icon Cylinder
BASH Shell, IT Infrastructure Systems, Linux, Operating Systems

Linux Based Monitoring Setup

Read Time:2 Minute, 30 Second

Last Updated on October 3, 2022 by Hammad Rauf

This post describes how to setup easy to re-use monitoring on a Linux desktop system. We will need Screen and Terminator. We will monitor the Django (A python web application) console output.

Screen – A virtual Terminal Emulator

We will first install Screen. Screen is a Virtual Terminal Emulator specially created for multitasking. It allows you to start a program that logs output to console, in an off-screen session. You can later Attach or Detach to that screen session to look at the output.

Terminator – A Terminal program

Terminator is a fancy Terminal with easy to use launch options. It is available through the EPEL yum repository.

Install Required Tools

sudo yum install screen
sudo yum install terminator

OR

sudo apt-get install screen
sudo apt-get install terminator

Script for Starting Screen Sessions

Save the following scripts as “start-django-portal.sh” in /home/username folder. Then chmod +x FileName.sh.

#!/bin/sh
screen -S django_portal -md python ~/PycharmProjects/mysite/manage.py runserver &
sleep 4
screen –ls
/usr/bin/firefox http://127.0.0.1:8000

Script for Monitoring Screen Sessions

Save the following scripts as “monitor-screens.sh” in /home/username folder. Then chmod +x FileName.sh.

#!/bin/bash
DISP_ARRAY=(636x420+0+0 636x420-0+0 636x420+0-0 636x420-0-0)
DISP_ARRAY2=(77x23+0+0 77x23-0+0 77x23+0-0 77x23-0-0)
COUNT=0
for scr in $(screen -ls | grep "Detached" | awk '{print $1}')
do
# echo $scr
echo ${DISP_ARRAY[$COUNT]}
# gnome-terminal -e "screen -r $scr" --geometry=${DISP_ARRAY2[$COUNT]} --background=black --foreground=white --title=$scr
terminator -e "screen -r $scr" --geometry=${DISP_ARRAY[$COUNT]} --title=$scr &
COUNT=$(((COUNT+1)%4))
done
exit $?

Desktop Launcher for Screen Start

This launcher is for GNOME Desktop. Save the following as “start-django-portal.desktop” in /home/username/Desktop folder. You can save a suitable screen capture PNG image in /home/username/Icons folder to work as icon

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Name=Start Django-Portal
Icon=/home/username/Icons/img.PNG
Exec="/home/username/start-django-portal.sh"
Comment=Script to start Django-Portal
Categories=Development;
Terminal=false

Desktop Launcher for Screen Monitor

This launcher is for the GNOME desktop. Save the following as “monitor-screens.desktop” in /home/username/Desktop folder. You can save a suitable screen capture PNG image in /home/username/Icons folder to work as icon.

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Name=Monitor Screens
Icon=/home/username/Icons/img2.PNG
Exec="/home/username/monitor-screens.sh"
Comment=Script to monitor detached Screen sessions
Categories=Development;
Terminal=false
Image showing 4 Screens Monitoring Consoles on Linux Desktop
Figure 1: A sample of the monitoring windows. In this case 4 Screen sessions are being monitored in 1 corner of screen each.

Further Reading

Have a look at the Screen manual pages (or try this link) for more insight into using screen.

Leave a Reply

Your email address will not be published. Required fields are marked *