-
#!/bin/bash # Installing Kafka Exporter # tput commands CLEAR="tput clear" DOWN="tput cud1" BOLD="tput bold" NORMAL="tput sgr0" BLACK="tput setaf 0" RED="tput setaf 1" GREEN="tput setaf 2" YELLOW="tput setaf 3" BLUE="tput setaf 4" $CLEAR $NORMAL $DOWN # Installation confirmation printf "You have selected to install kafka_exporter.\n\n" read -p "Do you want to continue? [ yes / no ] : " USER_INPUT USER_INPUT=${USER_INPUT:-yes} $DOWN # Convert user's choice to lowercase for case-sensitive comparison USER_INPUT_LOWER=$(echo "$USER_INPUT" | tr '[:upper:]' '[:lower:]') # Check the user's input if [ "$USER_INPUT_LOWER" == "yes" ]; then $YELLOW printf "Kafka exporter installation confirmed.\n\n" $NORMAL else printf "Kafka exporter installation cancelled.\n\n" exit fi # Specify the name of the systemd service SERVICE_NAME="kafka_exporter" # Check if the service file exists if [ -e "/usr/lib/systemd/system/$SERVICE_NAME.service" ]; then # Check if the service is active if sudo systemctl is-active --quiet "$SERVICE_NAME"; then $BOLD printf "There is an active $SERVICE_NAME. \n\n" $NORMAL # Check the version of the active kafka_exporter KAFKA_EXPORTER_PATH="/usr/local/$SERVICE_NAME/$SERVICE_NAME" VERSION_INFO="$($KAFKA_EXPORTER_PATH --version 2>&1 | awk '/kafka_exporter/ {print $3}')" $GREEN printf "Active Kafka Exporter Version: $VERSION_INFO \n\n" $NORMAL printf "Do you want to remove it and replace with a new one? [ 1 / 2 ]\n\n" printf " 1: Remove the active kafka_exporter and replace it with a new one. \n\n" printf " 2: Don't do anything and exit.\n\n" read -rp "> " ACTION # Check the action to do if [ -z "$ACTION" ]; then printf "Removing all kafka_exporter files... \n\n" # Remove kafka_exporter related files sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service $DOWN sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" elif [ "$ACTION" -eq 1 ]; then printf "Removing all kafka_exporter files... \n\n" # Remove kafka_exporter related files sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service $DOWN sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" elif [ "$ACTION" -eq 2 ]; then $DOWN printf "No action done.\n\n" exit else printf "Invalid input. Please enter 1 or 2.\n\n" exit 1 fi else printf "There's a $SERVICE_NAME service that is not active. Removing related files...\n\n" sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" fi else printf "No $SERVICE_NAME service file found.\n\n" fi # Curling Google to check if connected to a network printf "Looking for a network...\n\n" if curl google.com > /dev/null; then $DOWN $YELLOW printf "Network connected.\n\n" $NORMAL else $DOWN printf "The server is not connected to the network. Please connect and try again.\n\n"; exit 1 fi echo -n "Insert the version you would like to be installed, default is [ 1.7.0 ] : " $BOLD $BLUE read VERSION $NORMAL VERSION=${VERSION:-1.7.0} $DOWN $NORMAL # Download the file wget https://github.com/danielqsj/kafka_exporter/releases/download/v$VERSION/kafka_exporter-$VERSION.linux-amd64.tar.gz -P /opt # Extract the downloaded tarball in user directory with a new name tar -xzvf /opt/kafka_exporter-$VERSION.linux-amd64.tar.gz -C /usr/local && mv /usr/local/kafka_exporter-$VERSION.linux-amd64 /usr/local/kafka_exporter # IP IP=$(hostname -I | awk '{print $1}') # Create a systemd service file for Kafka Exporter cat >/usr/lib/systemd/system/kafka_exporter.service<
-
InfluxDB
Purpose built for real-time analytics at any scale. InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
-
#!/bin/bash # Installing Kafka Exporter # tput commands CLEAR="tput clear" DOWN="tput cud1" BOLD="tput bold" NORMAL="tput sgr0" BLACK="tput setaf 0" RED="tput setaf 1" GREEN="tput setaf 2" YELLOW="tput setaf 3" BLUE="tput setaf 4" $CLEAR $NORMAL $DOWN # Installation confirmation printf "You have selected to install kafka_exporter.\n\n" read -p "Do you want to continue? [ yes / no ] : " USER_INPUT USER_INPUT=${USER_INPUT:-yes} $DOWN # Convert user's choice to lowercase for case-sensitive comparison USER_INPUT_LOWER=$(echo "$USER_INPUT" | tr '[:upper:]' '[:lower:]') # Check the user's input if [ "$USER_INPUT_LOWER" == "yes" ]; then $YELLOW printf "Kafka exporter installation confirmed.\n\n" $NORMAL else printf "Kafka exporter installation cancelled.\n\n" exit fi # Specify the name of the systemd service SERVICE_NAME="kafka_exporter" # Check if the service file exists if [ -e "/usr/lib/systemd/system/$SERVICE_NAME.service" ]; then # Check if the service is active if sudo systemctl is-active --quiet "$SERVICE_NAME"; then $BOLD printf "There is an active $SERVICE_NAME. \n\n" $NORMAL # Check the version of the active kafka_exporter KAFKA_EXPORTER_PATH="/usr/local/$SERVICE_NAME/$SERVICE_NAME" VERSION_INFO="$($KAFKA_EXPORTER_PATH --version 2>&1 | awk '/kafka_exporter/ {print $3}')" $GREEN printf "Active Kafka Exporter Version: $VERSION_INFO \n\n" $NORMAL printf "Do you want to remove it and replace with a new one? [ 1 / 2 ]\n\n" printf " 1: Remove the active kafka_exporter and replace it with a new one. \n\n" printf " 2: Don't do anything and exit.\n\n" read -rp "> " ACTION # Check the action to do if [ -z "$ACTION" ]; then printf "Removing all kafka_exporter files... \n\n" # Remove kafka_exporter related files sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service $DOWN sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" elif [ "$ACTION" -eq 1 ]; then printf "Removing all kafka_exporter files... \n\n" # Remove kafka_exporter related files sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service $DOWN sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" elif [ "$ACTION" -eq 2 ]; then $DOWN printf "No action done.\n\n" exit else printf "Invalid input. Please enter 1 or 2.\n\n" exit 1 fi else printf "There's a $SERVICE_NAME service that is not active. Removing related files...\n\n" sudo systemctl stop $SERVICE_NAME sudo systemctl disable $SERVICE_NAME sudo rm /usr/lib/systemd/system/$SERVICE_NAME.service sudo rm -rf /usr/local/kafka_exporter* $YELLOW printf "Related files removed.\n\n" $NORMAL printf "Installation will continue...\n\n" fi else printf "No $SERVICE_NAME service file found.\n\n" fi # Curling Google to check if connected to a network printf "Looking for a network...\n\n" if curl google.com > /dev/null; then $DOWN $YELLOW printf "Network connected.\n\n" $NORMAL else $DOWN printf "The server is not connected to the network. Please connect and try again.\n\n"; exit 1 fi echo -n "Insert the version you would like to be installed, default is [ 1.7.0 ] : " $BOLD $BLUE read VERSION $NORMAL VERSION=${VERSION:-1.7.0} $DOWN $NORMAL # Download the file wget https://github.com/danielqsj/kafka_exporter/releases/download/v$VERSION/kafka_exporter-$VERSION.linux-amd64.tar.gz -P /opt # Extract the downloaded tarball in user directory with a new name tar -xzvf /opt/kafka_exporter-$VERSION.linux-amd64.tar.gz -C /usr/local && mv /usr/local/kafka_exporter-$VERSION.linux-amd64 /usr/local/kafka_exporter # IP IP=$(hostname -I | awk '{print $1}') # Create a systemd service file for Kafka Exporter cat >/usr/lib/systemd/system/kafka_exporter.service<