DOCSIS Stats

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Author
Message
jbarbieri
Cacti User
Posts: 101
Joined: Tue May 24, 2005 8:46 am
Location: Rochester, New Hampshire
Contact:

#61 Post by jbarbieri » Thu Feb 12, 2009 4:27 pm

Hi there, this is a great script.

I am trying to monitor a modem, but the power levels don't show, and running manually, I get this:

Code: Select all

bash-3.00# php ../script_server.php
PHP Script Server has Started - Parent is cmd
/usr/local/cacti/scripts/ss_docsis_stats.php
WARNING: Function does not exist
/usr/local/cacti/scripts/ss_docsis_stats.php ss_docsis_stats 172.16.10.2 public 2 161 500
docsIfDownChannelPower:NaN docsIfSigQSignalNoise:NaN docsIfSigQMicroreflections:NaN docsIfCmRangingTimeout:5 docsIfCmStatusTxPower:NaN docsIfCmStatusResets:0 docsIfCmStatusLostSyncs:0 docsIfCmStatusT1Timeouts:0 docsIfCmStatusT2Timeouts:0 docsIfCmStatusT3Timeouts:0 docsIfCmStatusT4Timeouts:0

I can walk all the OIDs though:

Code: Select all

bash-3.00# snmpwalk -v 2c -c public 172.16.10.2  1.3.6.1.2.1.10.127.1.1.1.1
DOCS-IF-MIB::docsIfDownChannelId.3 = INTEGER: 145
DOCS-IF-MIB::docsIfDownChannelFrequency.3 = INTEGER: 567000000 hertz
DOCS-IF-MIB::docsIfDownChannelWidth.3 = INTEGER: 6000000 hertz
DOCS-IF-MIB::docsIfDownChannelModulation.3 = INTEGER: qam256(4)
DOCS-IF-MIB::docsIfDownChannelInterleave.3 = INTEGER: taps32Increment4(5)
DOCS-IF-MIB::docsIfDownChannelPower.3 = INTEGER: -.4 dBmV
DOCS-IF-MIB::docsIfDownChannelAnnex.3 = INTEGER: annexB(4)
bash-3.00# snmpwalk -v 2c -c public 172.16.10.2  1.3.6.1.2.1.10.127.1.1.4.1
DOCS-IF-MIB::docsIfSigQIncludesContention.3 = INTEGER: false(2)
DOCS-IF-MIB::docsIfSigQUnerroreds.3 = Counter32: 1560765262
DOCS-IF-MIB::docsIfSigQCorrecteds.3 = Counter32: 0
DOCS-IF-MIB::docsIfSigQUncorrectables.3 = Counter32: 0
DOCS-IF-MIB::docsIfSigQSignalNoise.3 = INTEGER: 37.8 dB
DOCS-IF-MIB::docsIfSigQMicroreflections.3 = INTEGER: 36 dBc
DOCS-IF-MIB::docsIfSigQEqualizationData.3 = Hex-STRING: 0B 01 10 00 FF FB 00 0C 00 17 FF F4 FF EC 00 13
00 13 FF EC FF FF 00 1C FF D4 FF DF FF E4 00 2B
00 30 FF BF 02 01 00 02 01 00 30 14 30 12 06 0D
2B 06 01 02 01 0A 7F 01 01 04 01 06 03 02 01 24
80 4F E1 D4
DOCS-IF-MIB::docsIfSigQExtUnerroreds.3 = Counter64: 1560769166
DOCS-IF-MIB::docsIfSigQExtCorrecteds.3 = Counter64: 0
DOCS-IF-MIB::docsIfSigQExtUncorrectables.3 = Counter64: 0
bash-3.00# snmpwalk -v 2c -c public 172.16.10.2  1.3.6.1.2.1.10.127.1.2.2.1
DOCS-IF-MIB::docsIfCmStatusValue.2 = INTEGER: operational(12)
DOCS-IF-MIB::docsIfCmStatusCode.2 = STRING: "D3.0"
DOCS-IF-MIB::docsIfCmStatusTxPower.2 = INTEGER: 45.5 dBmV
DOCS-IF-MIB::docsIfCmStatusResets.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusLostSyncs.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusInvalidMaps.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusInvalidUcds.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusInvalidRangingResponses.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusInvalidRegistrationResponses.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusT1Timeouts.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusT2Timeouts.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusT3Timeouts.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusT4Timeouts.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusRangingAborteds.2 = Counter32: 0
DOCS-IF-MIB::docsIfCmStatusDocsisOperMode.2 = INTEGER: docsis11(2)
DOCS-IF-MIB::docsIfCmStatusModulationType.2 = INTEGER: tdma(1)
DOCS-IF-MIB::docsIfCmStatusEqualizationData.2 = Hex-STRING: 04 01 08 00 00 02 FF FF FF FA 00 06 00 0A FF EC
01 FE 00 00 FF FA FF EB 00 05 00 03 FF FC FF FC
00 01 FF FD

Somewhere, something is not pushing the levels and microreflections up.

User avatar
BSOD2600
Cacti Moderator
Posts: 12160
Joined: Sat May 08, 2004 12:44 pm
Location: USA

#62 Post by BSOD2600 » Thu Feb 12, 2009 6:50 pm

Looks like your cable modem violates the ISO standard and is returning TEXT in an INTEGER only field -- would be my guess. Sadly, I can't test this script anymore since I've changed ISPs and can no longer SNMP query my modem (damn you Comcast!).

Anyways, the last line of the ss_docsis_stats.php script needs fixing ($result = is_numeric($var) ....)

Try modifying the script with the following:

Code: Select all

        for ($i=0;$i<(count($oids));$i++) {
                $row = each($oids);
                $var = (cacti_snmp_get($hostname, $snmp_community, $row["value"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));
                preg_match("/(-?\d*\.?\d*)/", $var, $matches);
                $result = is_numeric($matches[1]) ? ($result . $row["key"] . ":" . $var . " ") : ($result . $row["key"] . ":NaN ");
        }

jbarbieri
Cacti User
Posts: 101
Joined: Tue May 24, 2005 8:46 am
Location: Rochester, New Hampshire
Contact:

#63 Post by jbarbieri » Fri Feb 13, 2009 8:11 am

Stupid SB5100s!!

OK I will give that a shot. Thanks!

jbarbieri
Cacti User
Posts: 101
Joined: Tue May 24, 2005 8:46 am
Location: Rochester, New Hampshire
Contact:

#64 Post by jbarbieri » Fri Feb 13, 2009 8:54 am

With the code looking like this:


Code: Select all

        for ($i=0;$i<(count($oids));$i++) {
                $row = each($oids);
                $var = (cacti_snmp_get($hostname, $snmp_community, $row["value"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));
                preg_match("/(-?\d*\.?\d*)/", $var, $matches);
                $result = is_numeric($matches[1]) ? ($result . $row["key"] . ":" . $var . " ") : ($result . $row["key"] . ":NaN ");
        }
I get

Code: Select all

bash-3.00# php /usr/local/cacti/script_server.php
PHP Script Server has Started - Parent is cmd
/usr/local/cacti/scripts/ss_docsis_stats.php ss_docsis_stats 172.16.10.2 public 2 161 500
U

User avatar
BSOD2600
Cacti Moderator
Posts: 12160
Joined: Sat May 08, 2004 12:44 pm
Location: USA

#65 Post by BSOD2600 » Mon Feb 16, 2009 1:47 am

Arg, try this one instead:

Code: Select all

        for ($i=0;$i<(count($oids));$i++) {
                $row = each($oids);
                $var = (cacti_snmp_get($hostname, $snmp_community, $row["value"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));
                preg_match("/(-?\d*\.?\d*)/", $var, $matches);
                $result = is_numeric($matches[1]) ? ($result . $row["key"] . ":" . $matches[1] . " ") : ($result . $row["key"] . ":NaN ");
        }

jbarbieri
Cacti User
Posts: 101
Joined: Tue May 24, 2005 8:46 am
Location: Rochester, New Hampshire
Contact:

#66 Post by jbarbieri » Tue Feb 17, 2009 8:23 am

BSOD2600 wrote:Arg, try this one instead:

Code: Select all

        for ($i=0;$i<(count($oids));$i++) {
                $row = each($oids);
                $var = (cacti_snmp_get($hostname, $snmp_community, $row["value"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));
                preg_match("/(-?\d*\.?\d*)/", $var, $matches);
                $result = is_numeric($matches[1]) ? ($result . $row["key"] . ":" . $matches[1] . " ") : ($result . $row["key"] . ":NaN ");
        }

Heh, fixed the parts I wanted, but now broke the ones that were working


Code: Select all

bash-3.00# php ../script_server.php
PHP Script Server has Started - Parent is cmd
/usr/local/cacti/scripts/ss_docsis_stats.php ss_docsis_stats 172.16.10.2 public 2 161 500
docsIfDownChannelPower:.0 docsIfSigQSignalNoise:38.3 docsIfSigQMicroreflections:36 docsIfCmRangingTimeout:NaN docsIfCmStatusTxPower:44.8 docsIfCmStatusResets:NaN docsIfCmStatusLostSyncs:NaN docsIfCmStatusT1Timeouts:NaN docsIfCmStatusT2Timeouts:NaN docsIfCmStatusT3Timeouts:NaN docsIfCmStatusT4Timeouts:NaN


User avatar
BSOD2600
Cacti Moderator
Posts: 12160
Joined: Sat May 08, 2004 12:44 pm
Location: USA

#67 Post by BSOD2600 » Tue Feb 17, 2009 3:09 pm

Hmm not sure why that would be since the test code I wrote shows it should work...

Code: Select all

<?php
$no_http_headers = true;
$var1 = "-.4 dBmV";
$var2 = "37.8 dB";
$var3 = "36 dBc";
$var4 = "0";
print $var1 . PHP_EOL;
print $var2 . PHP_EOL;
print $var3 . PHP_EOL;
print $var4 . PHP_EOL;
print PHP_EOL;

preg_match("/(-?\d*\.?\d*)/", $var1, $matches1);
preg_match("/(-?\d*\.?\d*)/", $var2, $matches2);
preg_match("/(-?\d*\.?\d*)/", $var3, $matches3);
preg_match("/(-?\d*\.?\d*)/", $var4, $matches4);
print "var1:" . $matches1[1] . PHP_EOL;
print "var2:" . $matches2[1] . PHP_EOL;
print "var3:" . $matches3[1] . PHP_EOL;
print "var4:" . $matches4[1] . PHP_EOL;
?>
-.4 dBmV
37.8 dB
36 dBc
0

var1:-.4
var2:37.8
var3:36
var4:0
Well its a band-aid, but you can change the ($result . $row["key"] . ":NaN ") to ($result . $row["key"] . ":0 ").

jbarbieri
Cacti User
Posts: 101
Joined: Tue May 24, 2005 8:46 am
Location: Rochester, New Hampshire
Contact:

#68 Post by jbarbieri » Tue Mar 03, 2009 2:19 pm

I was able to make a perl script to do this, and it works.

I didn't have to do any kind of regex to get the dbmv out, the perl script only put out the numbers.

jantman
Posts: 21
Joined: Tue Jan 30, 2007 3:13 pm

#69 Post by jantman » Tue Mar 31, 2009 10:55 pm

I just tried this with a Motorola SBV5120 (BOOTR: 8.2; SW_REV: SBV5120-17.5.4-SCM-01-SHPC; MODEL: SBV5120) and Cacti 0.8.7d.

I wasn't getting any data output, and with DEBUG enabled, I was seeing errors like:

Code: Select all

Result from SERVER not valid.  Partial Result: U
It turns out, after adding some instrumentation to the code, that the result ss_docsis_stats was returning was like:

Code: Select all

docsIfDownChannelPower: 75 docsIfSigQSignalNoise: 367 docsIfSigQMicroreflections: 13 docsIfCmRangingTimeout: 20 docsIfCmStatusTxPower: 379 docsIfCmStatusResets: 0 docsIfCmStatusLostSyncs: 0 docsIfCmStatusT1Timeouts: 0 docsIfCmStatusT2Timeouts: 0 docsIfCmStatusT3Timeouts: 0 docsIfCmStatusT4Timeouts: 0
Sure enough, taking a peek at the code (and some more instrumentation), PHP's weak typing was at fault - "$var = (cacti_snmp_get..." was returning a space before the value, and this was still evaluating as true in is_numeric().

I just added

Code: Select all

$var = trim($var);
after setting $var.

I also had to make a few other modifications to the script for 0.8.7d, mainly by manually running from the command line (using the command line output in the debug logs) and getting the arguments right. I believe all I did was add an additional array_shift() if called from the CLI.

User avatar
BSOD2600
Cacti Moderator
Posts: 12160
Joined: Sat May 08, 2004 12:44 pm
Location: USA

#70 Post by BSOD2600 » Wed Apr 01, 2009 3:59 am

Thanks for the info. I tweaked the ss_docsis_stats.php script so others will hopefully have less problems. Sadly, I can't test it anymore.

inf24
Posts: 1
Joined: Mon Feb 14, 2011 2:44 am

Re: DOCSIS Stats

#71 Post by inf24 » Mon Feb 14, 2011 2:53 am

One problem with modem stats usage:
there are no Correct downstream stats - spaces present while get stats
http://radikal.ru/F/i045.radikal.ru/110 ... 2.jpg.html

Image

http://radikal.ru/F/i081.radikal.ru/110 ... e.jpg.html

Image

Where is trouble?
Thank you


p.s.

Here is different modems at same time

http://radikal.ru/F/s52.radikal.ru/i136 ... 0.jpg.html

Image

fbourqui
Posts: 1
Joined: Thu Mar 03, 2011 11:53 pm

Re: DOCSIS Stats

#72 Post by fbourqui » Fri Mar 04, 2011 12:14 am

Hello,
I updated the ss_docsis_stats.php script so that it can work with cacti 0.8.7g with the new cacti_snmp_get() function.
Attachments
docsis-1.2.zip
(10.03 KiB) Downloaded 463 times

bobbomo
Posts: 4
Joined: Fri Oct 26, 2018 8:28 am

Re: DOCSIS Stats

#73 Post by bobbomo » Fri Feb 08, 2019 7:08 pm

Thank you fbourqui, the old ss_docsis_stats.php stopped working after the upgrade from 1.1.38 to 1.2.1, but this fixed it.
fbourqui wrote:Hello,
I updated the ss_docsis_stats.php script so that it can work with cacti 0.8.7g with the new cacti_snmp_get() function.

Post Reply