cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
11.15k stars 1.1k forks source link

Ubuntu script data output in Microsoft SQL server #16590

Closed yasirvohra closed 2 years ago

yasirvohra commented 2 years ago

Hi,

SCENARIO : I have created script which is giving output for CPU,RAM,HDD (root) usage and saving output values in (.csv) file /mnt/report.csv.


!/bin/bash

--------Print Operating System Details--------

HOSTNAME=$(hostname)

--------Check for HDD--------

DISK_USAGE=df -h / | awk '{ print $5}' | tail -1

--------Check for CPU Utilization--------

CPU_IDLE=top -b -n 1 | grep Cpu | awk '{print $8}'|cut -f 1 -d "." CPU_USED=expr 100 - $CPU_IDLE

--------Check for MEMORY Utilization--------

MEM_USGAE=free | grep Mem | awk '{print $3/$2 * 100.0}' | cut -f1 -d'.' TIME=date +%H:%M DATE=date +%d/%m/%Y

echo "$HOSTNAME,$DATE,$TIME,${CPU_USED}%,${MEM_USGAE}%,${DISK_USAGE}" >> /mnt/report.csv


Secondly I have schedule cron job to run this script every after 10 minutes --> so in file (/mnt/report.csv) I am getting data every after 10 minutes.

Requirement : I have Microsoft SQL Server running on windows server 2019 already. I need to send output from this script (CPU,RAM,HDD - usage) directly to (Microsoft SQL Server database - table) rather then file (/mnt/report.csv) every after 10 minutes.

Any advice or help please what needs to be done ??

jelly commented 2 years ago

As this is not directly related to cockpit, I would recommend asking your question on the ubuntu forums or stack overflow.