OpenBSD check SNMPv2c


> ./check_snmp_openbsd.py -h
usage: check_snmp_openbsd.py [-h] [--version] -H HOST -C COMMUNITY -O OPTION
                             [-w WARNING] [-c CRITICAL]

optional arguments:
  -h, --help    show this help message and exit
  --version     show program's version number and exit
  -H HOST       IP addess or hostname of the target host
  -C COMMUNITY  SNMPv2 community
  -O OPTION     What sould be checked. This can be cpu, memory, swap, fs or
                number of running processes
  -w WARNING    WARNING value
  -c CRITICAL   CRITICAL value

      _____                 ____   _____ _____   
     / ___ \               |  _ \ / ____|  __ \  
    / /  / /___  ___  ____ | |_) | (___ | |  | | 
   / /  / / __ \/ _ \/ __ \|  _ < \___ \| |  | | 
  / /__/ / /_/ /  __/ / / /| |_) |____) | |__| | 
  \_____/ .___/\___/_/ /_/ |____/|_____/|_____/  
       /_/                                       
              |    .            
          .   |L  /|   .                        This script uses SNMPv2 to check memory/swap usage,
      _ . |\ _| \--+._/| .                             file system space usage and CPU load average
     / ||\| Y J  )   / |/| ./                    on (remote) OpenBSD system. It also shows detailed
    J  |)'( |        ` F`.'/                          information about all avaliable file systems,
  -<|  F         __     .-<                           and configured NICs, system information about
    | /       .-'. `.  /-. L___                                   OS and list of running processes.
    J \      <    \  | | O\|.-' 
  _J \  .-    \/ O | | \  |F      EXAMPLES:
 '-F  -<_.     \   .-'  `-' L__      
__J  _   _.     >-'  )._.   |-'   > ./check_snmp_openbsd.py -H 127.0.0.1 -C secret -O fs:/var 80 90
`-|.'   /_.           \_|   F     checks file system space usage (in %) on /var.
  /.-   .                _.<       
 /'    /.'             .'  `\     > ./check_snmp_openbsd.py -H 127.0.0.1 -C secret -O mem 80 90
  /L  /'   |/      _.-'-\         checks memory usage (in %).
 /'J       ___.---'\|          
   |\  .--' V  | `. `             > ./check_snmp_openbsd.py -H 127.0.0.1 -C secret -O file-systems
   |/`. `-.     `._)              shows list of all mounted file systems (including space usage).
      / .-.\                   
      \ (  `\                     > ./check_snmp_openbsd.py -H 127.0.0.1 -C secret -O interfaces
       `.\                        shows list of all configured network interfaces with some related
                                  information.

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O os

Uname:   OpenBSD pizza.home 5.8 GENERIC.MP#1098 i386
Uptime:  Timeticks: (62800) 0:10:28.00
CPU:     Intel(R) Atom(TM) CPU N270 @ 1.60GHz (\"GenuineIntel\" 686-class)
Contact: root@pizza.home

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O file-systems

    SIZE                USED                AVALIABLE           FILE SYSTEM
==================================================================================
 1004.8 Mb         53.4 Mb (5.32 %)       951.3 Mb (94.68 %)    /                             
   48.4 Gb          2.0 Mb (0.00 %)        48.4 Gb (100.00 %)   /home                         
    3.9 Gb         10.0 Kb (0.00 %)         3.9 Gb (100.00 %)   /tmp                          
    2.0 Gb        306.0 Mb (15.20 %)        1.7 Gb (84.80 %)    /usr                          
 1004.8 Mb        179.7 Mb (17.88 %)      825.1 Mb (82.12 %)    /usr/X11R6                    
    9.1 Gb         38.8 Mb (0.41 %)         9.1 Gb (99.59 %)    /usr/local                    
    2.0 Gb          2.0 Kb (0.00 %)         2.0 Gb (100.00 %)   /usr/obj                      
    2.0 Gb          2.0 Kb (0.00 %)         2.0 Gb (100.00 %)   /usr/src                      
    7.4 Gb         30.9 Mb (0.41 %)         7.3 Gb (99.59 %)    /var

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O fs:/ -w 80 -c 90
OK: FS usage 5.32 % [ 53.4 Mb / 1004.8 Mb ]|usage=5.32;80;90;0;0
> echo $?
0

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O fs:/usr -w 10 -c 15
CRITICAL: FS usage 15.20 % [ 306.0 Mb / 2.0 Gb ]|usage=15.20;10;15;0;0
> echo $?
2

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O fs:/usr/X11R6 -w 10 -c 20
WARNING: FS usage 17.88 % [ 179.7 Mb / 1004.8 Mb ]|usage=17.88;10;20;0;0
> echo $?
1

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O interfaces

NAME       STATE      IP                 MAC                  MTU        TYPE                 CONNECTOR  I/O ERROR
=================================================================================================================
bge0       up         192.168.2.101      0:1f:16:2b:75:cd     1500       ethernetCsmacd       true       0/0
enc0       down                                               0          other                false      0/0
lo0        up         127.0.0.1                               32768      softwareLoopback     false      0/0
pflog0     up                                                 33192      other                false      0/0

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O swap -w 10 -c 20
OK: Swap usage 0.00 % [ 0.0 b / 2.0 Gb ]|usage=0.00;10;20;0;0

> ./check_snmp_openbsd.py -H 192.168.2.101 -C public -O mem -w 5 -c 10
WARNING: Memory usage 7.50 % [ 134.3 Mb / 1.7 Gb ]|usage=7.50;5;10;0;0

> ./check_snmp_openbsd.py -C public -H 192.168.2.101 -O proc

PID        STATE        TYPE            PROC
================================================================
1          runnable     application     init 
517        runnable     application     pflogd 
2460       runnable     application     getty std.9600 ttyC2
4268       runnable     application     smtpd 
6272       runnable     application     Xorg 
6386       runnable     application     ntpd 
6997       runnable     application     ntpd 
7078       runnable     application     Xorg :0 vt05 -auth /etc/X11/xdm/authdir/authfiles/A:0-DCusev
7201       runnable     application     getty std.9600 ttyC5
8250       runnable     application     dhclient 
10976      runnable     application     xconsole 
11450      runnable     application     syslogd 
12740      runnable     application     xdm 
13613      runnable     application     smtpd 
15292      runnable     application     syslogd 
18261      runnable     application     snmpd 
18588      runnable     application     cron 
18843      runnable     application     snmpd 
19776      runnable     application     xconsole 
20281      runnable     application     getty std.9600 ttyC3
22587      running      application     snmpd 
23119      runnable     application     ntpd 
23207      runnable     application     xdm 
23612      runnable     application     ksh 
24885      runnable     application     getty std.9600 ttyC1
25499      runnable     application     sshd 
26028      runnable     application     smtpd 
26955      runnable     application     smtpd 
28214      runnable     application     sndiod 
28368      runnable     application     smtpd 
28564      runnable     application     smtpd 
29894      runnable     application     pflogd 
30302      runnable     application     dhclient 
30937      runnable     application     smtpd