Subject: [Pkg-cacti-maint] Bug#949545: cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list

From: Jim McNamara <[email-masked]>
Date: Tue, 21 Jan 2020 15:15:02 -0500

Package: cacti
Version: 1.2.2+ds1-2+deb10u2
Severity: normal

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
	Upgraded machine from Stretch to Buster, cacti was upgraded in process from 0.8.8 to 1.2.2.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?
	Any host added through the use of /usr/share/cacti/cli/add_device.php reports success, but the device-id is always 0 and the host never appears either in the web interface or via /usr/share/cacti/cli/add_tree.php --list-hosts

   * What was the outcome of this action?
	++ /usr/share/cacti/cli/add_device.php --template=1 --description=192.168.112.200 --ip=192.168.112.200 --community=public
	+ ADDHOST='Adding 192.168.112.200 (192.168.112.200) as "Generic SNMP-enabled Host" using SNMP vnet-snmp with community "public"
	Success - new device-id: (0)'

	The host is not added, and 0 seems like an odd device-id as they seem to start from 1

   * What outcome did you expect instead?
	
	Host would be added with the next available device-id, that new device-id should be reported by the add-device.php script

*** End of the template - remove these template lines ***

-- System Information:
Debian Release: 10.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-6-amd64 (SMP w/16 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages cacti depends on:
ii  dbconfig-common                           2.0.11+deb10u1
ii  dbconfig-mysql                            2.0.11+deb10u1
ii  debconf [debconf-2.0]                     1.5.71
ii  fonts-dejavu-core                         2.37-1
ii  fonts-dejavu-extra                        2.37-1
ii  fonts-fork-awesome                        1.1.5+ds1-2
ii  javascript-common                         11
ii  libapache2-mod-php                        2:7.3+69
ii  libapache2-mod-php7.0 [libapache2-mod-ph  7.0.33-0+deb9u5
ii  libapache2-mod-php7.3 [libapache2-mod-ph  7.3.11-1~deb10u1
ii  libjs-c3                                  0.4.11+dfsg-2
ii  libjs-chart.js                            2.7.3+dfsg-5
ii  libjs-d3                                  3.5.17-2
ii  libjs-jquery                              3.3.1~dfsg-3
ii  libjs-jquery-colorpicker                  1.2.17-1
ii  libjs-jquery-cookie                       12-1.1
ii  libjs-jquery-hotkeys                      0~20130707+git2d51e3a9+dfsg-2
ii  libjs-jquery-jstree                       3.3.7+dfsg1-1
ii  libjs-jquery-metadata                     12-1.1
ii  libjs-jquery-tablesorter                  1:2.31.1+dfsg1-1
ii  libjs-jquery-timepicker                   1.2-1
ii  libjs-jquery-ui                           1.12.1+dfsg-5
ii  libjs-jquery-ui-theme-smoothness          1.12.1+dfsg-1
ii  libjs-jquery-ui-theme-south-street        1.12.1+dfsg-1
ii  libjs-jquery-ui-theme-ui-darkness         1.12.1+dfsg-1
ii  libjs-jquery-ui-touch-punch               0.0~git20141218.2.4bc0091+dfsg1-2
ii  libphp-phpmailer                          6.0.6-0.1
ii  perl                                      5.28.1-6
ii  php-gd                                    2:7.3+69
ii  php-gmp                                   2:7.3+69
ii  php-ldap                                  2:7.3+69
ii  php-mbstring                              2:7.3+69
ii  php-mysql                                 2:7.3+69
ii  php-php-gettext                           1.0.12-0.1
ii  php-phpseclib                             2.0.14-1
ii  php-snmp                                  2:7.3+69
ii  php-twig                                  2.6.2-2
ii  php-xml                                   2:7.3+69
ii  php7.0-cli [php-cli]                      7.0.33-0+deb9u5
ii  php7.0-json [php-json]                    7.0.33-0+deb9u5
ii  php7.0-mbstring [php-mbstring]            7.0.33-0+deb9u5
ii  php7.0-snmp [php-snmp]                    7.0.33-0+deb9u5
ii  php7.0-xml [php-xml]                      7.0.33-0+deb9u5
ii  php7.3-cli [php-cli]                      7.3.11-1~deb10u1
ii  php7.3-gd [php-gd]                        7.3.11-1~deb10u1
ii  php7.3-gmp [php-gmp]                      7.3.11-1~deb10u1
ii  php7.3-json [php-json]                    7.3.11-1~deb10u1
ii  php7.3-ldap [php-ldap]                    7.3.11-1~deb10u1
ii  php7.3-mbstring [php-mbstring]            7.3.11-1~deb10u1
ii  php7.3-snmp [php-snmp]                    7.3.11-1~deb10u1
ii  php7.3-xml [php-xml]                      7.3.11-1~deb10u1
ii  rrdtool                                   1.7.1-2
ii  snmp                                      5.7.3+dfsg-5
ii  ucf                                       3.0038+nmu1

Versions of packages cacti recommends:
ii  apache2 [httpd]                             2.4.38-3+deb10u3
ii  default-mysql-server                        1.0.5
ii  iputils-ping                                3:20180629-2
ii  logrotate                                   3.14.0-4
ii  mariadb-server-10.3 [virtual-mysql-server]  1:10.3.18-0+deb10u1

Versions of packages cacti suggests:
pn  cacti-spine  <none>
pn  moreutils    <none>
ii  snmpd        5.7.3+dfsg-5

-- debconf information:
  cacti/app-password-confirm: (password omitted)
  cacti/mysql/admin-pass: (password omitted)
  cacti/mysql/app-pass: (password omitted)
  cacti/password-confirm: (password omitted)
  cacti/database-type: mysql
* cacti/dbconfig-upgrade: true
  cacti/purge: false
  cacti/dbconfig-reinstall: false
  cacti/db/app-user: cacti@localhost
  cacti/upgrade-backup: true
  cacti/install-error: abort
* cacti/mysql/admin-user: debian-sys-maint
* cacti/dbconfig-install: true
  cacti/internal/reconfiguring: false
  cacti/remote/port:
  cacti/upgrade-error: abort
* cacti/webserver: apache2
  cacti/passwords-do-not-match:
  cacti/mysql/method: Unix socket
  cacti/missing-db-package-error: abort
  cacti/remote/newhost:
  cacti/dbconfig-remove:
  cacti/db/dbname: cacti
  cacti/remote/host: localhost
  cacti/remove-error: abort
  cacti/internal/skip-preseed: false

---

From: Paul Gevers <[email-masked]>
Date: Tue, 21 Jan 2020 21:48:58 +0100

Control: tags -1 moreinfo

Hi Jim,

Thanks for reporting issues you encounter.

> 	Host would be added with the next available device-id, that new device-id should be reported by the add-device.php script

I found this upstream report: https://github.com/Cacti/cacti/issues/3111
Can you check your cacti.log for errors and see if the issue matches?

Paul

---

From: "Debian Bug Tracking System" <[email-masked]>
Date: Tue, 21 Jan 2020 20:51:05 +0000

Processing control commands:

> tags -1 moreinfo
Bug #949545 [cacti] cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
Added tag(s) moreinfo.

-- 
949545: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949545
Debian Bug Tracking System
Contact [email-masked] with problems

---

From: Jim McNamara <[email-masked]>
Date: Tue, 21 Jan 2020 16:18:19 -0500

> Thanks for reporting issues you encounter.

You're most welcome, thank you for maintaining software I've found
tremendously useful over the last 15 years.

> >       Any host added through the use of
> /usr/share/cacti/cli/add_device.php reports success, but the device-id is
> always 0 and the host never appears either in the web interface or via
> /usr/share/cacti/cli/add_tree.php --list-hosts
> >
> >       ++ /usr/share/cacti/cli/add_device.php --template=1
> --description=192.168.112.200 --ip=192.168.112.200 --community=public
> >       + ADDHOST='Adding 192.168.112.200 (192.168.112.200) as "Generic
> SNMP-enabled Host" using SNMP vnet-snmp with community "public"
> >       Host would be added with the next available device-id, that new
> device-id should be reported by the add-device.php script
>

That is precisely my issue, thank you. The error when trying to add my host
shows that net-snmp was being provided as the snmp_version -

01/21/2020 14:44:50 - DBCALL ERROR: SQL Save Failed for Table 'host'.
SQL:'INSERT INTO host (`id`, `host_template_id`, `poller_id`, `site_id`,
`external_id`, `description`, `hostname`, `notes`, `location`,
`snmp_version`, `snmp_community`, `snmp_username`, `snmp_password`,
`snmp_auth_protocol`, `snmp_priv_passphrase`, `snmp_priv_protocol`,
`snmp_context`, `snmp_engine_id`, `snmp_port`, `snmp_timeout`, `disabled`,
`availability_method`, `ping_method`, `ping_port`, `ping_timeout`,
`ping_retries`, `max_oids`, `device_threads`) VALUES (267, 1, 1, 1, '',
'192.168.112.200', '192.168.112.200', '', '', net-snmp, 'public', '', '',
'', '', '', '', '', 161, 500, '', 1, 1, 23, 400, 1, 10, 1) ON DUPLICATE KEY
UPDATE `host_template_id`=VALUES(`host_template_id`),
`poller_id`=VALUES(`poller_id`), `site_id`=VALUES(`site_id`),
`external_id`=VALUES(`external_id`), `description`=VALUES(`description`),
`hostname`=VALUES(`hostname`), `notes`=VALUES(`notes`),
`location`=VALUES(`location`), `snmp_version`=VALUES(`snmp_version`),
`snmp_community`=VALUES(`snmp_community`),
`snmp_username`=VALUES(`snmp_username`),
`snmp_password`=VALUES(`snmp_password`),
`snmp_auth_protocol`=VALUES(`snmp_auth_protocol`),
`snmp_priv_passphrase`=VALUES(`snmp_priv_passphrase`),
`snmp_priv_protocol`=VALUES(`snmp_priv_protocol`),
`snmp_context`=VALUES(`snmp_context`),
`snmp_engine_id`=VALUES(`snmp_engine_id`), `snmp_port`=VALUES(`snmp_port`),
`snmp_timeout`=VALUES(`snmp_timeout`), `disabled`=VALUES(`disabled`),
`availability_method`=VALUES(`availability_method`),
`ping_method`=VALUES(`ping_method`), `ping_port`=VALUES(`ping_port`),
`ping_timeout`=VALUES(`ping_timeout`),
`ping_retries`=VALUES(`ping_retries`), `max_oids`=VALUES(`max_oids`),
`device_threads`=VALUES(`device_threads`)'

Redoing the call to add and including --version=1 solves things in the
short term:

./add_device.php --template=1 --description=192.168.112.200
--ip=192.168.112.200 --community=public --version=1
Adding 192.168.112.200 (192.168.112.200) as "Generic SNMP-enabled Host"
using SNMP v1 with community "public"
Success - new device-id: (267)

Thanks again, sorry I missed the upstream bug.

Jim

---

From: Paul Gevers <[email-masked]>
Date: Tue, 21 Jan 2020 22:43:22 +0100

Control: forwarded -1 https://github.com/Cacti/cacti/issues/3111
Control: tags -1 - moreinfo

Hi Jim,

> tremendously useful over the last 15 years.

YW.

> That is precisely my issue, thank you. The error when trying to add my
> host shows that net-snmp was being provided as the snmp_version -

[...]

> Thanks again, sorry I missed the upstream bug.

No problem. Do you agree that this doesn't warrant an update in buster?
With the update it would generate an error (instead of "fixing" the
situation), but that's nicer than nothing happening.

Paul

---

From: "Debian Bug Tracking System" <[email-masked]>
Date: Tue, 21 Jan 2020 21:45:05 +0000

Processing control commands:

> forwarded -1 https://github.com/Cacti/cacti/issues/3111
Bug #949545 [cacti] cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
Set Bug forwarded-to-address to 'https://github.com/Cacti/cacti/issues/3111'.
> tags -1 - moreinfo
Removed tag(s) moreinfo.

---

From: Jim McNamara <[email-masked]>
Date: Tue, 21 Jan 2020 16:49:31 -0500

On Tue, Jan 21, 2020 at 4:43 PM Paul Gevers <[email-masked]> wrote:

> []

> I agree that it doesn't merit an update exclusively to fix this issue, but
I do think it would be a practical to include the error generation whenever
the next update happens.

Paul

---

From: "Debian Bug Tracking System" <[email-masked]>
Date: Thu, 13 Feb 2020 19:36:04 +0000

Your message dated Thu, 13 Feb 2020 20:33:43 +0100
with message-id <[email-masked]>
and subject line Re: Bug#949545: cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
has caused the Debian Bug report #949545,
regarding cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email-masked]
immediately.)

Subject: cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
From: Jim McNamara <[email-masked]>
To: Debian Bug Tracking System <[email-masked]>
Date: Tue, 21 Jan 2020 15:15:02 -0500

Package: cacti

Dear Maintainer,

	

-- System Information:
Debian Release: 10.2

-- debconf information:

Subject: Re: Bug#949545: cacti: cli/add_device.php reports success but device-id is 0 and never appears in the host list
From: Paul Gevers <[email-masked]>
To: Jim McNamara <[email-masked]>, [email-masked]
Date: Thu, 13 Feb 2020 20:33:43 +0100

Version: 1.2.8+ds1-1

Hi Jim,

This e-mail is to teach the BTS that this bug is fixed in the version in
unstable and testing.

On 21-01-2020 22:49, Jim McNamara wrote:
> I agree that it doesn't merit an update exclusively to fix this issue,
> but I do think it would be a practical to include the error generation
> whenever the next update happens.  

Nearly all of the uploads of cacti to (old-)stable are handled by the
security team as security updates and this fix wouldn't really be
appropriate for security uploads. If an upload happens that doesn't go
via the security archive, I'll try to get this fix in.

Paul