iar42 / rt-diff

Script for Racktables that sends and archives object changes
0 stars 1 forks source link

Use of undefined constant id #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

noticed your nice script https://github.com/iar42/rt-diff via racktables mailinglist.

Unfortunately I get the following error executing php /opt/rt-diff/bin/rt-diff.php:

PHP Notice:  Use of undefined constant id - assumed 'id' in
/opt/rt-diff/bin/rt-diff.php on line 143
PHP Notice:  Use of undefined constant id - assumed 'id' in
/opt/rt-diff/bin/rt-diff.php on line 162

Beside this I get an email with RackTables changes but only after calling the script manully (Cron doesn't work even if it is set up properly under Debian8.6).

Any ideas?

iar42 commented 7 years ago

Hi and thanks for the feedback.

The PHP Notice was only warning and did not seem to affect functionality but still I have applied a fix for that so please try the newest version.

About the script not sending email via cron I'm not sure what could be happening but cron most often has a limited environment like variables and such. Some ideas: If you are using the rt-diff.cron in a users crontab then you should remove the "root" part from the crontab line. Check in the rt-diff/archive directory if the script is actually updating the archive files (archive/allobj-*) and creating diff files. Check the cron log. You could add "> /tmp/rt-diff.log 2>&1" to the crontab line and check /tmp/rt-diff.log to see if you are getting any output from the script. Check the smtp servers logs if it's getting something when the script is running from cron.

ghost commented 7 years ago

Thank you so much for looking into the issue!

I've deleted /opt/rt-diff/ and installed the new zip according to your manual but unfortunately got other errors this time:

# php /opt/rt-diff/bin/rt-diff.php

[...]

Cannot adopt OID in UCD-SNMP-MIB: ucdSnmpAgent ::= { ucdavis 250 }
Cannot adopt OID in UCD-SNMP-MIB: ucdExperimental ::= { ucdavis 13 }
Cannot adopt OID in UCD-SNMP-MIB: ucdInternal ::= { ucdavis 12 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsModuleEntry ::= {
nsModuleTable 1 }
Cannot adopt OID in UCD-SNMP-MIB: dskErrorMsg ::= { dskEntry 101 }
Cannot adopt OID in UCD-SNMP-MIB: dskErrorFlag ::= { dskEntry 100 }
Cannot adopt OID in UCD-SNMP-MIB: dskUsedHigh ::= { dskEntry 16 }
Cannot adopt OID in UCD-SNMP-MIB: dskUsedLow ::= { dskEntry 15 }
Cannot adopt OID in UCD-SNMP-MIB: dskAvailHigh ::= { dskEntry 14 }
Cannot adopt OID in UCD-SNMP-MIB: dskAvailLow ::= { dskEntry 13 }
Cannot adopt OID in UCD-SNMP-MIB: dskTotalHigh ::= { dskEntry 12 }
Cannot adopt OID in UCD-SNMP-MIB: dskTotalLow ::= { dskEntry 11 }
Cannot adopt OID in UCD-SNMP-MIB: dskPercentNode ::= { dskEntry 10 }
Cannot adopt OID in UCD-SNMP-MIB: dskPercent ::= { dskEntry 9 }
Cannot adopt OID in UCD-SNMP-MIB: dskUsed ::= { dskEntry 8 }
Cannot adopt OID in UCD-SNMP-MIB: dskAvail ::= { dskEntry 7 }
Cannot adopt OID in UCD-SNMP-MIB: dskTotal ::= { dskEntry 6 }
Cannot adopt OID in UCD-SNMP-MIB: dskMinPercent ::= { dskEntry 5 }
Cannot adopt OID in UCD-SNMP-MIB: dskMinimum ::= { dskEntry 4 }
Cannot adopt OID in UCD-SNMP-MIB: dskDevice ::= { dskEntry 3 }
Cannot adopt OID in UCD-SNMP-MIB: dskPath ::= { dskEntry 2 }
Cannot adopt OID in UCD-SNMP-MIB: dskIndex ::= { dskEntry 1 }
Cannot adopt OID in UCD-DISKIO-MIB: diskIOTable ::= { ucdDiskIOMIB 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLoggingGroup ::= {
nsConfigGroups 2 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsDebugGroup ::= {
nsConfigGroups 1 }
Cannot adopt OID in UCD-SNMP-MIB: snmperrErrMessage ::= { snmperrs 101 }
Cannot adopt OID in UCD-SNMP-MIB: snmperrErrorFlag ::= { snmperrs 100 }
Cannot adopt OID in UCD-SNMP-MIB: snmperrNames ::= { snmperrs 2 }
Cannot adopt OID in UCD-SNMP-MIB: snmperrIndex ::= { snmperrs 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsTransactionTable ::= {
nsTransactions 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLogStatus ::= { nsLoggingEntry 5 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLogMaxLevel ::= {
nsLoggingEntry 4 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLogType ::= { nsLoggingEntry 3 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLogToken ::= { nsLoggingEntry 2 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsLogLevel ::= { nsLoggingEntry 1 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendResult ::= {
nsExtendOutput1Entry 4 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutNumLines ::= {
nsExtendOutput1Entry 3 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutputFull ::= {
nsExtendOutput1Entry 2 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutput1Line ::= {
nsExtendOutput1Entry 1 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutLine ::= {
nsExtendOutput2Entry 2 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendLineIndex ::= {
nsExtendOutput2Entry 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyStart ::= {
netSnmpNotifications 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyShutdown ::= {
netSnmpNotifications 2 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyRestart ::= {
netSnmpNotifications 3 }
Cannot adopt OID in UCD-SNMP-MIB: laErrMessage ::= { laEntry 101 }
Cannot adopt OID in UCD-SNMP-MIB: laErrorFlag ::= { laEntry 100 }
Cannot adopt OID in UCD-SNMP-MIB: laLoadFloat ::= { laEntry 6 }
Cannot adopt OID in UCD-SNMP-MIB: laLoadInt ::= { laEntry 5 }
Cannot adopt OID in UCD-SNMP-MIB: laConfig ::= { laEntry 4 }
Cannot adopt OID in UCD-SNMP-MIB: laLoad ::= { laEntry 3 }
Cannot adopt OID in UCD-SNMP-MIB: laNames ::= { laEntry 2 }
Cannot adopt OID in UCD-SNMP-MIB: laIndex ::= { laEntry 1 }
#

The system is running with:

# uname -a
Linux vm-racktables 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2
(2016-10-19) x86_64 GNU/Linux
iar42 commented 7 years ago

Yes, this is most likely because you do not have the snmp package installed on the server. On Ubuntu I did "apt-get install snmp" to fix this. I guess it's the same or very similar on Debian.

ghost commented 7 years ago

Thanks alot @iar42 - apt-get install snmp did it. Initial php /opt/rt-diff/bin/rt-diff.php runs without any errors now. Unfortunately the Cron job still doesn't work. Notification is only sent after manual php /opt/rt-diff/bin/rt-diff.php... this is really strange. The server OS is an almost "vanilla" Debian8x64... just racktables, unattended-upgrades and logwatch.

ghost commented 7 years ago

Got it. Under Debian8 setting the cron job in /opt/rt-diff/rt-diff.cron doesn't work. Couldn't figure out the reason. But crontab -e with following settings work:

*/15 * * * * /usr/bin/php /opt/rt-diff/bin/rt-diff.php

Thanks alot for your support and your great script!