OSSP CVS Repository

ossp - Check-in [3527]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3527
Date: 2003-Sep-01 17:22:41 (local)
2003-Sep-01 15:22:41 (UTC)
User:rse
Branch:
Comment: genesis of OSSP snmpd-probe
Tickets:
Inspections:
Files:
ossp-pkg/snmpd-probe/00BRAINSTORM      added-> 1.1
ossp-pkg/snmpd-probe/00README      added-> 1.1
ossp-pkg/snmpd-probe/00TODO      added-> 1.1
ossp-pkg/snmpd-probe/Makefile      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/hwCpu.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/hwProd.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/swOp.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/swOs.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/sysLoad.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/sysProc.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/sysUptime.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.d/sysUser.pm      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.mib/.index      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.mib/snmpd-probe.mib      added-> 1.1
ossp-pkg/snmpd-probe/snmpd-probe.sh      added-> 1.1
ossp-pkg/snmpdx/00BRAINSTORM      added-> 1.1
ossp-pkg/snmpdx/00README      added-> 1.1
ossp-pkg/snmpdx/00TODO      added-> 1.1
ossp-pkg/snmpdx/Makefile      added-> 1.1
ossp-pkg/snmpdx/snmpdx      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/hwProd.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/swOp.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/swOs.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/sysLoad.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/sysProc.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/sysUptime.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.d/sysUser.pm      added-> 1.1
ossp-pkg/snmpdx/snmpdx.mib/.index      added-> 1.1
ossp-pkg/snmpdx/snmpdx.mib/snmpdx.mib      added-> 1.1
ossp-pkg/snmpdx/snmpdx.sh      added-> 1.1

















ossp-pkg/snmpdx/00BRAINSTORM -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,145 ----
+ 
+ Sitzt Michael schon an der SNMP-Geschichte? Wir haben bereits am Mittwoch
+ ein Folgemeeting, er waere gut, bis dahin erste Resultate zu haben. Ziel
+ ist es, von einer (zu schaffenden) Montoring Platform bestehend aus zwei
+ Sun Netra t1 ueber das Backup-LAN Hardware-Monitoring mittels SNMP zu
+ fahren. Die Netras werden auch von uns bereitgestellt, ich will diese dem
+ Zet.Net-Setup entnehmen. Dazu fehlt mir jedoch die Freigabe von Assuntina
+ Greco (Bill & Collect), welche jedoch erst zum 1.9. wieder da sein wird.
+ 
+ Deshalb sollten wir uns erst mal auf die Client-Seite konzentriert werden.
+ Hierzu muss eine MIB entwickelt werden, mit der sich Parameter wir
+ Netzteil-Status (jeweils 1 oder mehrere), Plattenstatus (jeweils 1 oder
+ mehrere), Temperatur (jeweils 1 oder mehrere) etc. abfragen lassen. Wir
+ sollten erst einmal eine Referenzloesung und Sun Solaris schaffen.
+ Notwendige Punkte sind daher wohl
+ 
+ o Config fuer den SNMP-Daemon aus OpenPKG, welcher diesen nur am
+   Backup-Interface listenen laesst.
+ o Entwicklung von MIB und Skripten, mit der sich die relevanten
+   Information extrahieren lassen (wahrscheinlich output von prtdiag
+   parsen. Wie wir wissen, kann der output von prtdiag je nach Platform
+   stark abweichen)
+ o Erweiterbarkeit der Loesung um andere Platformen, etwa Linux oder
+   Windows (natuerlich nicht mit OpenPKG :-) muss gegeben sein.
+ o Waere es evtl. sinnvoll, die Skripte nicht direct durch den SNMP Daemon
+   triggern zu lassen, insofern Daten lokal gecached bereits vorliegen?
+   Der Cache koennte etwa eine RRD sein, welche durch cronjobs gespeist
+   wird. So koennte man die Informationen noch evtl. anderweitig lokal
+   nutzen (evtl. Reanimierung von poor man's monitoring probes sinnvoll?)
+ 
+ Es sollen keine Traps ausgeloest werden, die Monitoring-Platform, auf der
+ dann ein BMC Agent laufen soll, pollt regelmaessig.
+ 
+ 
+ * 1.3         - ISO Identified Organization
+ * 1.3.6       - US Department of Defense
+ * 1.3.6.1     - OID assignments from 1.3.6.1 - Internet
+ * 1.3.6.1.4   - Internet Private
+ * 1.3.6.1.4.1 - IANA-registered Private Enterprises
+ * 1.3.6.1.4.1.2021 - RedHat Linux
+ * 1.3.6.1.4.1.4007 - Cable & Wireless Plc
+ 
+ Cable & Wireless Communications plc Brian Norris <brian.norris@cwcom.co.uk>
+                                     Brian Morris <brian.morris@uk.ibm.com>
+ 
+ http://www.iana.org/assignments/enterprise-numbers
+ http://www.iana.org/cgi-bin/enterprise.pl
+ http://www.alvestrand.no/objectid/top.html
+ 
+ {iso(1) org(3) dod(6) iana(1)}
+ 
+ 
+ pass .1.3.6.1.4.1.2021.255 /path/to/probe
+ $ /path/to/probe -g .1.3.6.1.4.1.2021.255
+ .1.3.6.1.4.1.2021.255
+ integer
+ 42
+ 
+ pass_persist .1.3.6.1.4.1.2021.255 /path/to/probe
+ > PING
+ < PONG
+ > GET
+ > .1.3.6.1.4.1.2021.255
+ < .1.3.6.1.4.1.2021.255
+ < integer
+ < 42
+ > GET
+ > .1.2.3
+ < NONE
+ 
+ /cw/bin/snmpget  -cpublic -v2c -mALL 127.0.0.1 .1.3.6.1.4.1.4007.42.1
+ /cw/bin/snmpwalk -cpublic -v2c -mALL 127.0.0.1 .1.3.6.1.4.1.4007.42.1
+ /cw/bin/snmpwalk -M /u/rse/prj/snmp/snmpdx.d -cpublic -v2c -mALL 127.0.0.1 .1.3.6.1.4.1.4007.42
+ 
+ -----------------------------------------------------------------------
+ 
+ o hardware
+   o CPU
+     - number of
+     - speed (mhz)
+     - temperature
+   o RAM
+     - available
+     - used
+     - bank status (ok)
+   o Disk
+     o Logical
+       - number of (parts)
+       - available (space)
+       - used
+       - status
+     o Physical
+       - number of (parts)
+       - available (space)
+       - used
+       - status
+       - temperature
+   o Power
+     - number of (parts)
+     - temperature
+     - operating/shutdown
+   o Chassis
+     - open/closed
+     - temperature
+ 
+ o software
+   o Operating System
+     - uptime
+     - load average (5/10/15)
+     - processes
+     - logged in users 
+     - virtual memory
+       - swap space (available/used)
+       - RAM space (available/used)
+   o Packages (installed)
+     - Vendor
+       - name, version
+       - status (verified ok)
+     - OpenPKG (multiple instances!)
+       - name, version
+       - status (verified ok)
+   o Processes (running)
+     - running
+ 
+ ------------------------
+ 
+ FreeBSD:
+ /proc
+ sysctl
+ df
+ netstat 
+ ps
+ 
+ Linux:
+ /proc
+ sysctl
+ df
+ netstat
+ ps
+ /proc/meminfo
+ 
+ Solaris:
+ prtdiag 
+ /usr/sbin/sysdef
+ 


ossp-pkg/snmpdx/00README -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,47 ----
+    _        ___  ____ ____  ____
+   |_|_ _   / _ \/ ___/ ___||  _ \ 
+   _|_||_| | | | \___ \___ \| |_) |
+  |_||_|_| | |_| |___) |__) |  __/ 
+   |_|_|_|  \___/|____/____/|_|    
+ 
+   OSSP snmpdx - SNMP Daemon Extension
+   Version 0.1.0 (30-Jan-2003)
+ 
+   ABSTRACT
+ 
+   OSSP snmpdx is ...
+ 
+   COPYRIGHT AND LICENSE
+ 
+   Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+   Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+   Copyright (c) 2003 Cable & Wireless Germany <http://www.cw.com/de/>
+ 
+   This file is part of OSSP snmpdx, ...
+   can be found at http://www.ossp.org/pkg/tool/snmpdx/.
+ 
+   Permission to use, copy, modify, and distribute this software for
+   any purpose with or without fee is hereby granted, provided that
+   the above copyright notice and this permission notice appear in all
+   copies.
+ 
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+   IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.
+ 
+   HOME AND DOCUMENTATION
+ 
+   The documentation and latest release can be found on
+ 
+   o http://www.ossp.org/pkg/tool/snmpdx/
+   o  ftp://ftp.ossp.org/pkg/tool/snmpdx/
+ 


ossp-pkg/snmpdx/00TODO -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,14 ----
+ 
+ - suplement command line options with configuration file
+   (mainly because snmpd(8) does not support passing options)
+ 
+ - implement more probes [thl]
+ 
+ - support MIB SEQUENCEs [rse]
+ 
+ - split out MIB parts of each probe into own sub-MIBs
+ 
+ - Makefile and snmpdx.sh still contains some hard-coded things
+ 
+ - provide top-level MIB prefix name as variable
+ 


ossp-pkg/snmpdx/Makefile -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,27 ----
+ 
+ SRCDIR      = `pwd`
+ OPENPKG     = /cw
+ RC          = $(OPENPKG)/etc/rc
+ SNMPGET     = $(OPENPKG)/bin/snmpget
+ SNMPWALK    = $(OPENPKG)/bin/snmpget
+ SNMPHOSTS   = dv1 dv6 dv9
+ SNMPMIBDIR  = $(SRCDIR)/snmpdx.mib:$(OPENPKG)/share/snmp/mibs
+ SNMPMIBNAME = snmpdx
+ 
+ restart:
+        @for host in $(SNMPHOSTS); do \
+            echo "==== $$host ===="; \
+            ssh -t root@$$host "$(RC) snmp stop start"; \
+            $(SNMPGET) \
+                -M $(SNMPMIBDIR) -cpublic -v2c -mALL \
+             $$host $(SNMPMIBNAME)::swOsName; \
+        done
+ 
+ query:
+        @for host in $(SNMPHOSTS); do \
+            echo "==== $$host ===="; \
+            $(SNMPWALK) \
+                -M $(SNMPMIBDIR) -cpublic -v2c -mALL \
+                $$host $(SNMPMIBNAME); \
+        done
+ 


ossp-pkg/snmpdx/snmpdx -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,734 ----
+ #!/bin/sh -- # -*- perl -*-
+ eval 'exec perl -S $0 ${1+"$@"}'
+     if $running_under_some_shell;
+ ##
+ ##  OSSP snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ 
+ #   requirements
+ require 5;
+ use strict;
+ use warnings;
+ use Getopt::Long;
+ use IO;
+ 
+ #   program information
+ my $progname = "snmpdx";
+ my $progvers = "0.1.0";
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: LOGFILE WRITING
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::Log;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY write);
+ 
+ sub new ($$) {
+     my $proto = shift @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     my $level    = shift @_ || die "missing level argument";
+     my $filename = shift @_ || die "missing filename argument";
+     $self->{-level} = $level;
+     $self->{-io} = new IO::File ">>$filename"
+         or die "cannot open logfile \"$filename\" for writing";
+     $self->{-io}->autoflush(1);
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     $self->{-io}->close() if (defined($self->{-io}));
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub printf ($;@) {
+     my $self  = shift @_;
+     my $level = shift @_ || die "missing level argument";
+     my $fmt   = shift @_ || die "missing format argument";
+     if ($self->{-level} >= $level) {
+         my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time());
+         my $id = sprintf("[%04d-%02d-%02d/%02d:%02d:%02d@%05d] ", 
+                          $year+1900, $mon+1, $mday, $hour, $min, $sec, $$);
+         $self->{-io}->printf($id . $fmt . "\n", @_);
+     }
+     return;
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: VALUE CACHING
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::Cache;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY store fetch);
+ 
+ sub new ($) {
+     my ($proto) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     $self->{-cache} = {};
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub store ($$$$) {
+     my ($self, $id, $expires, $value) = @_;
+ 
+     die "invalid id" if (not defined($id) or $id eq '');
+ 
+     if    ($expires =~ m|^(\d+)[sS]?$|) { $expires = $1; }
+     elsif ($expires =~ m|^(\d+)[mM]$|)  { $expires = $1 * 60; }
+     elsif ($expires =~ m|^(\d+)[hH]$|)  { $expires = $1 * 60 * 60; }
+     elsif ($expires =~ m|^(\d+)[dD]$|)  { $expires = $1 * 60 * 60 * 24; }
+     elsif ($expires =~ m|^(\d+)[wW]$|)  { $expires = $1 * 60 * 60 * 24 * 7; }
+     elsif ($expires =~ m|^forever$|i)   { $expires = 99999 * 365 * 24 * 60 * 60; }
+     else { die "invalid expire time"; }
+ 
+     $expires = time() + $expires;
+ 
+     $self->{-cache}->{$id} = { -expires => $expires, -value => $value };
+ 
+     return;
+ }
+ 
+ sub fetch ($$) {
+     my ($self, $id) = @_;
+ 
+     my $value = undef;
+     if (defined($self->{-cache}->{$id})) {
+         if ($self->{-cache}->{$id}->{-expires} > time()) {
+             $value = $self->{-cache}->{$id}->{-value};
+         }
+         else {
+             undef $self->{-cache}->{$id};
+         }
+     }
+     return $value;
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: RUNNING SYSTEM COMMANDS
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::System;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY run);
+ 
+ sub new ($;$) {
+     my ($proto, $log, $cache) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     $self->{-log}   = $log;
+     $self->{-cache} = (defined($cache) ? $cache : new My::Cache);
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     $self->{-cache}->destroy() if (defined($self->{-cache}));
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub run ($$;$) {
+     my ($self, $cmd, $expires) = @_;
+ 
+     $expires = "1m" if (not defined($expires));
+     my $result = $self->{-cache}->fetch($cmd);
+     if (defined($result)) {
+         $self->{-log}->printf(4, "system: run: \"$cmd\" ($expires) [CACHE HIT]");
+     }
+     else {
+         $self->{-log}->printf(3, "system: run: \"$cmd\" ($expires) [CACHE MISS]");
+         $self->{-log}->printf(5, "system: executing command: \"$cmd\""); 
+         $result = { -stdout => '', -rv => 0 };
+         $result->{-stdout} = `$cmd 2>/dev/null`;
+         $result->{-rv} = ($? >> 8);
+         $self->{-log}->printf(6, "system: return value: ". $result->{-rv}); 
+         $self->{-cache}->store($cmd, $expires, $result);
+     }
+     return $result;
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: PLATFORM IDENTIFICATION
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::Platform;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY id);
+ 
+ sub new ($) {
+     my ($proto) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     $self->{-machine} = `(uname -m) 2>/dev/null`;
+     $self->{-machine} = `(uname -p) 2>/dev/null` if ($self->{-machine} eq '');
+     $self->{-machine} =~ s|^\s*(.+?)\s*$|$1|s;
+     $self->{-system}  = `(uname -s) 2>/dev/null`;
+     $self->{-system}  =~ s|^\s*(.+?)\s*$|$1|s;
+     $self->{-release} = `(uname -r) 2>/dev/null`;
+     $self->{-release} = `(uname -v) 2>/dev/null` if ($self->{-release} eq '');
+     $self->{-release} =~ s|^\s*(.+?)\s*$|$1|s;
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub id ($) {
+     my ($self) = @_;
+     return sprintf("%s-%s-%s", 
+         $self->{-machine}, $self->{-system}, $self->{-release});
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: MIB OID/NAME MAPPING
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::MIB;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY oid2name name2oid oid2type);
+ 
+ sub new ($$$) {
+     my ($proto, $bindir, $mibdir, $mib) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     $self->{-oid2name} = {};
+     $self->{-name2oid} = {};
+     my @entries = `$bindir/snmptranslate -M $mibdir -m $mib -Tl`;
+     foreach my $entry (@entries) {
+         $entry =~ s|\n$||s;
+         my $name = $entry;
+         my $oid = '';
+         $name =~ s|\((\d+)\)|$oid .= ".$1", ''|sge;
+         my $out = `$bindir/snmptranslate -M $mibdir -m $mib -Td $oid`;
+         if ($out =~ m|\s+MAX-ACCESS\s+not-accessible\s*|si) {
+             next;
+         }
+         my $type;
+         if ($out =~ m|TEXTUAL\s+CONVENTION\s+(.+?)\n\s+SYNTAX|si) {
+             $type = $1;
+         }
+         elsif ($out =~ m|SYNTAX\s+(.+?)\s*\n|si) {
+             $type = $1;
+             $type =~ s|\s+\([^\)]+\)$||s;
+         }
+         else {
+             next;
+         }
+         if ($name =~ m|[^.]+TABLE\.[^.]+ENTRY\.[^.]+$|) {
+             $name .= ".#";
+             $oid  .= ".#";
+         }
+         $self->{-oid2type}->{$oid} = $type;
+         $self->{-oid2name}->{$oid} = $name;
+         $self->{-name2oid}->{$name} = $oid;
+     }
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub oid2name ($$) {
+     my ($self, $oid) = @_;
+     return $self->{-oid2name}->{$oid};
+ }
+ 
+ sub name2oid ($$) {
+     my ($self, $name) = @_;
+     return $self->{-name2oid}->{$name};
+ }
+ 
+ sub oid2type ($$) {
+     my ($self, $oid) = @_;
+     return $self->{-oid2type}->{$oid};
+ }
+ 
+ sub oids ($;@) {
+     my ($self, @patterns) = @_;
+     my $oids = [];
+     foreach my $pattern (@patterns) {
+         $pattern = "*" if (not defined($pattern));
+         $pattern =~ s/\./\\./sg;
+         $pattern =~ s/\*/.*/sg;
+         foreach my $name (keys(%{$self->{-name2oid}})) {
+             if ($name =~ m|^${pattern}$|si) {
+                 push(@{$oids}, $self->{-name2oid}->{$name});
+             }
+         }
+     }
+     return $oids;
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: PROBE (abstract only)
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::Probe;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY oids probe);
+ 
+ sub new ($$) {
+     my ($proto, $ctx) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     $self->{-ctx} = $ctx;
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return [];
+ }
+ 
+ sub probe ($$$) {
+     my ($self, $ctx, $oid) = @_;
+     return {};
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  HELPER CLASS: Encoding
+ ##  _________________________________________________________________________
+ ##
+ 
+ package My::Enc;
+ 
+ require Exporter;
+ 
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(new destroy DESTROY dat_encode dat_decode octet_encode octet_decode);
+ 
+ sub new ($$) {
+     my ($proto) = @_;
+     my $class = ref $proto || $proto;
+     my $self = {};
+     bless ($self, $class);
+     return $self;
+ }
+ 
+ sub destroy ($) {
+     my ($self) = @_;
+     return;
+ }
+ 
+ sub DESTROY ($) {
+     my ($self) = @_;
+     $self->destroy;
+     return;
+ }
+ 
+ #   ASN.1 DateAndTime encoding/decoding
+ sub dat_encode ($$) {
+     my ($self, $asc) = @_;
+     my ($y, $m, $d, $H, $M, $S) = (0, 0, 0, 0, 0, 0);
+     if ($asc =~ m|^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$|) {
+         ($y, $m, $d, $H, $M, $S) = ($1, $2, $3, $4, $5, $6);
+     }
+     return pack("nCCCCCCCCC", $y, $m, $d, $H, $M, $S, 0, 0, 0, 0);
+ }
+ sub dat_decode ($$) {
+     my ($self, $bin) = @_;
+     my ($y, $m, $d, $H, $M, $S) = unpack("nCCCCCCCCC", $bin);
+     return sprintf("%04d-%02d-%02d %02d:%02d:%02d", $y, $m, $d, $H, $M, $S);
+ }
+ 
+ #   snmpd(8) pass_persist protocol 'octet' encoding/decoding
+ sub octet_encode ($$) {
+     my ($self, $bin) = @_;
+     my $asc = '';
+     $bin =~ s|(.)|$asc .= sprintf("%02x ", ord($1)), ''|sge;
+     return $asc;
+ }
+ sub octet_decode ($$) {
+     my ($self, $asc) = @_;
+     my $bin = '';
+     $asc =~ s|([0-9a-zA-Z]{2})\s*|$bin .= chr(hex($1)), ''|sge;
+     return $bin;
+ }
+ 
+ ##  _________________________________________________________________________
+ ##
+ ##  MAIN PROCEDURE
+ ##  _________________________________________________________________________
+ ##
+ 
+ package main;
+ 
+ #   parameters (defaults)
+ my $version   = 0;
+ my $help      = 0;
+ my $tmpdir    = ($ENV{TMPDIR} || $ENV{TEMPDIR} || "/tmp");
+ my $get       = 0;
+ my $next      = 0;
+ my $bindir    = "/cw/bin";
+ my $probedir  = "./snmpdx.d";
+ my $probename = "*";
+ my $mibdir    = "./snmpdx.mib";
+ my $mibname   = "snmpdx";
+ my $logfile   = "./snmpdx.log";
+ my $loglevel  = 9;
+ 
+ #   command line parsing
+ Getopt::Long::Configure("bundling");
+ my $result = GetOptions(
+     'V|version'     => \$version,
+     'h|help'        => \$help,
+     't|tmpdir=s'    => \$tmpdir,
+     'g|get'         => \$get,
+     'n|next'        => \$next,
+     'b|bindir=s'    => \$bindir,
+     'P|probedir=s'  => \$probedir,
+     'p|probename=s' => \$probename,
+     'M|mibdir=s'    => \$mibdir,
+     'm|mibname=s'   => \$mibname,
+     'l|logfile=s'   => \$logfile,
+     'L|loglevel=i'  => \$loglevel,
+ ) || die "option parsing failed";
+ if ($help) {
+     print "Usage: $progname [options] [SPECFILE ...]\n" .
+           "Available options:\n" .
+           " -V,--version        print program version\n" .
+           " -h,--help           print out this usage page\n" .
+           " -t,--tmpdir=PATH    filesystem path to temporary directory\n" .
+           " -g,--get=MIBOID     get value of this MIB OID\n" .
+           " -n,--next=MIBOID    get value of next MIB OID\n" .
+           " -b,--bindir=PATH    path to the net-snmp binaries\n" .
+           " -P,--probedir=PATH  path to probe directory\n" .
+           " -p,--probename=NAME the pattern for probes to load\n" .
+           " -M,--mibdir=PATH    path to MIB directory\n" .
+           " -m,--mibname=MIB    the name of the MIB to act under\n" .
+           " -l,--logfile=PATH   path to daemon logfile\n" .
+           " -L,--loglevel=NUM   logging level (0...9)\n";
+     exit(0);
+ }
+ if ($version) {
+     print "$progname $progvers\n";
+     exit(0);
+ }
+ 
+ #   create daemon run-time context
+ my $ctx = {};
+ $ctx->{-log}      = new My::Log ($loglevel, $logfile);
+ $ctx->{-cache}    = new My::Cache;
+ $ctx->{-sys}      = new My::System ($ctx->{-log}, $ctx->{-cache});
+ $ctx->{-platform} = new My::Platform;
+ $ctx->{-log}->printf(1, "startup %s %s (%s)", $progname, $progvers, $ctx->{-platform}->id());
+ $ctx->{-mib}      = new My::MIB ($bindir, $mibdir, $mibname);
+ $ctx->{-enc}      = new My::Enc;
+ 
+ #   exception handling support 
+ $SIG{__DIE__} = sub {
+     my ($err) = @_;
+     $err =~ s|\r?\n$||s;
+     $ctx->{-log}->printf(1, "ERROR: $err ". ($! ? "($!)" : ""));
+     undef $ctx;
+     exit(1);
+ };
+ $SIG{__WARN__} = sub {
+     my ($err) = @_;
+     $err =~ s|\r?\n$||s;
+     $ctx->{-log}->printf(1, "WARNING: $err");
+     return;
+ };
+ 
+ #   PROTOCOL   MIB        MIB TYPE            net-snmp API   CONVERT TYPE
+ #   ---------- ---------- ------------------- -------------- ------- ------
+ #   string     SNMPv2-TC  DisplayString       ASN_OCTET_STR  -       char *
+ #   integer    ASN.1      Integer32           ASN_INTEGER    strtol  long
+ #   unsigned   SNMPv2-SMI Unsigned32          ASN_UNSIGNED   strtoul long
+ #   counter    SNMPv2-SMI Counter32           ASN_COUNTER    strtoul long
+ #   octet      ASN.1      OCTET STRING        ASN_OCTET_STR  asc2bin char *
+ #   opaque     SNMPv2-SMI Opaque              ASN_OPAQUE     asc2bin char *
+ #   gauge      SNMPv2-SMI Gauge32             ASN_GAUGE      strtoul long
+ #   objectid   ASN.1      OBJECT IDENTIFIER   ASN_OBJECT_ID  -       char *
+ #   timetick   SNMPv2-SMI TimeTicks           ASN_TIMETICKS  strtoul long
+ #   ipaddress  SNMPv2-SMI IpAddress           ASN_IPADDRESS  htonl   long
+ #   octet      SNMPv2-TC  DateAndTime         ASN_OCTET_STR  asc2bin char *
+ 
+ #   load probes and determine their handled OIDs
+ my $oidtable   = [];
+ my $oidhandler = {};
+ my $oidtype    = {
+     'DisplayString'      => [ 'string',    'N.A.'    ],
+     'Integer32'          => [ 'integer',   '-1'      ],
+     'Unsigned32'         => [ 'unsigned',  '0'       ],
+     'Counter32'          => [ 'counter',   '-1'      ],
+     'OCTET STRING'       => [ 'octet',     'N.A.'    ],
+     'Opaque'             => [ 'opaque',    'N.A.'    ],
+     'Gauge32'            => [ 'gauge',     '-1'      ],
+     'OBJECT IDENTIFIER'  => [ 'objectid',  '.0'      ],
+     'TimeTicks'          => [ 'timetick',  '0'       ],
+     'IpAddress'          => [ 'ipaddress', '0.0.0.0' ],
+     'DateAndTime'        => [ 'octet',     $ctx->{-enc}->dat_encode("1970-01-01 01:02:03") ],
+ };
+ $ctx->{-log}->printf(1, "MIB id: %s", $mibname);
+ foreach my $probefile (glob("$probedir/$probename.pm")) {
+     my $probe = $probefile;
+     $probe =~ s|^.*/([^/]+)\.pm$|$1|sg;
+     my $p;
+     eval {
+         local $SIG{__DIE__} = 'DEFAULT';
+         eval "require \"$probefile\";";
+         die if ($@);
+         eval "\$p = new My::Probe::$probe (\$ctx);";
+         die if ($@);
+     };
+     if ($@) {
+         die "invalid probe \"$probe\"";
+     }
+     $ctx->{-log}->printf(2, "Probe: \"%s\"", $probe);
+     foreach my $oid (sort(@{$p->oids()})) {
+         push(@{$oidtable}, $oid);
+         $oidhandler->{$oid} = $p;
+         $ctx->{-log}->printf(1, "MIB OID: %s [%s] ::= %s (%s)",
+             $oid, $ctx->{-mib}->oid2name($oid),
+             $ctx->{-mib}->oid2type($oid),
+             $oidtype->{$ctx->{-mib}->oid2type($oid)}->[0]);
+     }
+ }
+ @{$oidtable} = sort(@{$oidtable});
+ 
+ #   connect I/O channels
+ my $stdin = new IO::Handle;;
+ $stdin->fdopen(fileno(STDIN), "r");
+ $stdin->blocking(1);
+ my $stdout = new IO::Handle;;
+ $stdout->fdopen(fileno(STDOUT), "w");
+ $stdout->autoflush(1);
+ open(STDERR, ">/dev/null");
+ 
+ #   daemon loop
+ while (1) {
+     #   read next command from snmpd
+     my $cmd = $stdin->getline;
+     if (not defined($cmd)) {
+         $ctx->{-log}->printf(4, "IO: EOF");
+         last;
+     }
+     $cmd =~ s|\n?$||s;
+     $ctx->{-log}->printf(4, "IO: recv: << \"%s\\n\"", $cmd);
+ 
+     if ($cmd =~ m/^PING$/i) {
+         #   the PING/PONG protocol part
+         $ctx->{-log}->printf(4, "IO: send: >> \"PONG\\n\"");
+         $stdout->printf("PONG\n");
+     }
+     elsif ($cmd =~ m/^GET$/i or $cmd =~ m/^GETNEXT$/i) {
+         #   the GET/GETNEXT protocol part
+         my $error = 1;
+         my $oid = $stdin->getline;
+         if (not defined($oid)) {
+             $ctx->{-log}->printf(1, "ERROR: EOF instead of OID");
+             goto ERROR;
+         }
+         $oid =~ s|\n?$||s;
+         $ctx->{-log}->printf(4, "IO: recv: << \"%s\\n\"", $oid);
+         if ($oid !~ m/^(\.\d+)+$/) {
+             $ctx->{-log}->printf(1, "ERROR: invalid query OID \"%s\"", $oid);
+             goto ERROR;
+         }
+         my $oid_table = undef;
+         if ($cmd =~ m/^GETNEXT$/i) {
+             my $oid_parent = $oid;
+             $oid_parent =~ s|(\.\d+)$||s;
+             for (my $i = 0; defined($oidtable->[$i]); $i++) {
+                 if ($oidtable->[$i] =~ m|^\Q$oid\E(\.\d+)+$|) {
+                     #   OID start with requested OID prefix, so use this OID
+                     $oid = $oidtable->[$i];
+                     last;
+                 }
+                 elsif ($oidtable->[$i] eq $oid) {
+                     #   OID is the requested OID exactly, so use next OID
+                     if (defined($oidtable->[$i+1])) {
+                         $oid = $oidtable->[$i+1];
+                         last;
+                     }
+                     else {
+                         goto ERROR; # end-of-MIB case
+                     }
+                 }
+                 elsif ($oidtable->[$i] =~ m|^\Q$oid\E(\.\d+)*(\.#)$|) {
+                     #   OID start with requested OID prefix, so use this OID (special case of table)
+                     $oid = $oidtable->[$i];
+                     $oid =~ s|\.#$|.1|s;
+                     last;
+                 }
+                 elsif ($oidtable->[$i] =~ m|^\Q$oid_parent\E\.#$|) {
+                     #   OID is the a requested OID of a table, so use next OID in table
+                     $oid = s|\.(\d+)$|".".($1+1)|se;
+                     $oid_table = $oidtable->[$i+1];
+                     $oid =~ s|\.#$|.1|s;
+                     last;
+                 }
+             }
+         }
+         TABLE_NEXT:
+         my $oid_wild = $oid;
+         my $handler = $oidhandler->{$oid};
+         if (not defined($handler)) {
+             $oid_wild =~ s|(\.\d+)$|.#|s;
+             $handler = $oidhandler->{$oid_wild};
+         }
+         if (not defined($handler)) {
+             $ctx->{-log}->printf(1, "ERROR: no handler found for OID \"%s\"", $oid);
+             goto ERROR;
+         }
+         my $obj = {
+             -oid   => $oid,
+             -name  => $ctx->{-mib}->oid2name($oid_wild),
+             -type  => $ctx->{-mib}->oid2type($oid_wild),
+             -value => undef
+         };
+         $handler->probe($obj);
+         if (not defined($obj->{-value})) {
+             if (defined($oid_table)) {
+                 #   end of table entry
+                 $oid = $oid_table;
+                 goto TABLE_NEXT;
+             }
+             #$ctx->{-log}->printf(1, "ERROR: handler was unable to provide probe value for OID \"%s\"", $oid);
+             #goto ERROR;
+             $ctx->{-log}->printf(1, "WARNING: handler was unable to provide probe value for OID \"%s\"", $oid);
+             $obj->{-value} = $oidtype->{$obj->{-type}}->[1];
+         }
+         if ($oidtype->{$obj->{-type}}->[0] =~ m/^(octet|opaque)$/) {
+             $obj->{-value} = $ctx->{-enc}->octet_encode($obj->{-value});
+         }
+         $ctx->{-log}->printf(1, "QUERY: %s [%s] ::= %s \"%s\"",
+             $obj->{-name}, $obj->{-oid}, $obj->{-type}, $obj->{-value});
+         $stdout->printf("%s\n%s\n%s\n",
+             $obj->{-oid}, $oidtype->{$obj->{-type}}->[0], $obj->{-value});
+         $ctx->{-log}->printf(4, "IO: send: >> \"%s\\n%s\\n%s\\n\"",
+             $obj->{-oid}, $oidtype->{$obj->{-type}}->[0], $obj->{-value});
+         $error = 0;
+ 
+         if ($error) {
+             #   end-of-MIB or error
+             ERROR:
+             $ctx->{-log}->printf(4, "IO: send: >> \"NONE\\n\"");
+             $stdout->printf("NONE\n");
+         }
+     }
+     else {
+         #   for anything else (not expected) just send 
+         #   something in case snmpd expects something.
+         $ctx->{-log}->printf(4, "IO: send: >> \"\"");
+         $stdout->printf("\n");
+     }
+ }
+ 
+ #   shutdown gracefully
+ $ctx->{-log}->printf(1, "shutdown");
+ undef $ctx;
+ exit(0);
+ 


ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,66 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  hwCpu: Hardware, CPU
+ ##
+ 
+ package My::Probe::hwCpu;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.hardware.hwCpu.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+ 
+     if ($obj->{-name} =~ m|\.hwCpuNum$|) {
+         if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+             #   query sysctl(8)
+             my $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n hw.ncpu", "forever");
+             $obj->{-value} = $out->{-stdout};
+             $obj->{-value} =~ s/^\s*(.+?)\s*$/$1/s;
+         }
+     }
+     elsif ($obj->{-name} =~ m|\.hwCpuSpeed$|) {
+         if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+             #   query dmesg(8)
+             #   FIXME: this works only within a reasonable time after booting
+             #          but I don't know any alternative method for querying the speed!
+             my $out = $self->{-ctx}->{-sys}->run("/sbin/dmesg", "forever");
+             if ($out->{-stdout} =~ m|(\d+)(\.\d+)?[ -]*MHz|si) {
+                 $obj->{-value} = $1;
+             }
+         }
+     }
+     elsif ($obj->{-name} =~ m|\.hwCpuTemp$|) {
+         if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+         }
+     }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/hwProd.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,81 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  hwProd: Hardware, Product
+ ##
+ 
+ package My::Probe::hwProd;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.hardware.hwProd.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+ 
+     #   query hardware architecture via uname(1)
+     my $uname = "uname";
+     if    ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i)       { $uname = "/usr/bin/uname"; }
+     elsif ($self->{-ctx}->{-platform}->id() =~ m/(Linux|SunOS)/i) { $uname = "/bin/uname";     }
+     my $out = $self->{-ctx}->{-sys}->run("$uname -m 2>/dev/null || $uname -p 2>/dev/null", "1d");
+     my $arch = $out->{-stdout};
+     $arch =~ s|^\s*(.+?)\s*$|$1|s;
+ 
+     #   provide results
+     if ($obj->{-name} =~ m|\.hwProdArch$|) {
+         $obj->{-value} = $arch;
+     }
+     elsif ($obj->{-name} =~ m|\.hwProdName$|) {
+         my $name = "NoName";
+         if ($self->{-ctx}->{-platform}->id() =~ m/SunOS/i) {
+             my $out = $self->{-ctx}->{-sys}->run("/usr/platform/`uname -i`/sbin/prtdiag", "1d");
+             if ($out->{-stdout} =~ m|System\s+Configuration:\s+(.*?)\n|si) {
+                 #  System Configuration:  Sun Microsystems  sun4u Sun (TM) Enterprise 250 (2 X UltraSPARC-II 400MHz)
+                 #  System Configuration:  Sun Microsystems  sun4u Netra t1 (UltraSPARC-IIi 440MHz)
+                 #  System Configuration:  Sun Microsystems  sun4u Sun Ultra 450 (2 X UltraSPARC-II 248MHz)
+                 #  System Configuration:  Sun Microsystems  sun4u Sun Enterprise 420R (2 X UltraSPARC-II 450MHz)
+                 $name = $1;
+                 $name =~ s|\s+$arch||s;
+                 $name =~ s|(Sun Microsystems)\s+Sun|$1|si;
+                 $name =~ s|\s+\(TM\)||si;
+             }
+         }
+         elsif ($arch =~ m/^(i?[3-6x]86|.*(pentium|athlon).*)$/i) {
+             $name .= "-PC";
+             if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+                 my $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n hw.model", "1d");
+                 my $model = $out->{-stdout};
+                 $model =~ s/^\s*(.+?)\s*$/$1/s;
+                 $name .= " ($model)";
+             }
+         }
+         $obj->{-value} = $name;
+     }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/swOp.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,50 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  swOp: Software, OpenPKG
+ ##
+ 
+ package My::Probe::swOp;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     my $oids = [];
+     push(@{$oids}, @{$self->{-ctx}->{-mib}->oids("*.snmpdx.host.software.swOp.swOpVersion")});
+     foreach my $oid (@{$self->{-ctx}->{-mib}->oids("*.snmpdx.host.software.swOp.swOpPkg.*")}) {
+         push(@{$oids}, $oid.".1");
+         push(@{$oids}, $oid.".2");
+         push(@{$oids}, $oid.".3");
+     }
+     return $oids;
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+ 
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/swOs.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,55 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  swOs: Software, Operating System
+ ##
+ 
+ package My::Probe::swOs;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.software.swOs.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+ 
+     #   query system via uname(1)
+     my $uname = "uname";
+     if    ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i)       { $uname = "/usr/bin/uname"; }
+     elsif ($self->{-ctx}->{-platform}->id() =~ m/(Linux|SunOS)/i) { $uname = "/bin/uname";     }
+     my $out1 = $self->{-ctx}->{-sys}->run("$uname -s 2>/dev/null || echo 'Unix'", "1d");
+     my $out2 = $self->{-ctx}->{-sys}->run("$uname -r 2>/dev/null || $uname -v 2>/dev/null", "1d");
+     my $name = $out1->{-stdout}; $name =~ s|^\s*(.+?)\s*$|$1|s;
+     my $vers = $out2->{-stdout}; $vers =~ s|^\s*(.+?)\s*$|$1|s;
+ 
+     #   provide results
+     if    ($obj->{-name} =~ m|\.swOsName$|)    { $obj->{-value} = $name; }
+     elsif ($obj->{-name} =~ m|\.swOsVersion$|) { $obj->{-value} = $vers; }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/sysLoad.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,63 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  sysLoad: System Load Average
+ ##
+ 
+ package My::Probe::sysLoad;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.system.sysLoad.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+ 
+     #   query system via uptime(1)
+     my $uptime = "uptime";
+     if ($self->{-ctx}->{-platform}->id() =~ m/(FreeBSD|Linux|SunOS)/i) {
+         $uptime = "/usr/bin/uptime"
+     }
+     my $out = $self->{-ctx}->{-sys}->run($uptime, "1m");
+ 
+     #   parse out details (example outputs follow)
+     #   FreeBSD: "5:36PM  up 6 days, 54 mins, 9 users, load averages: 0.00, 0.02, 0.00"
+     #   Linux:   "17:36:50 up 49 days,  8:16,  2 users,  load average: 0.00, 0.00, 0.00"
+     #   SunOS:   "5:36pm  up 71 day(s),  3:29,  2 users,  load average: 0.16, 0.11, 0.13"
+     my ($load5, $load10, $load15) = (0, 0, 0);
+     if ($out->{-stdout} =~ m|load\s+averages?:\s+(\S+),\s+(\S+),\s+(\S+)|si) {
+         ($load5, $load10, $load15) = ($1, $2, $3);
+     }
+ 
+     #   provide result
+     if    ($obj->{-name} =~ m|\.sysLoad5$|)  { $obj->{-value} = sprintf("%d", $load5  * 100); }
+     elsif ($obj->{-name} =~ m|\.sysLoad10$|) { $obj->{-value} = sprintf("%d", $load10 * 100); }
+     elsif ($obj->{-name} =~ m|\.sysLoad15$|) { $obj->{-value} = sprintf("%d", $load15 * 100); }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/sysProc.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,76 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  sysProc: System Process Information
+ ##
+ 
+ package My::Probe::sysProc;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.system.sysProc.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+     
+     if ($obj->{-name} =~ m|\.sysProcMax$|) {
+         if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+             #   query system via sysctl(8)
+             my $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n kern.maxproc", "1d");
+             $obj->{-value} = $out->{-stdout};
+             $obj->{-value} =~ s/^\s*(.+?)\s*$/$1/s;
+         }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/Linux/i) {
+             #   query system via /proc or sysctl(8)
+             my $out = $self->{-ctx}->{-sys}->run(
+                 "cat /proc/sys/kernel/threads-max 2>&1 || " .
+                 "/sbin/sysctl kernel/threads-max", "1d");
+             $obj->{-value} = $out->{-stdout};
+             $obj->{-value} =~ s/^[^\d]*(\d+).*$/$1/s;
+         }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/SunOS/i) {
+             #   query system via sysdef(8)
+             my $out = $self->{-ctx}->{-sys}->run("/usr/sbin/sysdef -i", "1d");
+             if ($out->{-stdout} =~ m/\s*(\d+)\s+maximum number of processes/s) {
+                 $obj->{-value} = $1;
+             }
+         }
+     }
+     elsif ($obj->{-name} =~ m|\.sysProcActive$|) {
+         #   query system via ps(1)
+         my $ps = "ps";
+         if    ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) { $ps = "/bin/ps -ax"; }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/Linux/i)   { $ps = "/bin/ps ax";  }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/SunOS/i)   { $ps = "/bin/ps -e";  }
+         my $out = $self->{-ctx}->{-sys}->run($ps, "1m");
+         my @lines = split(/\n/, $out->{-stdout});
+         $obj->{-value} = ($#lines+1);
+     }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/sysUptime.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,69 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  sysUptime: System Uptime
+ ##
+ 
+ package My::Probe::sysUptime;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.system.sysUptime");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+     
+     #   query system via uptime(1)
+     my $uptime = "uptime";
+     if ($self->{-ctx}->{-platform}->id() =~ m/(FreeBSD|Linux|SunOS)/i) {
+         $uptime = "/usr/bin/uptime"
+     }
+     my $out = $self->{-ctx}->{-sys}->run($uptime, "1m");
+ 
+     #   parse out details (example outputs follow)
+     #   FreeBSD: "5:36PM  up 6 days, 54 mins, 9 users, load averages: 0.00, 0.02, 0.00"
+     #   Linux:   "17:36:50 up 49 days,  8:16,  2 users,  load average: 0.00, 0.00, 0.00"
+     #   SunOS:   "5:36pm  up 71 day(s),  3:29,  2 users,  load average: 0.16, 0.11, 0.13"
+     my ($days, $hours, $mins) = (0, 0, 0);
+     my $spec = $out->{-stdout};
+     $spec =~ s|^.*\s+up\s+||s;
+     $spec =~ s|,\s+\d+\s+users.*$||s;
+     $spec =~ s/(\d+)\s+day(s|\(s\))?/$days = $1, ''/se;
+     $spec =~ s/(\d+):(\d{2})/$hours = $1, $mins = $2, ''/se;
+     $spec =~ s/(\d+)\s+min(s|\(s\))?/$mins = $1, ''/se;
+ 
+     #   provide results
+     my $t = 0;
+     $t += ($days  * 24 * 60 * 60);
+     $t += ($hours *      60 * 60);
+     $t += ($mins  *           60);
+     $t *= 100;
+     $obj->{-value} = $t;
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.d/sysUser.pm -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,71 ----
+ ##
+ ##  snmpdx -- SNMP Daemon Extension
+ ##  Copyright (c) 2003 The OSSP Project <http://www.ossp.org/>
+ ##  Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Copyright (c) 2003 Cable & Wireless <http://www.cw.com/>
+ ##
+ ##  Permission to use, copy, modify, and distribute this software for
+ ##  any purpose with or without fee is hereby granted, provided that
+ ##  the above copyright notice and this permission notice appear in all
+ ##  copies.
+ ##
+ ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ ##  SUCH DAMAGE.
+ ##
+ ##  sysUser: System User Information
+ ##
+ 
+ package My::Probe::sysUser;
+ our @ISA = qw(My::Probe);
+ 
+ sub oids ($) {
+     my ($self) = @_;
+     return $self->{-ctx}->{-mib}->oids("*.snmpdx.host.system.sysUser.*");
+ }
+ 
+ sub probe ($$) {
+     my ($self, $obj) = @_;
+     
+     if ($obj->{-name} =~ m|\.sysUserMax$|) {
+         if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+             #   query system via sysctl(8)
+             my $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n kern.maxusers", "1d");
+             $obj->{-value} = $out->{-stdout};
+             $obj->{-value} =~ s/^\s*(.+?)\s*$/$1/s;
+         }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/Linux/i) {
+             #   TODO
+         }
+         elsif ($self->{-ctx}->{-platform}->id() =~ m/SunOS/i) {
+             #   TODO
+         }
+     }
+     elsif ($obj->{-name} =~ m|\.sysUserLoggedIn$|) {
+         #   query system via uptime(1)
+         #   FreeBSD: "5:36PM  up 6 days, 54 mins, 9 users, load averages: 0.00, 0.02, 0.00"
+         #   Linux:   "17:36:50 up 49 days,  8:16,  2 users,  load average: 0.00, 0.00, 0.00"
+         #   SunOS:   "5:36pm  up 71 day(s),  3:29,  2 users,  load average: 0.16, 0.11, 0.13"
+         my $uptime = "uptime";
+         if ($self->{-ctx}->{-platform}->id() =~ m/(FreeBSD|Linux|SunOS)/i) {
+             $uptime = "/usr/bin/uptime"
+         }
+         my $out = $self->{-ctx}->{-sys}->run($uptime, "1m");
+         if ($out->{-stdout} =~ m|\s*(\d+)\s+users|s) {
+             $obj->{-value} = $1;
+         }
+     }
+     return;
+ }
+ 
+ 1;
+ 


ossp-pkg/snmpdx/snmpdx.mib/.index -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1 ----
+ snmpdx snmpdx.mib


ossp-pkg/snmpdx/snmpdx.mib/snmpdx.mib -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,393 ----
+ snmpdx DEFINITIONS ::= BEGIN
+ 
+ IMPORTS
+     MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE,
+     Integer32, Counter32, Gauge32, TimeTicks
+         FROM SNMPv2-SMI
+ 
+     TEXTUAL-CONVENTION, DisplayString, DateAndTime
+         FROM SNMPv2-TC
+ 
+     MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP
+         FROM SNMPv2-CONF;
+ 
+ org            OBJECT IDENTIFIER ::= { iso 3 } -- iso = 1
+ dod            OBJECT IDENTIFIER ::= { org 6 }
+ internet       OBJECT IDENTIFIER ::= { dod 1 }
+ private        OBJECT IDENTIFIER ::= { internet 4 }
+ enterprises    OBJECT IDENTIFIER ::= { private 1 }
+ 
+ cw             OBJECT IDENTIFIER ::= { enterprises 4007 }
+ snmpdx         OBJECT IDENTIFIER ::= { cw 42 }
+ 
+ host           OBJECT IDENTIFIER ::= { snmpdx 1 }
+ hardware       OBJECT IDENTIFIER ::= { host 1 }
+ system         OBJECT IDENTIFIER ::= { host 2 }
+ software       OBJECT IDENTIFIER ::= { host 3 }
+ 
+ --
+ --  System Identification
+ --
+ 
+ sysId OBJECT IDENTIFIER
+     ::= { system 1 }
+ 
+ sysIdHostid OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "unique host identification of system"
+     ::= { sysId 1 }
+ 
+ sysIdHostname OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "fully qualified host name of system"
+     ::= { sysId 2 }
+ 
+ --
+ --  System Load Average
+ --
+ 
+ sysLoad OBJECT IDENTIFIER
+     ::= { system 2 }
+ 
+ sysLoad5 OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "load average during last 5 minutes"
+     ::= { sysLoad 1 }
+ 
+ sysLoad10 OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "load average during last 10 minutes"
+     ::= { sysLoad 2 }
+ 
+ sysLoad15 OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "load average during last 15 minutes"
+     ::= { sysLoad 3 }
+ 
+ --
+ --  System Processes
+ --
+ 
+ sysProc OBJECT IDENTIFIER
+     ::= { system 3 }
+ 
+ sysProcMax OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of process contexts maximum possible"
+     ::= { sysProc 1 }
+ 
+ sysProcActive OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of process contexts currently active"
+     ::= { sysProc 2 }
+ 
+ --
+ --  System Users
+ --
+ 
+ sysUser OBJECT IDENTIFIER
+     ::= { system 4 }
+ 
+ sysUserMax OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of logged in users maximum possible"
+     ::= { sysUser 1 }
+ 
+ sysUserLoggedIn OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of currently logged in users"
+     ::= { sysUser 2 }
+ 
+ --
+ --  System Uptime
+ --
+ 
+ sysUptime OBJECT-TYPE
+     SYNTAX      TimeTicks
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "time (in hundrets of a second) since the system was booted"
+     ::= { system 5 }
+ 
+ --
+ --  Hardware: Product
+ --
+ 
+ hwProd OBJECT IDENTIFIER
+     ::= { hardware 1 }
+ 
+ hwProdArch OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "name of hardware architecture"
+     ::= { hwProd 1 }
+ 
+ hwProdName OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "name of hardware product"
+     ::= { hwProd 2 }
+ 
+ --
+ --  Hardware: CPU
+ --
+ 
+ hwCpu OBJECT IDENTIFIER
+     ::= { hardware 2 }
+ 
+ hwCpuNum OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of CPUs"
+     ::= { hwCpu 1 }
+ 
+ hwCpuSpeed OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of CPUs"
+     ::= { hwCpu 2 }
+ 
+ hwCpuTemp OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "temperature of CPU"
+     ::= { hwCpu 3 }
+ 
+ --
+ --  Hardware: RAM
+ --
+ 
+ hwRam OBJECT IDENTIFIER
+     ::= { hardware 3 }
+ 
+ hwRamMax OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "maximum available RAM in MB"
+     ::= { hwRam 1 }
+ 
+ hwRamUsed OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "currently used RAM in MB"
+     ::= { hwRam 2 }
+ 
+ hwRamStatus OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "boolean status of RAM banks"
+     ::= { hwRam 3 }
+ 
+ --
+ --  Hardware: Disk Space
+ --
+ 
+ hwDisk OBJECT IDENTIFIER
+     ::= { hardware 4 }
+ 
+ hwDiskMax OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "maximum available Disk space in MB"
+     ::= { hwDisk 1 }
+ 
+ hwDiskUsed OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "currently used Disk space in MB"
+     ::= { hwDisk 2 }
+ 
+ hwDiskTemp OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "temperature of Disks"
+     ::= { hwDisk 3 }
+ 
+ hwDiskStatus OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "boolean status of Disks"
+     ::= { hwDisk 4 }
+ 
+ --
+ --  Hardware: Power Supply
+ --
+ 
+ hwPS OBJECT IDENTIFIER
+     ::= { hardware 5 }
+ 
+ hwPSNum OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "number of power supplies"
+     ::= { hwPS 1 }
+ 
+ hwPSTemp OBJECT-TYPE
+     SYNTAX      Gauge32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "temperature of Power Supply"
+     ::= { hwPS 2 }
+ 
+ hwPSStatus OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "boolean status of Power Supply (0:shutdown, 1:operating: 2:error)"
+     ::= { hwPS 3 }
+ 
+ --
+ --  Hardware: Chassis
+ --
+ 
+ hwChassis OBJECT IDENTIFIER
+     ::= { hardware 6 }
+ 
+ hwChassisOpen OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "boolean open/close status of Chassis"
+     ::= { hwChassis 1 }
+ 
+ hwChassisTemp OBJECT-TYPE
+     SYNTAX      Integer32
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "temperature inside Chassis"
+     ::= { hwChassis 2 }
+ 
+ --
+ --  Software: Operating System
+ --
+ 
+ swOs OBJECT IDENTIFIER
+     ::= { software 1 }
+ 
+ swOsName OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "name of operating system"
+     ::= { swOs 1 }
+ 
+ swOsVersion OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "version of operating system"
+     ::= { swOs 2 }
+ 
+ --
+ --  Software: OpenPKG Instances
+ --
+ 
+ swOp OBJECT IDENTIFIER
+     ::= { software 2 }
+ 
+ swOpVersion OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "OpenPKG instance version"
+     ::= { swOp 1 }
+ 
+ swOpPkgTABLE OBJECT-TYPE
+     SYNTAX         SEQUENCE OF SwOpPkgENTRY
+     MAX-ACCESS  not-accessible
+     STATUS      current
+     DESCRIPTION "OpenPKG package table"
+     ::= { swOp 2 }
+ 
+ swOpPkgENTRY OBJECT-TYPE
+     SYNTAX         SwOpPkgENTRY
+     MAX-ACCESS not-accessible
+     STATUS         current
+     DESCRIPTION "An entry containing a load average and its values."
+     INDEX          { swOpPkgIndex }
+     ::= { swOpPkgTABLE 1 }
+ 
+ SwOpPkgENTRY ::= SEQUENCE {
+     swOpPkgIndex     Integer32,
+     swOpPkgName      DisplayString,
+     swOpPkgVersion   DisplayString,
+     swOpPkgRelease   DisplayString,
+     swOpPkgBuilt     DateAndTime,
+     swOpPkgInstalled DateAndTime,
+ }
+ 
+ swOpPkgIndex OBJECT-TYPE
+     SYNTAX         Integer32
+     MAX-ACCESS read-only
+     STATUS         current
+     DESCRIPTION "reference index/row number for each package"
+     ::= { swOpPkgENTRY 1 }
+ 
+ swOpPkgName OBJECT-TYPE
+     SYNTAX      DisplayString
+     MAX-ACCESS  read-only
+     STATUS      current
+     DESCRIPTION "name of package"
+     ::= { swOpPkgENTRY 2 }
+ 
+ swOpPkgVersion OBJECT-TYPE
+     SYNTAX         DisplayString
+     MAX-ACCESS read-only
+     STATUS         current
+     DESCRIPTION "vendor version of package"
+     ::= { swOpPkgENTRY 3 }
+ 
+ swOpPkgRelease OBJECT-TYPE
+     SYNTAX         DisplayString
+     MAX-ACCESS read-only
+     STATUS         current
+     DESCRIPTION "OpenPKG release of package"
+     ::= { swOpPkgENTRY 4 }
+ 
+ swOpPkgBuilt OBJECT-TYPE
+     SYNTAX         DateAndTime
+     MAX-ACCESS read-only
+     STATUS         current
+     DESCRIPTION "time package was built"
+     ::= { swOpPkgENTRY 5 }
+ 
+ swOpPkgInstalled OBJECT-TYPE
+     SYNTAX         DateAndTime
+     MAX-ACCESS read-only
+     STATUS         current
+     DESCRIPTION "time package was installed"
+     ::= { swOpPkgENTRY 6 }
+ 
+ END
+ 


ossp-pkg/snmpdx/snmpdx.sh -> 1.1

*** /dev/null    Sat Nov 23 01:11:43 2024
--- -    Sat Nov 23 01:11:57 2024
***************
*** 0 ****
--- 1,20 ----
+ #!/bin/sh
+ openpkgdir=/cw
+ me="$0"
+ case "$me" in
+     /*  ) ;;
+     */* ) me="`pwd`/$me" ;;
+     *   )
+         for p in `echo $PATH | sed -e 's/:/ /g'`; do
+             if [ -x "$p/$me" ]; then
+                 me="$p/$me"
+                 break
+             fi
+         done
+         ;;
+ esac
+ rootdir=`echo $me | sed -e 's;/[^/]*$;;'`
+ $rootdir/snmpdx \
+     -M $rootdir/snmpdx.mib:$openpkgdir/share/snmp/mibs \
+     -P $rootdir/snmpdx.d \
+     -l /tmp/snmpdx.log

CVSTrac 2.0.1