Friday, March 14, 2008

SNMP & MRTG on OpenBSD

OpenBSD logo, Puffy
I have always being a total fan boy of MRTG, I can set it up in less than 15 minutes on plain vanilla Redhatish box, given that I did that lot of times because of work. Sure, there are many other solutions available, but MRTG setups in a jiffy, without any special requirements other than MRTG and Apache.
When I installed Judith, the second time, I put the box to do more stuff, since it has more stamina; the OpenBSD's builtin Apache, with MRTG was the first thing I tought.
The thing is that many of the scripts I use to gather data from the system don't work since they use either the /proc file system, or use the output from Linux commands; so I had to use SNMPD.

I don't have anything against it, but I this was the first time I use it, because at work all the servers are geographically distributed, so SNMPD its a bit unsafe to use, and all of the servers are Linux, so I have standardized the MRTG & the data gathering scripts setup.

For the configuration, specially for the SNPMD portion, I have used this site as reference:

Monitoring your Linux/Unix servers and network devices using MRTG and SNMP



So here is my mrtg.cfg from Judith:

# -------------------------------------------------------------------
# Multi Router Traffic Grapher -- judith.arenales.int
# -------------------------------------------------------------------

Htmldir: /var/www/htdocs/mrtg
Imagedir: /var/www/htdocs/mrtg/images
Logdir: /var/www/htdocs/mrtg/logs

Refresh: 600
XSize[_]: 250
Ysize[_]: 67

Colours[_]: --#7aafff,--#1000ff,--#006600,--#ff00ff

MaxBytes[_]: 125000000

LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt

## -----------------------------------------------

###############################
# Number of procs
###############################
Target[local_procs]: `/usr/local/scripts/mrtg/stat.pl procs`
Options[local_procs]: nopercent,gauge,noinfo,nobanner,noi
Title[local_procs]: Number of processes
MaxBytes[local_procs]: 1000000
YLegend[local_procs]: Processes
ShortLegend[local_procs]: procs
LegendO[local_procs]: Procs: 
Legend2[local_procs]: Number of processes
PageTop[local_procs]: Number of Processes
WithPeak[local_procs]:wmy
Legend4[local_procs]: Max number of processes

## -----------------------------------------------

###############################
# Number of TCP connections
###############################
Target[local_tcpopen]: `/usr/local/scripts/mrtg/stat.pl tcpopen`
Options[local_tcpopen]: nopercent,gauge,noinfo,nobanner,noi
Title[local_tcpopen]: Open TCP connections
MaxBytes[local_tcpopen]: 1000000
YLegend[local_tcpopen]: TCP Open
ShortLegend[local_tcpopen]:  
LegendO[local_tcpopen]: Open TCP connections: 
Legend2[local_tcpopen]: Connections
PageTop[local_tcpopen]: TCP Open connections
WithPeak[local_tcpopen]:wmy
Legend4[local_tcpopen]: Max number of open TCP connections

## -----------------------------------------------

###############################
# Uptime
###############################
Target[local_uptime]: `/usr/local/scripts/mrtg/stat.pl uptime`
Options[local_uptime]: nopercent,gauge,noinfo,nobanner,noi
Title[local_uptime]: Uptime
MaxBytes[local_uptime]: 1000000
YLegend[local_uptime]: Days
ShortLegend[local_uptime]: Uptime
LegendO[local_uptime]: Uptime: 
Legend2[local_uptime]: days
PageTop[local_uptime]: Uptime
WithPeak[local_uptime]:wmy
Legend4[local_uptime]: Max uptime

## -----------------------------------------------

###############################
# Users on the server
###############################
Target[local_users]: `/usr/local/scripts/mrtg/stat.pl users`
Options[local_users]: nopercent,gauge,noinfo,nobanner,noi
Title[local_users]: Number of users
MaxBytes[local_users]: 1000
YLegend[local_users]: Users
ShortLegend[local_users]:  
LegendO[local_users]: Users: 
Legend2[local_users]: Users
PageTop[local_users]: Users logged in
WithPeak[local_users]:wmy
Legend4[local_users]: Max number of users logged in

## -----------------------------------------------

################################
# HDD space
################################
Target[df-root]: `/usr/local/scripts/mrtg/mrtg-df.sh /`
Options[df-root]: nopercent,nobanner,nolegend,noinfo,integer,gauge
Title[df-root]: Disk usage for /
PageTop[df-root]: Disk usage
YLegend[df-root]: 1k blocks
ShortLegend[df-root]:  1k blocks
LegendI[df-root]: avail 
LegendO[df-root]: used 

Target[df-var]: `/usr/local/scripts/mrtg/mrtg-df.sh /var`
Options[df-var]: nopercent,nobanner,nolegend,noinfo,integer,gauge
Title[df-var]: Disk usage for /var
PageTop[df-var]: Disk usage /var
YLegend[df-var]: 1k blocks
ShortLegend[df-var]:  1k blocks
LegendI[df-var]: avail 
LegendO[df-var]: used 

Target[df-tmp]: `/usr/local/scripts/mrtg/mrtg-df.sh /tmp`
Options[df-tmp]: nopercent,nobanner,nolegend,noinfo,integer,gauge
Title[df-tmp]: Disk usage for /tmp
PageTop[df-tmp]: Disk usage /tmp
YLegend[df-tmp]: 1k blocks
ShortLegend[df-tmp]:  1k blocks
LegendI[df-tmp]: avail 
LegendO[df-tmp]: used 

Target[df-usr]: `/usr/local/scripts/mrtg/mrtg-df.sh /usr`
Options[df-usr]: nopercent,nobanner,nolegend,noinfo,integer,gauge
Title[df-usr]: Disk usage for /usr
PageTop[df-usr]: Disk usage /usr
YLegend[df-usr]: 1k blocks
ShortLegend[df-usr]:  1k blocks
LegendI[df-usr]: avail 
LegendO[df-usr]: used 

Target[df-home]: `/usr/local/scripts/mrtg/mrtg-df.sh /home`
Options[df-home]: nopercent,nobanner,nolegend,noinfo,integer,gauge
Title[df-home]: Disk usage for /home
PageTop[df-home]: Disk usage /home
YLegend[df-home]: 1k blocks
ShortLegend[df-home]:  1k blocks
LegendI[df-home]: avail 
LegendO[df-home]: used 

## -----------------------------------------------

#
# CPU Monitoring
# (Scaled so that the sum of all three values doesn't exceed 100)
#

Target[local_load]:ssCpuRawUser.0&ssCpuRawUser.0:mySecretCommunity@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:mySecretCommunity@localhost + ssCpuRawNice.0&ssCpuRawNice.0:mySecretCommunity@localhost
Title[local_load]: Server CPU Load
PageTop[local_load]: CPU Load - System, User and Nice Processes
MaxBytes[local_load]: 100
ShortLegend[local_load]: %
YLegend[local_load]: CPU Utilization
Legend1[local_load]: Current CPU percentage load
LegendI[local_load]: Used
LegendO[local_load]:
Options[local_load]: nopercent
Unscaled[local_load]: ymwd

#
# Memory Monitoring (Total Versus Available Memory)
#

Target[local_memory]: memAvailReal.0&memTotalReal.0:mySecretCommunity@localhost
Title[local_memory]: Free Memory
PageTop[local_memory]: Free Memory
MaxBytes[local_memory]: 100000000000
ShortLegend[local_memory]: B
YLegend[local_memory]: Bytes
LegendI[local_memory]: Free
LegendO[local_memory]: Total
Legend1[local_memory]: Free memory, not including swap, in bytes
Legend2[local_memory]: Total memory
Options[local_memory]: gauge,nopercent
kMG[local_memory]: k,M,G,T,P,X

#
# Memory Monitoring (Percentage usage)
#
Title[local_mempercent]: Percentage Free Memory
PageTop[local_mempercent]: Percentage Free Memory
Target[local_mempercent]: ( memAvailReal.0&memAvailReal.0:mySecretCommunity@localhost ) * 100 / ( memTotalReal.0&memTotalReal.0:mySecretCommunity@localhost )
options[local_mempercent]: gauge,transparent,nopercent
Unscaled[local_mempercent]: ymwd
MaxBytes[local_mempercent]: 100
YLegend[local_mempercent]: Memory %
ShortLegend[local_mempercent]: Percent
LegendI[local_mempercent]: Free
LegendO[local_mempercent]: Free
Legend1[local_mempercent]: Percentage Free Memory
Legend2[local_mempercent]: Percentage Free Memory

## -----------------------------------------------

###############################
## dc0 ethernet NIC
###############################
Target[local_dc0]: 3:mySecretCommunity@localhost:
#Options[local_dc0]: nopercent,gauge,noinfo,nobanner
Options[local_dc0]: nopercent,noinfo,nobanner
SetEnv[local_dc0]: MRTG_INT_IP="192.168.0.101" MRTG_INT_DESCR="dc0"
MaxBytes[local_dc0]: 12500000
Title[local_dc0]: Traffic analysis for ethernet card dc0
PageTop[local_dc0]: Ethernet card dc0
WithPeak[local_dc0]:wmy

Labels: , , ,

0 Comments:

Post a Comment

<< Home