Code Monkey home page Code Monkey logo

snmpfetch's Introduction

snmpfetch

License os

About ๐Ÿ“„

snmpfetch is a simple command-line program that uses the SNMP protocol to retrieve system information.
It sends GET requests to a host where the SNMP daemon is running, parses the data, and prints them.

asciicast

Installation ๐Ÿงฐ

Ubuntu

  1. Install Rust
  2. apt-get install snmp snmpd snmp-mibs-downloader libssl-dev
  3. sed -i 's/mibs :/# mibs :/g' /etc/snmp/snmp.conf
  4. Add to /etc/snmp/snmpd.conf :
view systemonly included .1.3.6.1.4.1.2021
view systemonly included .1.3.6.1.2.1.25
  1. Run service snmpd restart
  2. Clone this repository
  3. cd snmpfetch/
  4. cargo build --release
  5. cd target/release/
  6. ./snmpfetch 127.0.0.1

Testing ๐Ÿฅผ

Readings

  • sysName and sysDescr can be retrieved using commands uname -n and uname -a
  • hrSystemUptime using command uptime -p
  • hrSystremProcesses by ps aux
  • cpuUsage by iostat
  • memTotal and memUsed by free
  • Loads by top. (top shows values divided by 100)

Notifications

To check if notifications are correctly sent, stress can be used, but it might be necessary to reduce thresholds. The tool can be installed using apt-get install stress

Example

Edit the following snmpfetch_config.toml fields

[contacts]
# If notifications are needed, set an URL
webhook = "<URL>"
    
[timings]
# Seconds to wait before sending webhook
webhook_pause = 120 #  2 minutes
# Seconds between snmpfetch executions
interval = 1

[thresholds]
# Percentage of used memory
used_mem = 20
# Load 1 minute value
load_1m = 300

[database]
influxdb_url = "http://localhost:8086"
influxdb_name = "test"
grafana_url = "http://localhost:3000"
  1. Run the command stress --cpu 4 --vm 2 --vm-bytes 512M &
  2. Run ./snmpfetch 127.0.0.1 -t 2.5 -L
  3. Check notifications in your webhook channel and stop snmpfetch image-notification
  4. Terminate stress image-graph

FAQs โ“

How to install Grafana and InfluxDB 1.8

  1. Download Grafana and InfluxDB 1.8
  2. Start Influxd: service influxdb start
  3. Start Grafana Server: service grafana-server start
  4. run influx and execute CREATE DATABASE test
  5. Visit 127.0.0.1:3000 and enter admin in both fields
  6. Continue the configuration then go to 127.0.0.1:3000/datasources and click on Add data source
  7. Search InfluxDB and set the following parameters:
    • Name: test
    • URL: http://localhost:8086
    • DATABASE: test
    • HTTP Method: GET
  8. Click Save & Test

How to create the snmpfetch_config.toml file?

A sample can be generated by executing the program (ex. ./snmpfetch 127.0.0.1)

snmpfetch's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.