Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Fri Feb 22, 2019 5:43 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject:
PostPosted: Thu Feb 12, 2009 4:27 pm 
Offline
Cacti User

Joined: Tue May 24, 2005 8:46 am
Posts: 101
Location: Rochester, New Hampshire
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:
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:
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 6:50 pm 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12154
Location: USA
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:
        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 ");
        }

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 8:11 am 
Offline
Cacti User

Joined: Tue May 24, 2005 8:46 am
Posts: 101
Location: Rochester, New Hampshire
Stupid SB5100s!!

OK I will give that a shot. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 8:54 am 
Offline
Cacti User

Joined: Tue May 24, 2005 8:46 am
Posts: 101
Location: Rochester, New Hampshire
With the code looking like this:



Code:
        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:
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2009 1:47 am 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12154
Location: USA
Arg, try this one instead:

Code:
        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 ");
        }

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 8:23 am 
Offline
Cacti User

Joined: Tue May 24, 2005 8:46 am
Posts: 101
Location: Rochester, New Hampshire
BSOD2600 wrote:
Arg, try this one instead:

Code:
        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:
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



Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 3:09 pm 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12154
Location: USA
Hmm not sure why that would be since the test code I wrote shows it should work...

Code:
<?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;
?>


Quote:
-.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 ").

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 2:19 pm 
Offline
Cacti User

Joined: Tue May 24, 2005 8:46 am
Posts: 101
Location: Rochester, New Hampshire
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 31, 2009 10:55 pm 
Offline

Joined: Tue Jan 30, 2007 3:13 pm
Posts: 21
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:
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:
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:
$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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 3:59 am 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12154
Location: USA
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.

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |


Top
 Profile  
 
 Post subject: Re: DOCSIS Stats
PostPosted: Mon Feb 14, 2011 2:53 am 
Offline

Joined: Mon Feb 14, 2011 2:44 am
Posts: 1
One problem with modem stats usage:
there are no Correct downstream stats - spaces present while get stats
http://radikal.ru/F/i045.radikal.ru/1102/b0/10afeddedbe2.jpg.html

Image

http://radikal.ru/F/i081.radikal.ru/1102/e6/a11e2cf302fe.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/1102/8d/9041dae4c360.jpg.html

Image


Top
 Profile  
 
 Post subject: Re: DOCSIS Stats
PostPosted: Fri Mar 04, 2011 12:14 am 
Offline

Joined: Thu Mar 03, 2011 11:53 pm
Posts: 1
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 439 times
Top
 Profile  
 
 Post subject: Re: DOCSIS Stats
PostPosted: Fri Feb 08, 2019 7:08 pm 
Offline

Joined: Fri Oct 26, 2018 8:28 am
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group