Skip to content

mour0/snmpfetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Releases

No releases published

Packages

No packages published

Languages