# psagar-dev/testing_linux_servers_hv architecture

> Architecture diagram of the GitHub repository psagar-dev/testing_linux_servers_hv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/psagar-dev/testing_linux_servers_hv
- Repository: https://github.com/psagar-dev/testing_linux_servers_hv

## Overview

- System Monitoring (system_monitor.sh)
- User Management (create_list_user.sh, referenced as the user management script)
- Web Server Backup Automation (apache_backup.sh and nginx_backup.sh)

##### Project Components
a. System Monitoring Module:
– Inside this module list its responsibilities: monitoring CPU, memory, disk, and process metrics.
– Highlight that it uses system utilities (nmon, htop, df, du, ps) and writes logs to a dedicated log directory (/var/log/system_monitor).
– Note that the script also sets up a cron job to schedule periodic execution.

b. User Management Module:
– List its main functions such as listing users and creating new users (with password and workspace configuration), along with enforcing password policies.
– Include the fact that it interacts directly with Linux system commands (useradd, chpasswd, chage) and modifies configuration files like /etc/login.defs and /etc/security/pwquality.conf.

c. Backup Configuration Module:
– Illustrate two backup sub-components within one module: one for Apache (apache_backup.sh) and one for Nginx (nginx_backup.sh).
– For each, note that they verify source directories, create compressed backups (tar.gz), log operations, and check backup integrity.
– Indicate that these scripts are scheduled via cron (running every Tuesday at 12:00 AM) and store backup files in /backups.

##### Underlying Infrastructure and External Dependencies
– Inside, indicate the relevant system directories:
- /var/log/system_monitor for logs (used by the system monitoring script)
- /backups to store backup archives (used by the backup scripts)
– Show external utilities and packages such as nmon, htop, and libpam-pwquality (highlight that some scripts will install/check these dependencies).

##### Data Flow and Interactions
– Inside each module, indicate data inputs and outputs:

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Linux Environment"
        Cron["Cron Daemon"]:::cron
        LogDir["/var/log/system_monitor"]:::storage
        BackupDir["/backups"]:::storage
        SysConfig["System Config Files (/etc/login.defs, /etc/security/pwquality.conf)"]:::config

        subgraph "System Monitoring Module"
            SM["System Monitoring Script"]:::script
            SMInfo["Monitors: CPU, Memory, Disk, Processes\nUses: nmon, htop, df, du, ps\nWrites logs to log directory\nSchedules periodic execution via cron"]:::note
            SM --- SMInfo
        end

        subgraph "User Management Module"
            UM["User Management Script"]:::script
            UMInfo["Lists users, creates new users with password and workspace setup\nEnforces password policies using: useradd, chpasswd, chage"]:::note
            UM --- UMInfo
        end

        subgraph "Backup Configuration Module"
            Apache["Apache Backup Script"]:::script
            Nginx["Nginx Backup Script"]:::script
            BackupInfo["Verifies directories, creates tar.gz backups, logs operations, checks backup integrity\nScheduled every Tuesday at 12:00 AM"]:::note
            Apache --- BackupInfo
            Nginx --- BackupInfo
        end

        %% Cron scheduling arrows
        Cron -->|"schedule_trigger"| SM
        Cron -->|"schedule_trigger"| Apache
        Cron -->|"schedule_trigger"| Nginx

        %% Data and resource interactions
        SM -->|"logs_written"| LogDir
        Apache -->|"backup_stored"| BackupDir
        Nginx -->|"backup_stored"| BackupDir

        UM -->|"updates"| SysConfig

        %% External Dependencies within modules
        subgraph "External Utilities"
            Nmon["nmon"]:::utility
            Htop["htop"]:::utility
            Libpam["libpam-pwquality"]:::utility
        end

        SMInfo ---|"uses"| Nmon
        SMInfo ---|"uses"| Htop
        UMInfo ---|"checks"| Libpam
    end

    %% Click Events
    click SM "https://github.com/psagar-dev/testing_linux_servers_hv/blob/main/system_monitor.sh"
    click UM "https://github.com/psagar-dev/testing_linux_servers_hv/blob/main/create_list_user.sh"
    click Apache "https://github.com/psagar-dev/testing_linux_servers_hv/blob/main/apache_backup.sh"
    click Nginx "https://github.com/psagar-dev/testing_linux_servers_hv/blob/main/nginx_backup.sh"

    %% Style Definitions
    classDef script fill:#fceabb,stroke:#d68a00,stroke-width:2px;
    classDef cron fill:#c2e7da,stroke:#3aafa9,stroke-width:2px;
    classDef storage fill:#d0f0fd,stroke:#0288d1,stroke-width:2px;
    classDef config fill:#ffd1dc,stroke:#e91e63,stroke-width:2px;
    classDef note fill:#e8f5e9,stroke:#66bb6a,stroke-width:1px,stroke-dasharray: 5 5;
    classDef utility fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
```
