| Nächste Überarbeitung | Vorhergehende Überarbeitung |
| freebsd:freebsd_-_monitoring [2018-06-19 09:57:29] – angelegt manfred | freebsd:freebsd_-_monitoring [2026-01-16 11:42:00] (aktuell) – manfred |
|---|
| | ====== FreeBSD - Monitoring ====== |
| | |
| | siehe auch: [[::Systemwerkzeuge]] |
| | |
| | |
| | ===== Mit System-Werkzeugen ===== |
| | |
| | [root@freebsd13 ~]# top |
| | |
| | [root@freebsd13 ~]# cd /usr/ports/sysutils/freecolor/ |
| | [root@freebsd13 /usr/ports/sysutils/freecolor]# make clean |
| | [root@freebsd13 /usr/ports/sysutils/freecolor]# make |
| | [root@freebsd13 /usr/ports/sysutils/freecolor]# make install |
| | [root@freebsd13 /usr/ports/sysutils/freecolor]# make clean |
| | [root@freebsd13 /usr/ports/sysutils/freecolor]# cd |
| | |
| | [root@freebsd13 ~]# freecolor -mots 1 |
| | total used free shared buffers cached |
| | Mem: 63401 54268 9132 0 0 0 |
| | Swap: 2048 1916 131 |
| | Total: 65449 = ( 56184 (used) + 9264 (free)) |
| | |
| | Es sind ~56 GiB von 64 GiB RAM belegt. |
| | |
| | |
| | ===== Grafana ===== |
| | |
| | * [[https://grafana.com/grafana|Grafana]] |
| | * //[[https://www.robustperception.io/setting-up-grafana-for-prometheus/|Setting up Grafana for Prometheus]]// |
| | * [[https://grafana.com/plugins|Plugins]] |
| | * [[https://grafana.com/plugins/prometheus|Prometheus]] |
| | * **[[https://grafana.com/dashboards/4260|Node Exporter FreeBSD (Grafana dashboard ID 4260)]]** |
| | * //[[https://gist.github.com/hbokh/d07fbbf8c2411efd1b4e0064d4b2ed93|Prometheus 2.1.0 and a FreeBSD node_exporter - Grafana dashboard ID 4260]]// |
| | |
| | ===== Prometheus ===== |
| | |
| | <file bash /root/bin/dev_-_var_lib_mysql.sh> |
| | #!/bin/bash |
| | |
| | # > df -T /var/lib/mysql |
| | # Filesystem Type 1K-blocks Used Available Use% Mounted on |
| | # /dev/mapper/vgmysql-lvolmysql ext4 4226435512 2283978596 1749651528 57% /var/lib/mysql |
| | |
| | # > df -T /var/lib/mysql |
| | # Filesystem Type 1K-blocks Used Available Use% Mounted on |
| | # mysql_datadir zfs 142989952 22156976 120832976 16% /var/lib/mysql |
| | |
| | VAR_LIB_MYSQL="$(df -T /var/lib/mysql | grep -Ev '^Filesystem' | awk '{print $1,$2}')" |
| | #echo "VAR_LIB_MYSQL=${VAR_LIB_MYSQL}" |
| | |
| | DEV_NAME="$(echo "${VAR_LIB_MYSQL}" | awk '{print $1}')" |
| | FS_NAME="$(echo "${VAR_LIB_MYSQL}" | awk '{print $2}')" |
| | if [ zfs = "${FS_NAME}" ] ; then |
| | #zpool status ${DEV_NAME} | sed -ne '/config:/,/errors:/p' | grep -Ev 'config:|NAME[[:space:]]+STATE|errors:|^[[:space:]]*$' | tail -n1 | awk '{print $1}' |
| | #zpool iostat -v ${DEV_NAME} | sed -ne '/-------------/,/-------------/p' | grep -Fv -- '-------------' | grep -Fv ${DEV_NAME} | awk '{print $1}' |
| | ZPOOL_IOSTAT="$(zpool iostat -v ${DEV_NAME} | sed -ne '/-------------/,/-------------/p' | grep -Fv -- '-------------' | grep -Fv ${DEV_NAME})" |
| | DAS_DEV="$(echo "${ZPOOL_IOSTAT}" | awk '{print $1}')" |
| | else |
| | DAS_DEV="$(readlink -f ${DEV_NAME})" |
| | fi |
| | |
| | if [ -e "${DAS_DEV}" ] ; then |
| | #ls -lha ${DAS_DEV} |
| | echo ${DAS_DEV} |
| | else |
| | #ls -lha /dev/${DAS_DEV} |
| | echo /dev/${DAS_DEV} |
| | fi |
| | </file> |
| | |
| | <file bash /root/bin/Connections-Exporter.sh> |
| | #!/bin/bash |
| | |
| | DER_NAME="$(hostname -s)" |
| | TEXTFILE_DIR="/prometheus" |
| | VERBINDUNGEN="verbindungen" |
| | V_STATUS="/var/tmp/status" |
| | JETZT="$(date +'%H-%M')" |
| | |
| | #==============================================================================# |
| | |
| | GERAET="$(/root/bin/dev_-_var_lib_mysql.sh)" |
| | if [ ! -e "${GERAET}" ] ; then |
| | #GERAET="vda" |
| | GERAET="dm-0" # /dev/mapper/vgmysql-lvolmysql |
| | #GERAET="vdb" # ZFS-Pool: mysql_datadir |
| | fi |
| | |
| | #==============================================================================# |
| | |
| | mkdir -p ${TEXTFILE_DIR}/ |
| | mkdir -p ${V_STATUS}/ |
| | |
| | ( |
| | MESSZEITPUNKT="$(date +'%s')" |
| | echo "Messzeitpunkt ${MESSZEITPUNKT}" |
| | echo "Der_Name ${DER_NAME}" |
| | |
| | #------------------------------------------------------------------------------# |
| | # DEV |
| | |
| | AUSGABE="$(iostat -md ${GERAET} | egrep -v '^$' | tail -n2)" |
| | |
| | SPALTEN="$(echo "${AUSGABE}" | tail -n1 | wc -w)" |
| | for i in $(seq 2 ${SPALTEN}) |
| | do |
| | echo "${GERAET}_$(echo "${AUSGABE}" | awk -v spalte="${i}" '{print $spalte}' | tr -s '\n' ' ' | sed 's|[/]|_je_|g;s/[,]/./g;s/[ ]*$//')" |
| | done |
| | |
| | #------------------------------------------------------------------------------# |
| | # ZFS |
| | |
| | DIE_ZPOOLS="$(zpool list 2>/dev/null | grep -Ev '^NAME' | awk '{print $1}')" |
| | ZAHL_ZPOOLS="$(echo "${DIE_ZPOOLS}" | wc -l)" |
| | if [ 0 -lt "${ZAHL_ZPOOLS}" ] ; then |
| | for DER_ZPOOL in ${DIE_ZPOOLS} |
| | do |
| | zpool iostat -p ${DER_ZPOOL} | grep -E '^mysql_datadir' | while read POOL CAPACITY_ALLOC CAPACITY_FREE OPERATIONS_READ OPERATIONS_WRITE BANDWIDTH_READ BANDWIDTH_WRITE |
| | do |
| | echo "${DER_ZPOOL}_Capacity_Alloc ${CAPACITY_ALLOC}" |
| | echo "${DER_ZPOOL}_Capacity_Free ${CAPACITY_FREE}" |
| | echo "${DER_ZPOOL}_Operations_Read ${OPERATIONS_READ}" |
| | echo "${DER_ZPOOL}_Operations_Write ${OPERATIONS_WRITE}" |
| | echo "${DER_ZPOOL}_Bandwidth_Read ${BANDWIDTH_READ}" |
| | echo "${DER_ZPOOL}_Bandwidth_Write ${BANDWIDTH_WRITE}" |
| | done |
| | done |
| | fi |
| | |
| | #------------------------------------------------------------------------------# |
| | |
| | MYSQL="mysql -S /var/run/mysqld/mysqld.sock" |
| | |
| | # DB-Version |
| | echo "SHOW VARIABLES LIKE 'version';" | ${MYSQL} -Ns 2>/dev/null |
| | echo "SHOW VARIABLES LIKE 'version_comment';" | ${MYSQL} -Ns 2>/dev/null |
| | |
| | # Max. Anzahl an erlaubten Verbindungen |
| | echo "SHOW VARIABLES WHERE VARIABLE_NAME IN ('max_connections');" | ${MYSQL} -Ns 2>/dev/null |
| | |
| | # Status der Verbindungen |
| | echo " |
| | SHOW STATUS |
| | WHERE variable_name IN ( |
| | 'Aborted_connects', |
| | 'Connections', |
| | 'Max_used_connections', |
| | 'Max_used_connections_time', |
| | 'Performance_schema_session_connect_attrs_longest_seen', |
| | 'Threads_connected' |
| | ); |
| | " | ${MYSQL} -Ns 2>/dev/null | sed 's/[[:space:]][[:space:]]*/ /' |
| | ) | while read ZEILE |
| | do |
| | echo "${ZEILE}" |
| | echo |
| | done | tee ${V_STATUS}/status_${JETZT} > ${TEXTFILE_DIR}/${VERBINDUNGEN}.prom.$$ |
| | mv ${TEXTFILE_DIR}/${VERBINDUNGEN}.prom.$$ ${TEXTFILE_DIR}/${VERBINDUNGEN}.prom |
| | |
| | #==============================================================================# |
| | </file> |
| | |
| | <file bash /etc/cron.d/Connections-Exporter> |
| | MAILTO='' |
| | * * * * * root /root/bin/Connections-Exporter.sh |
| | </file> |
| | |
| |