script output loop

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

Moderators: Moderators, Developers

Post Reply
Author
Message
cheinzle
Posts: 4
Joined: Mon Nov 28, 2016 11:02 am

script output loop

#1 Post by cheinzle » Tue Jul 16, 2019 2:17 pm

From the Cacti docs:

"Note: Spine requires, that multiple parameters are spit out by a single “print” statement. Do not print them in a loop! "

Wondering if someone can enlighten me as to why loops don't work?

User avatar
camerabob
Cacti User
Posts: 275
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: script output loop

#2 Post by camerabob » Wed Jul 17, 2019 7:36 am

Not sure, but you could loop an append to a variable instead and just print that variable once all the looping has completed. Simple work around.
See the Cacti 1.x templates I use at: http://www.camerabob.com/cacti

Live: Cacti 1.2.3 @ CentOS 7-6.1810.2.el7 & PHP 5.4.16-46.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Test: Cacti 1.2.4 @ CentOS 7-6.1810.2.el7 & PHP 5.4.16-46.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

cheinzle
Posts: 4
Joined: Mon Nov 28, 2016 11:02 am

Re: script output loop

#3 Post by cheinzle » Wed Jul 17, 2019 8:24 am

I suppose. And for my script that wasn't working (Cacti log indicated that spine was receiving a truncated list of variables) making a single print statement fixed it. My question was fishing for more of a technical reason why spine doesn't like loops.

netniV
Cacti Guru User
Posts: 2666
Joined: Sun Aug 27, 2017 12:05 am

Re: script output loop

#4 Post by netniV » Wed Jul 17, 2019 12:11 pm

The poller expects a single line of output with the value. If you have multiple values, you have to use field:value combinations but they must all be on the same line again.

Post Reply