Просмотр исходного кода

changed function order per convention

Serghey Rodin 14 лет назад
Родитель
Сommit
86eba5df8b
3 измененных файлов с 43 добавлено и 17 удалено
  1. 29 2
      bin/v_list_sys_rrd
  2. 14 14
      bin/v_list_web_templates
  3. 0 1
      bin/v_update_sys_rrd_ssh

+ 29 - 2
bin/v_list_sys_rrd

@@ -20,9 +20,36 @@ json_list_rrd() {
             if [ "$i" -ne 1 ]; then
                 echo -e "\t},"
             fi
-            echo -e "\\t\"$i\": {"
+
+            # Define title
+            if [ "$type" = 'la' ]; then
+                title="Load Average"
+            fi
+
+            if [ "$type" = 'mem' ]; then
+                title="Memory Usage"
+            fi
+
+            if [ "$type" = 'net' ]; then
+                title="Bandwidth Usage $rrd"
+            fi
+
+            if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\
+               [ "$type" = 'ssh' ]; then
+                title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage"
+            fi
+
+            if [ "$type" = 'db' ]; then
+                db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \
+                    -e 's/pgsql/PostgreSQL/g' )
+                db_host=$(echo $rrd|cut -f 2 -d _ )
+                title="$db_type Usage on $db_host"
+            fi
+
+            echo -e "\t\"$i\": {"
             echo -e "\t\t\"TYPE\": \"$type\"",
-            echo -e "\t\t\"RRD\": \"$rrd\""
+            echo -e "\t\t\"RRD\": \"$rrd\"",
+            echo -e "\t\t\"TITLE\": \"$title\""
             (( ++i))
         done
     done

+ 14 - 14
bin/v_list_web_templates

@@ -13,20 +13,6 @@ format=${2-shell}
 source $VESTA/conf/vars.conf
 source $V_FUNC/shared.func
 
-
-#----------------------------------------------------------#
-#                    Verifications                         #
-#----------------------------------------------------------#
-
-# Checking arg number
-check_args '1' "$#" 'user'
-
-# Checking argument format
-format_validation 'user'
-
-# Checking user
-is_user_valid
-
 # Json function
 json_list_wtpl() {
     i='1'       # iterator
@@ -68,6 +54,20 @@ shell_list_wtpl() {
 }
 
 
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '1' "$#" 'user'
+
+# Checking argument format
+format_validation 'user'
+
+# Checking user
+is_user_valid
+
+
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#

+ 0 - 1
bin/v_update_sys_rrd_ssh

@@ -1,4 +1,3 @@
-
 #!/bin/bash
 # info: updating ssh rrd