Serghey Rodin 14 лет назад
Родитель
Сommit
a45bf7e4bd

+ 78 - 0
bin/v_upd_sys_rrd_ftp

@@ -0,0 +1,78 @@
+#!/bin/bash
+# info: updating ftp rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/ftp" ]; then
+    mkdir $V_RRD/ftp
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/ftp/ftp.rrd --step $V_RRD_STEP \
+        DS:A:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+a=0
+a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody| grep -v root|wc -l)
+
+# Updating rrd database
+rrdtool update $V_RRD/ftp/ftp.rrd N:$a
+
+# Updating daily graph
+rrdtool graph $V_RRD/ftp/ftp.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
+    --vertical-label "Connections" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:a=$V_RRD/ftp/ftp.rrd:A:AVERAGE \
+    COMMENT:'\r' \
+    LINE1:a#fefda0:"Users " \
+    GPRINT:a:'LAST:Current\:''%8.0lf' \
+    GPRINT:a:'MIN:Min\:''%8.0lf' \
+    GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 87 - 0
bin/v_upd_sys_rrd_httpd

@@ -0,0 +1,87 @@
+#!/bin/bash
+# info: updating httpd rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+source $V_FUNC/shared_func.sh
+source $V_FUNC/domain_func.sh
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/web" ]; then
+    mkdir $V_RRD/web
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/web/httpd.rrd --step $V_RRD_STEP \
+        DS:A:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+web_port=$(get_config_value '$WEB_PORT')
+server_status=$(wget -qO-  http://localhost:$web_port/server-status |\
+    grep 'currently being processed'| \
+    cut -f 2 -d '>' |\
+    sed 's/requests currently being processed, //' | \
+    cut -f 1,2 -d ' ')
+active=$(echo "$server_status"|cut -f 1 -d ' ')
+idle=$(echo "$server_status"|cut -f 1 -d ' ')
+a=$((active + idle))
+
+# Updating rrd database
+rrdtool update $V_RRD/web/httpd.rrd N:$a
+
+# Updating daily graph
+rrdtool graph $V_RRD/web/httpd.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "HTTPD Usage" \
+    --vertical-label "Connections" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:a=$V_RRD/web/httpd.rrd:A:AVERAGE \
+    COMMENT:'\r' \
+    LINE1:a#fefda0:"Connections " \
+    GPRINT:a:'LAST:Current\:''%8.0lf' \
+    GPRINT:a:'MIN:Min\:''%8.0lf' \
+    GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 84 - 0
bin/v_upd_sys_rrd_la

@@ -0,0 +1,84 @@
+#!/bin/bash
+# info: updating load average rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/la" ]; then
+    mkdir $V_RRD/la
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/la/la.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/la/la.rrd --step $V_RRD_STEP \
+        DS:LA:GAUGE:600:U:U \
+        DS:PR:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+loadavg=$(cat /proc/loadavg )
+la=$(echo "$loadavg"|cut -f 2 -d ' ')
+pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
+
+# Updating rrd database
+rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr
+
+# Updating daily graph
+rrdtool graph $V_RRD/la/la.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "Load Average" \
+    --vertical-label "Points" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:la=$V_RRD/la/la.rrd:LA:AVERAGE \
+    DEF:pr=$V_RRD/la/la.rrd:PR:AVERAGE \
+    COMMENT:'\r' \
+    AREA:la#9fec00:"LA * 100"\
+    GPRINT:la:'LAST: Current\:''%8.0lf'  \
+    GPRINT:la:'MIN: Min\:''%8.0lf'  \
+    GPRINT:la:'MAX: Max\:''%8.0lf\j'  \
+    LINE1:pr#1c74cd:"Procs # " \
+    GPRINT:pr:'LAST:Current\:''%8.0lf' \
+    GPRINT:pr:'MIN:Min\:''%8.0lf' \
+    GPRINT:pr:'MAX:Max\:''%8.0lf\j' >/dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 84 - 0
bin/v_upd_sys_rrd_mem

@@ -0,0 +1,84 @@
+#!/bin/bash
+# info: updating memory rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/mem" ]; then
+    mkdir $V_RRD/mem
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/mem/mem.rrd --step $V_RRD_STEP \
+        DS:RAM:GAUGE:600:U:U \
+        DS:SWAP:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+mem=$(free -m)
+ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
+swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
+
+# Updating rrd
+rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap
+
+# Updating daily graph
+rrdtool graph  $V_RRD/mem/mem.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "Memory Usage" \
+    --vertical-label "Mbytes" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:ram=$V_RRD/mem/mem.rrd:RAM:AVERAGE \
+    DEF:swap=$V_RRD/mem/mem.rrd:SWAP:AVERAGE \
+    COMMENT:'\r' \
+    AREA:ram#867995:"RAM "\
+    GPRINT:ram:'LAST: Current\:''%8.0lf'  \
+    GPRINT:ram:'MIN: Min\:''%8.0lf'  \
+    GPRINT:ram:'MAX: Max\:''%8.0lf\j'  \
+    LINE1:swap#f57900:"SWAP" \
+    GPRINT:swap:'LAST:Current\:''%8.0lf' \
+    GPRINT:swap:'MIN:Min\:''%8.0lf' \
+    GPRINT:swap:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 121 - 0
bin/v_upd_sys_rrd_mysql

@@ -0,0 +1,121 @@
+#!/bin/bash
+# info: updating MySQL rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_FUNC/shared_func.sh
+source $V_FUNC/db_func.sh
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/db" ]; then
+    mkdir $V_RRD/db
+fi
+
+# Parsing db hosts
+conf="$V_DB/mysql.conf"
+fields='$HOST'
+hosts=$(v_clear_list)
+check_row=$(echo "$hosts" |wc -l)
+if [ 0 -eq "$check_row" ]; then
+    exit
+fi
+
+# Parsing excludes
+for exclude in $(echo ${V_RRD_MYSQL_EXCLUDE//,/ }); do
+    hosts=$(echo "$hosts" |grep -vw "$exclude" )
+done
+
+for host in $hosts; do
+    # Checking database
+    if [ ! -e "$V_RRD/db/mysql_$host.rrd" ]; then
+        # Adding database
+        rrdtool create $V_RRD/db/mysql_$host.rrd --step $V_RRD_STEP \
+            DS:A:COUNTER:600:U:U \
+            DS:S:COUNTER:600:U:U \
+            RRA:AVERAGE:0.5:1:600 \
+            RRA:AVERAGE:0.5:6:700 \
+            RRA:AVERAGE:0.5:24:775 \
+            RRA:AVERAGE:0.5:288:797 \
+            RRA:MAX:0.5:1:600 \
+            RRA:MAX:0.5:6:700 \
+            RRA:MAX:0.5:24:775 \
+            RRA:MAX:0.5:288:797
+    fi
+
+    # Defining host credentials
+    host_str=$(grep "HOST='$host'" $conf)
+    for key in $host_str; do
+        eval ${key%%=*}=${key#*=}
+    done
+    sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
+
+    # Checking empty vars
+    if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
+        echo "Error: config is broken"
+        log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
+        exit $E_PARSE_ERROR
+    fi
+
+    # Parsing data
+    status=$($sql "SHOW GLOBAL STATUS"  2>/dev/null); code="$?"
+    if [ '0' -ne "$code" ]; then
+        active=0
+        slow=0
+    else
+        active=$(echo "$status"|grep 'Queries'|cut -f 2)
+        slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2)
+    fi
+
+    # Updating rrd
+    rrdtool update $V_RRD/db/mysql_$host.rrd N:$active:$slow
+
+    # Updating daily graph
+    rrdtool graph  $V_RRD/db/mysql_$host.png \
+        --imgformat PNG \
+        --height="120" \
+        --width="440" \
+        --start -1d \
+        --end now \
+        --title "MySQL Usage on $host" \
+        --vertical-label "Queries" \
+        --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+        -c "BACK#484439" \
+        -c "SHADEA#484439" \
+        -c "SHADEB#484439" \
+        -c "FONT#DDDDDD" \
+        -c "CANVAS#202020" \
+        -c "GRID#666666" \
+        -c "MGRID#AAAAAA" \
+        -c "FRAME#202020" \
+        -c "ARROW#FFFFFF" \
+        DEF:a=$V_RRD/db/mysql_$host.rrd:A:AVERAGE \
+        DEF:s=$V_RRD/db/mysql_$host.rrd:S:AVERAGE \
+        COMMENT:'\r' \
+        LINE1:a#fefda0:"Queries"\
+        GPRINT:a:'LAST: Current\:''%8.0lf'  \
+        GPRINT:a:'MIN: Min\:''%8.0lf'  \
+        GPRINT:a:'MAX: Max\:''%8.0lf\j'  \
+        AREA:s#f57900:"Slow  " \
+        GPRINT:s:'LAST:Current\:''%8.0lf' \
+        GPRINT:s:'MIN:Min\:''%8.0lf' \
+        GPRINT:s:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+done
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 96 - 0
bin/v_upd_sys_rrd_net

@@ -0,0 +1,96 @@
+#!/bin/bash
+# info: updating network rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/net" ]; then
+    mkdir $V_RRD/net
+fi
+
+# Parsing network interfaces
+ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g")
+
+# Parsing excludes
+for exclude in $(echo ${V_RRD_IFACE_EXCLUDE//,/ }); do
+    ifaces=$(echo "$ifaces" |grep -vw "$exclude" )
+done
+
+for iface in $ifaces; do
+    # Checking database
+    if [ ! -e "$V_RRD/net/$iface.rrd" ]; then
+        # Adding database
+        rrdtool create $V_RRD/net/$iface.rrd --step $V_RRD_STEP \
+            DS:RX:COUNTER:600:U:U \
+            DS:TX:COUNTER:600:U:U \
+            RRA:AVERAGE:0.5:1:600 \
+            RRA:AVERAGE:0.5:6:700 \
+            RRA:AVERAGE:0.5:24:775 \
+            RRA:AVERAGE:0.5:288:797 \
+            RRA:MAX:0.5:1:600 \
+            RRA:MAX:0.5:6:700 \
+            RRA:MAX:0.5:24:775 \
+            RRA:MAX:0.5:288:797
+    fi
+
+    # Parsing device stats
+    raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
+    rx=$(echo "$raw_iface" |awk '{print $2}')
+    tx=$(echo "$raw_iface" |awk '{print $10}')
+
+    # Updating rrd database
+    rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx
+
+    # Updating daily graph
+    rrdtool graph $V_RRD/net/$iface.png \
+        --imgformat PNG \
+        --height="120" \
+        --width="440" \
+        --start -1d \
+        --end now \
+        --title "Bandwidth Usage $iface" \
+        --vertical-label "KBytes" \
+        --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+        -c "BACK#484439" \
+        -c "SHADEA#484439" \
+        -c "SHADEB#484439" \
+        -c "FONT#DDDDDD" \
+        -c "CANVAS#202020" \
+        -c "GRID#666666" \
+        -c "MGRID#AAAAAA" \
+        -c "FRAME#202020" \
+        -c "ARROW#FFFFFF" \
+        DEF:inoctets=$V_RRD/net/$iface.rrd:RX:AVERAGE \
+        DEF:outoctets=$V_RRD/net/$iface.rrd:TX:AVERAGE \
+        "CDEF:in=inoctets,8,*" \
+        "CDEF:out=outoctets,8,*" \
+        COMMENT:'\r' \
+        AREA:in#9fec00:"Input (rx) "\
+        GPRINT:in:'LAST: Current\:''%8.0lf'  \
+        GPRINT:in:'MIN: Min\:''%8.0lf'  \
+        GPRINT:in:'MAX: Max\:''%8.0lf\j'  \
+        LINE1:out#1c74cd:"Output (tx)" \
+        GPRINT:out:'LAST:Current\:''%8.0lf' \
+        GPRINT:out:'MIN:Min\:''%8.0lf' \
+        GPRINT:out:'MAX:Max\:''%8.0lf\j'  > /dev/null
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 76 - 0
bin/v_upd_sys_rrd_nginx

@@ -0,0 +1,76 @@
+#!/bin/bash
+# info: updating httpd rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/web" ]; then
+    mkdir $V_RRD/web
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/web/nginx.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/web/nginx.rrd --step $V_RRD_STEP \
+        DS:A:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+a=$(wget -qO-  http://localhost:8084/|head -n1|cut -f 3 -d ' ')
+
+# Updating rrd database
+rrdtool update $V_RRD/web/nginx.rrd N:$a
+
+# Updating daily graph
+rrdtool graph $V_RRD/web/nginx.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "NGINX Usage" \
+    --vertical-label "Connections" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:a=$V_RRD/web/nginx.rrd:A:AVERAGE \
+    COMMENT:'\r' \
+    LINE1:a#fefda0:"Connections " \
+    GPRINT:a:'LAST:Current\:''%8.0lf' \
+    GPRINT:a:'MIN:Min\:''%8.0lf' \
+    GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 126 - 0
bin/v_upd_sys_rrd_pgsql

@@ -0,0 +1,126 @@
+#!/bin/bash
+# info: updating PostgreSQL rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_FUNC/shared_func.sh
+source $V_FUNC/db_func.sh
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/db" ]; then
+    mkdir $V_RRD/db
+fi
+
+# Parsing db hosts
+conf="$V_DB/pgsql.conf"
+fields='$HOST'
+hosts=$(v_clear_list)
+check_row=$(echo "$hosts" |wc -l)
+if [ 0 -eq "$check_row" ]; then
+    exit
+fi
+
+# Parsing excludes
+for exclude in $(echo ${V_RRD_PGSQL_EXCLUDE//,/ }); do
+    hosts=$(echo "$hosts" |grep -vw "$exclude" )
+done
+
+for host in $hosts; do
+    # Checking database
+    if [ ! -e "$V_RRD/db/pgsql_$host.rrd" ]; then
+        # Adding database
+        rrdtool create $V_RRD/db/pgsql_$host.rrd --step $V_RRD_STEP \
+            DS:A:GAUGE:600:U:U \
+            DS:T:COUNTER:600:U:U \
+            RRA:AVERAGE:0.5:1:600 \
+            RRA:AVERAGE:0.5:6:700 \
+            RRA:AVERAGE:0.5:24:775 \
+            RRA:AVERAGE:0.5:288:797 \
+            RRA:MAX:0.5:1:600 \
+            RRA:MAX:0.5:6:700 \
+            RRA:MAX:0.5:24:775 \
+            RRA:MAX:0.5:288:797
+    fi
+
+    # Defining host credentials
+    host_str=$(grep "HOST='$host'" $conf)
+    for key in $host_str; do
+        eval ${key%%=*}=${key#*=}
+    done
+
+    export PGPASSWORD="$PASSWORD"
+    sql="psql -h $HOST -U $USER -p $PORT -c"
+
+    # Checking empty vars
+    if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
+        echo "Error: config is broken"
+        log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
+        exit $E_PARSE_ERROR
+    fi
+
+
+    # Parsing data
+    q='select sum(xact_commit + xact_rollback), sum(numbackends) from pg_stat_database;'
+    status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?"
+    if [ '0' -ne "$code" ]; then
+        active=0
+        slow=0
+    else
+        active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}')
+        trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}')
+    fi
+
+    # Updating rrd
+    export PGPASSWORD='pgsql'
+    rrdtool update $V_RRD/db/pgsql_$host.rrd N:$active:$trans
+
+    # Updating daily graph
+    rrdtool graph  $V_RRD/db/pgsql_$host.png \
+        --imgformat PNG \
+        --height="120" \
+        --width="440" \
+        --start -1d \
+        --end now \
+        --title "PostgreSQL Usage on $host" \
+        --vertical-label "Queries" \
+        --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+        -c "BACK#484439" \
+        -c "SHADEA#484439" \
+        -c "SHADEB#484439" \
+        -c "FONT#DDDDDD" \
+        -c "CANVAS#202020" \
+        -c "GRID#666666" \
+        -c "MGRID#AAAAAA" \
+        -c "FRAME#202020" \
+        -c "ARROW#FFFFFF" \
+        DEF:a=$V_RRD/db/pgsql_$host.rrd:A:AVERAGE \
+        DEF:t=$V_RRD/db/pgsql_$host.rrd:T:AVERAGE \
+        COMMENT:'\r' \
+        LINE1:a#fefda0:"Queries     "\
+        GPRINT:a:'LAST: Current conn\:''%8.0lf'  \
+        GPRINT:a:'MIN: Min\:''%8.0lf'  \
+        GPRINT:a:'MAX: Max\:''%8.0lf\j'  \
+        LINE2:t#f57900:"Transactions" \
+        GPRINT:t:'LAST:Transactions\:''%8.0lf' \
+        GPRINT:t:'MIN:Min\:''%8.0lf' \
+        GPRINT:t:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+done
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 78 - 0
bin/v_upd_sys_rrd_ssh

@@ -0,0 +1,78 @@
+#!/bin/bash
+# info: updating ssh rrd
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking directory
+if [ ! -d "$V_RRD/ssh" ]; then
+    mkdir $V_RRD/ssh
+fi
+
+# Checking database
+if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then
+    # Adding database
+    rrdtool create $V_RRD/ssh/ssh.rrd --step $V_RRD_STEP \
+        DS:A:GAUGE:600:U:U \
+        RRA:AVERAGE:0.5:1:600 \
+        RRA:AVERAGE:0.5:6:700 \
+        RRA:AVERAGE:0.5:24:775 \
+        RRA:AVERAGE:0.5:288:797 \
+        RRA:MAX:0.5:1:600 \
+        RRA:MAX:0.5:6:700 \
+        RRA:MAX:0.5:24:775 \
+        RRA:MAX:0.5:288:797
+fi
+
+# Parsing data
+a=0
+a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
+
+# Updating rrd database
+rrdtool update $V_RRD/ssh/ssh.rrd N:$a
+
+# Updating daily graph
+rrdtool graph $V_RRD/ssh/ssh.png \
+    --imgformat PNG \
+    --height="120" \
+    --width="440" \
+    --start -1d \
+    --end now \
+    --title "SSH Usage" \
+    --vertical-label "Connections" \
+    --x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
+    -c "BACK#484439" \
+    -c "SHADEA#484439" \
+    -c "SHADEB#484439" \
+    -c "FONT#DDDDDD" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#AAAAAA" \
+    -c "FRAME#202020" \
+    -c "ARROW#FFFFFF" \
+    DEF:a=$V_RRD/ssh/ssh.rrd:A:AVERAGE \
+    COMMENT:'\r' \
+    LINE1:a#fefda0:"Users " \
+    GPRINT:a:'LAST:Current\:''%8.0lf' \
+    GPRINT:a:'MIN:Min\:''%8.0lf' \
+    GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# No Logging
+#log_event 'system' "$V_EVENT"
+
+exit $OK

+ 16 - 0
func/shared_func.sh

@@ -1079,6 +1079,22 @@ v_shell_list() {
     done < $conf
 }
 
+# Clear listing function
+v_clear_list() {
+    # Reading file line by line
+    while read line ; do
+
+        # Parsing key=value
+        for key in $line; do
+            eval ${key%%=*}=${key#*=}
+        done
+
+        # Print result line
+        eval echo "$fields"
+
+    done < $conf
+}
+
 usr_json_single_list() {
     # Definigng variables
     USER="$user"        # user