[SOLVED]Cacti Environment Variables - Python - How to Get

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
eholz1
Cacti User
Posts: 254
Joined: Mon Oct 01, 2018 10:09 am

[SOLVED]Cacti Environment Variables - Python - How to Get

Post by eholz1 »

Hello Forum Members,
I would like to access the cacti environment variables.
I can do this easily in a bash script via the export command.

I have seen get and set for python, which works for the environment of a virtual machine (like HOSTNAME, etcx)

But so far I have not figured out how to get the cacti vars with python.
I run the bash script from the "Alerting/Threshold" tab.

Thanks,
eholz1
Last edited by eholz1 on Fri Nov 11, 2022 2:37 pm, edited 1 time in total.
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Cacti Environment Variables - Python - How to Get

Post by Osiris »

What cacti vars?
Before history, there was a paradise, now dust.
eholz1
Cacti User
Posts: 254
Joined: Mon Oct 01, 2018 10:09 am

Re: Cacti Environment Variables - Python - How to Get

Post by eholz1 »

I am using cacti-1.2.21 at the present time

THOLD_SNMP_HOSTNAME,
#export THOLD_HOSTNAME
#export THOLD_DATE
#export THOLD_SNMP_HOSTNAME
#export THOLD_SNMP_LOCATION
#export THOLD_DOWNUP
#export THOLD_DESCRIPTION

etc, but figured it out. Just in case someone has same question: here is what I did
create a python program to use the "get.os" environ imported the os module to my python program.
added the #!/usr/bin/local/python line to top of script, the made the program executable i.e. chmod 755 for linux.

put the program name the the "Thold/Alerting" area.
Presto Changeo - got the variables

thanks for a great product
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: [SOLVED]Cacti Environment Variables - Python - How to Get

Post by TheWitness »

Cool. Every little step works one from apprentice to journeyman.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests