| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #!/bin/bash
- # info: list system rrd charts
- # options: [format]
- #
- # List available rrd graphics, its titles and paths.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- format=${1-shell}
- # Importing variables
- source $VESTA/conf/vars.conf
- source $V_CONF/vesta.conf
- # Define json function
- json_list_rrd() {
- i=1
- echo "{"
- for type in $rrd_types; do
- for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
- if [ "$i" -ne 1 ]; then
- echo -e "\t},"
- fi
- # 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\"TITLE\": \"$title\""
- (( ++i))
- done
- done
- if [ "$i" -gt 1 ]; then
- echo -e "\t}"
- fi
- echo "}"
- }
- # Define jshell function
- shell_list_rrd() {
- if [ -z "$nohead" ]; then
- # Print brief info
- echo "PATH"
- echo "---------"
- fi
- for type in $rrd_types; do
- for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
- echo "$V_RRD/$type/$rrd.rrd"
- done
- done
- }
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Checking enabled systems
- rrd_types="la mem net"
- if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
- rrd_types="$rrd_types web"
- fi
- if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
- rrd_types="$rrd_types db"
- fi
- if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
- rrd_types="$rrd_types mail"
- fi
- if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
- rrd_types="$rrd_types ftp"
- fi
- rrd_types="$rrd_types ssh"
- # Listing domains
- case $format in
- json) json_list_rrd ;;
- plain) nohead=1; shell_list_rrd ;;
- shell) shell_list_rrd | column -t ;;
- esac
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- exit
|