diff --git a/Dockerfile b/Dockerfile index e58fc33..f461eea 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:18.04 -MAINTAINER Arthur Kono + +LABEL maintainer="artlov@gmail.com" ENV DEBIAN_FRONTEND noninteractive ENV LANG C.UTF-8 @@ -10,16 +11,8 @@ ENV INFLUXDB_VERSION 1.7.2 ENV GRAFANA_VERSION 5.3.2 ENV CHRONOGRAF_VERSION 1.7.5 -# Database Defaults -ENV INFLUXDB_GRAFANA_DB datasource -ENV INFLUXDB_GRAFANA_USER datasource -ENV INFLUXDB_GRAFANA_PW datasource - ENV GF_DATABASE_TYPE=sqlite3 -#ENV MYSQL_GRAFANA_USER grafana -#ENV MYSQL_GRAFANA_PW grafana - # Fix bad proxy issue COPY system/99fixbadproxy /etc/apt/apt.conf.d/99fixbadproxy @@ -28,8 +21,6 @@ RUN rm /var/lib/apt/lists/* -vf # Base dependencies -# apt-get -y --force-yes install \ - RUN apt-get -y update && \ apt-get -y dist-upgrade && \ apt-get -y install \ @@ -68,14 +59,9 @@ RUN mkdir -p /var/log/supervisor && \ COPY ssh/id_rsa .ssh/id_rsa COPY bash/profile .profile -# Configure MySql -#COPY scripts/setup_mysql.sh /tmp/setup_mysql.sh - -#RUN /tmp/setup_mysql.sh - # Install InfluxDB RUN wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb && \ - dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb && rm influxdb_${INFLUXDB_VERSION}_amd64.deb + dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb && rm influxdb_${INFLUXDB_VERSION}_amd64.deb # Configure InfluxDB COPY influxdb/influxdb.conf /etc/influxdb/influxdb.conf @@ -83,7 +69,7 @@ COPY influxdb/init.sh /etc/init.d/influxdb # Install Telegraf RUN wget https://dl.influxdata.com/telegraf/releases/telegraf_${TELEGRAF_VERSION}_amd64.deb && \ - dpkg -i telegraf_${TELEGRAF_VERSION}_amd64.deb && rm telegraf_${TELEGRAF_VERSION}_amd64.deb + dpkg -i telegraf_${TELEGRAF_VERSION}_amd64.deb && rm telegraf_${TELEGRAF_VERSION}_amd64.deb # Configure Telegraf COPY telegraf/telegraf.conf /etc/telegraf/telegraf.conf @@ -91,19 +77,29 @@ COPY telegraf/init.sh /etc/init.d/telegraf # Install chronograf RUN wget https://dl.influxdata.com/chronograf/releases/chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \ - dpkg -i chronograf_${CHRONOGRAF_VERSION}_amd64.deb + dpkg -i chronograf_${CHRONOGRAF_VERSION}_amd64.deb && rm chronograf_${CHRONOGRAF_VERSION}_amd64.deb # Install Grafana RUN wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_${GRAFANA_VERSION}_amd64.deb && \ - dpkg -i grafana_${GRAFANA_VERSION}_amd64.deb && rm grafana_${GRAFANA_VERSION}_amd64.deb + dpkg -i grafana_${GRAFANA_VERSION}_amd64.deb && rm grafana_${GRAFANA_VERSION}_amd64.deb # Configure Grafana with provisioning ADD grafana/provisioning /etc/grafana/provisioning ADD grafana/dashboards /var/lib/grafana/dashboards COPY grafana/grafana.ini /etc/grafana/grafana.ini -VOLUME /var/lib/influxdb -VOLUME /var/lib/grafana +# Update mibs +#RUN /usr/bin/download-mibs + +# Synology SNMP +COPY synology/synology.conf /etc/telegraf/telegraf.d +COPY synology/Synology_MIB_File.tar.gz /tmp +RUN tar -xvzf /tmp/Synology_MIB_File.tar.gz -C /usr/share/snmp/mibs +RUN chown root:root /usr/share/snmp/mibs +RUN chmod 755 /usr/share/snmp/mibs + +EXPOSE 22/tcp 3003/tcp 3004/tcp 8086/tcp 8125/udp +VOLUME /var/lib/influxdb /var/lib/grafana /var/lib/backups # Cleanup RUN apt-get clean && \ diff --git a/README.md b/README.md index fea5fe6..0989739 100755 --- a/README.md +++ b/README.md @@ -5,11 +5,10 @@ The main point of difference with this image is: * Persistence is supported via mounting volumes to a Docker container * Grafana will store its data in SQLite files instead of a MySQL table on the container, so MySQL is not installed -* Added SNMP +* Added snmp packages and Synology NAS MIBS ## Versions -* Docker Image: 2.2.0 * Ubuntu: 18.04 * InfluxDB: 1.7.2 * Telegraf (StatsD): 1.9.2-1 diff --git a/docker-compose.yml b/docker-compose.yml index 2de99d4..e0af7e2 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,21 @@ version: '3' services: - webapp: - build: artlov/docker-statsd-influxdb-grafana . + app: +# build: artlov/docker-telegraf-influxdb-grafana . + image: "artlov/docker-telegraf-influxdb-grafana" + ports: + - "3003:3003" + - "3004:8888" + - "8086:8086" + - "22022:22" + - "8125:8125/udp" + volumes: + - /volume1/docker/influxdb:/var/lib/influxdb + - /volume1/docker/grafana:/var/lib/grafana + - /volume1/docker/backups:/var/backups + + #test: # override: @@ -10,3 +23,8 @@ services: # - curl --retry 10 --retry-delay 5 -v http://localhost:3003 # - curl --retry 10 --retry-delay 5 -v http://localhost:3004 # - curl --retry 10 --retry-delay 5 -v http://localhost:8086 + + +# docker-compose up +# docker-compose stop +# docker-compose down diff --git a/supervisord/supervisord.conf b/supervisord/supervisord.conf index 06a575a..e21a970 100755 --- a/supervisord/supervisord.conf +++ b/supervisord/supervisord.conf @@ -6,17 +6,17 @@ priority = 1 command = /usr/sbin/sshd -D [program:influxdb] -priority = 3 +priority = 2 command = bash -c "/etc/init.d/influxdb start && sleep 5" [program:telegraf] -priority = 4 +priority = 3 command = bash -c "sleep 30 && /etc/init.d/telegraf start" [program:grafana] -priority = 5 +priority = 4 command = /etc/init.d/grafana-server start [program:chronograf] -priority = 6 +priority = 5 command = /usr/bin/chronograf -r diff --git a/synology/Synology_MIB_File.tar.gz b/synology/Synology_MIB_File.tar.gz new file mode 100644 index 0000000..28143af Binary files /dev/null and b/synology/Synology_MIB_File.tar.gz differ diff --git a/synology/synology.conf b/synology/synology.conf new file mode 100644 index 0000000..c1e8b73 --- /dev/null +++ b/synology/synology.conf @@ -0,0 +1,213 @@ +## +## Synology +## + [[inputs.snmp]] + # List of agents to poll +# agents = [ "192.168.1.134:161" ] # required - enter the IP address of your Synology device + agents = [ "172.17.0.1" ] # required - enter the IP address of your Synology device + + # Polling interval + interval = "60s" + + # Timeout for each SNMP query. + timeout = "10s" + + # Number of retries to attempt within timeout. + retries = 3 + + # SNMP version, UAP only supports v1 + version = 2 + + # SNMP community string. + community = "public" + + # The GETBULK max-repetitions parameter + max_repetitions = 30 + + # Measurement name + name = "snmp.SYNO" + + # System name (hostname) + [[inputs.snmp.field]] + is_tag = true + name = "sysName" + oid = "RFC1213-MIB::sysName.0" + # System vendor OID + [[inputs.snmp.field]] + name = "sysObjectID" + oid = "RFC1213-MIB::sysObjectID.0" + # System description + [[inputs.snmp.field]] + name = "sysDescr" + oid = "RFC1213-MIB::sysDescr.0" + # System contact + [[inputs.snmp.field]] + name = "sysContact" + oid = "RFC1213-MIB::sysContact.0" + # System location + [[inputs.snmp.field]] + name = "sysLocation" + oid = "RFC1213-MIB::sysLocation.0" + # System uptime + [[inputs.snmp.field]] + name = "sysUpTime" + oid = "RFC1213-MIB::sysUpTime.0" + # Inet interface + [[inputs.snmp.table]] + oid = "IF-MIB::ifTable" + [[inputs.snmp.table.field]] + is_tag = true + oid = "IF-MIB::ifDescr" + #Syno disk + [[inputs.snmp.table]] + oid = "SYNOLOGY-DISK-MIB::diskTable" + [[inputs.snmp.table.field]] + is_tag = true + oid = "SYNOLOGY-DISK-MIB::diskID" + #Syno raid + [[inputs.snmp.table]] + oid = "SYNOLOGY-RAID-MIB::raidTable" + [[inputs.snmp.table.field]] + is_tag = true + oid = "SYNOLOGY-RAID-MIB::raidName" + #Syno load + [[inputs.snmp.table]] + oid = "UCD-SNMP-MIB::laTable" + [[inputs.snmp.table.field]] + is_tag = true + oid = "UCD-SNMP-MIB::laNames" + # System memTotalSwap + [[inputs.snmp.field]] + name = "memTotalSwap" + oid = "UCD-SNMP-MIB::memTotalSwap.0" + # System memAvailSwap + [[inputs.snmp.field]] + name = "memAvailSwap" + oid = "UCD-SNMP-MIB::memAvailSwap.0" + # System memTotalReal + [[inputs.snmp.field]] + name = "memTotalReal" + oid = "UCD-SNMP-MIB::memTotalReal.0" + # System memAvailReal + [[inputs.snmp.field]] + name = "memAvailReal" + oid = "UCD-SNMP-MIB::memAvailReal.0" + # System memTotalFree + [[inputs.snmp.field]] + name = "memTotalFree" + oid = "UCD-SNMP-MIB::memTotalFree.0" + # System Status + [[inputs.snmp.field]] + name = "systemStatus" + oid = "SYNOLOGY-SYSTEM-MIB::systemStatus.0" + # System temperature + [[inputs.snmp.field]] + name = "temperature" + oid = "SYNOLOGY-SYSTEM-MIB::temperature.0" + # System powerStatus + [[inputs.snmp.field]] + name = "powerStatus" + oid = "SYNOLOGY-SYSTEM-MIB::powerStatus.0" + # System systemFanStatus + [[inputs.snmp.field]] + name = "systemFanStatus" + oid = "SYNOLOGY-SYSTEM-MIB::systemFanStatus.0" + # System cpuFanStatus + [[inputs.snmp.field]] + name = "cpuFanStatus" + oid = "SYNOLOGY-SYSTEM-MIB::cpuFanStatus.0" + # System modelName + [[inputs.snmp.field]] + name = "modelName" + oid = "SYNOLOGY-SYSTEM-MIB::modelName.0" + # System serialNumber + [[inputs.snmp.field]] + name = "serialNumber" + oid = "SYNOLOGY-SYSTEM-MIB::serialNumber.0" + # System version + [[inputs.snmp.field]] + name = "version" + oid = "SYNOLOGY-SYSTEM-MIB::version.0" + # System upgradeAvailable + [[inputs.snmp.field]] + name = "upgradeAvailable" + oid = "SYNOLOGY-SYSTEM-MIB::upgradeAvailable.0" + # System volume + [[inputs.snmp.table]] + oid = "HOST-RESOURCES-MIB::hrStorageTable" + [[inputs.snmp.table.field]] + is_tag = true + oid = "HOST-RESOURCES-MIB::hrStorageDescr" + # System ssCpuUser + [[inputs.snmp.field]] + name = "ssCpuUser" + oid = ".1.3.6.1.4.1.2021.11.9.0" + # System ssCpuSystem + [[inputs.snmp.field]] + name = "ssCpuSystem" + oid = ".1.3.6.1.4.1.2021.11.10.0" + # System ssCpuIdle + [[inputs.snmp.field]] + name = "ssCpuIdle" + oid = ".1.3.6.1.4.1.2021.11.11.0" + # Service users CIFS + [[inputs.snmp.table.field]] + name = "usersCIFS" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "1" + # Service users AFP + [[inputs.snmp.table.field]] + name = "usersAFP" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "2" + # Service users NFS + [[inputs.snmp.table.field]] + name = "usersNFS" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "3" + # Service users FTP + [[inputs.snmp.table.field]] + name = "usersFTP" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "4" + # Service users SFTP + [[inputs.snmp.table.field]] + name = "usersSFTP" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "5" + # Service users HTTP + [[inputs.snmp.table.field]] + name = "usersHTTP" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "6" + # Service users TELNET + [[inputs.snmp.table.field]] + name = "usersTELNET" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "7" + # Service users SSH + [[inputs.snmp.table.field]] + name = "usersSSH" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "8" + # Service users OTHER + [[inputs.snmp.table.field]] + name = "usersOTHER" + oid = "SYNOLOGY-SERVICES-MIB::serviceUsers" + oid_index_suffix = "9" + # UPS Status + [[inputs.snmp.table.field]] + name = "upsStatus" + oid = "SYNOLOGY-UPS-MIB::upsInfoStatus" + # UPS Load + [[inputs.snmp.table.field]] + name = "upsLoad" + oid = "SYNOLOGY-UPS-MIB::upsInfoLoadValue" + # UPS Battery Charge + [[inputs.snmp.table.field]] + name = "upsCharge" + oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeValue" + # UPS Battery Charge Warning + [[inputs.snmp.table.field]] + name = "upsWarning" + oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeWarning"