Add full Oculog codebase
This commit is contained in:
10
clients/ubuntu/debian/control
Normal file
10
clients/ubuntu/debian/control
Normal file
@@ -0,0 +1,10 @@
|
||||
Package: oculog-client
|
||||
Version: 1.0.0
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: python3 (>= 3.6), python3-pip
|
||||
Maintainer: Ormentia <support@ormentia.com>
|
||||
Description: Oculog Client Agent for Server Metrics Collection
|
||||
Oculog client agent that collects system metrics (CPU, memory, disk, network)
|
||||
and sends them to the Oculog observability platform server.
|
||||
55
clients/ubuntu/debian/postinst
Executable file
55
clients/ubuntu/debian/postinst
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Post-installation script
|
||||
echo "Configuring Oculog client..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p /var/log/oculog
|
||||
mkdir -p /etc/oculog
|
||||
|
||||
# Install Python dependencies using system-managed approach
|
||||
# Try to install via apt first (for newer Ubuntu versions)
|
||||
if apt-cache show python3-psutil >/dev/null 2>&1 && apt-cache show python3-requests >/dev/null 2>&1; then
|
||||
apt-get update -qq
|
||||
if apt-get install -y -qq python3-psutil python3-requests >/dev/null 2>&1; then
|
||||
PYTHON_BIN="/usr/bin/python3"
|
||||
else
|
||||
USE_VENV=1
|
||||
fi
|
||||
else
|
||||
USE_VENV=1
|
||||
fi
|
||||
|
||||
# If apt packages aren't available, use a virtual environment
|
||||
if [ "$USE_VENV" = "1" ]; then
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq python3-venv python3-pip >/dev/null 2>&1 || true
|
||||
|
||||
# Create virtual environment
|
||||
python3 -m venv /opt/oculog/venv
|
||||
|
||||
# Install packages in virtual environment
|
||||
/opt/oculog/venv/bin/pip install --quiet --upgrade pip
|
||||
/opt/oculog/venv/bin/pip install --quiet psutil==5.9.6 requests==2.31.0
|
||||
|
||||
PYTHON_BIN="/opt/oculog/venv/bin/python3"
|
||||
|
||||
# Update shebang in client script
|
||||
sed -i "1s|.*|#!${PYTHON_BIN}|" /opt/oculog/client.py
|
||||
|
||||
# Update systemd service to use venv Python
|
||||
sed -i "s|ExecStart=.*|ExecStart=${PYTHON_BIN} /opt/oculog/client.py|" /etc/systemd/system/oculog-client.service
|
||||
fi
|
||||
|
||||
# Enable and start service if config exists
|
||||
if [ -f /etc/oculog/client.conf ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable oculog-client.service 2>/dev/null || true
|
||||
systemctl start oculog-client.service 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Oculog client installed successfully!"
|
||||
echo "Please configure /etc/oculog/client.conf before starting the service."
|
||||
|
||||
exit 0
|
||||
26
clients/ubuntu/debian/postrm
Executable file
26
clients/ubuntu/debian/postrm
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Post-removal script
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
||||
# Stop and disable service
|
||||
systemctl stop oculog-client.service 2>/dev/null || true
|
||||
systemctl disable oculog-client.service 2>/dev/null || true
|
||||
|
||||
# Remove service file
|
||||
rm -f /etc/systemd/system/oculog-client.service
|
||||
systemctl daemon-reload
|
||||
|
||||
# Remove symlink
|
||||
rm -f /usr/local/bin/oculog-client
|
||||
|
||||
if [ "$1" = "purge" ]; then
|
||||
# Remove configuration and logs (optional - commented out to preserve data)
|
||||
# rm -rf /etc/oculog
|
||||
# rm -rf /var/log/oculog
|
||||
# rm -rf /opt/oculog
|
||||
echo "Configuration and logs preserved at /etc/oculog and /var/log/oculog"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
16
clients/ubuntu/debian/rules
Executable file
16
clients/ubuntu/debian/rules
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install
|
||||
# Install client script
|
||||
install -d $(CURDIR)/debian/oculog-client/opt/oculog
|
||||
install -m 755 client.py $(CURDIR)/debian/oculog-client/opt/oculog/
|
||||
# Install systemd service
|
||||
install -d $(CURDIR)/debian/oculog-client/etc/systemd/system
|
||||
install -m 644 oculog-client.service $(CURDIR)/debian/oculog-client/etc/systemd/system/
|
||||
# Create symlink
|
||||
install -d $(CURDIR)/debian/oculog-client/usr/local/bin
|
||||
ln -sf /opt/oculog/client.py $(CURDIR)/debian/oculog-client/usr/local/bin/oculog-client
|
||||
Reference in New Issue
Block a user