[SOLVED]How to use the "Status Change Command" in Cacti settings

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]How to use the "Status Change Command" in Cacti settings

Post by eholz1 »

Greetings Cacti users,lovers, and developers:
I want to create a file that has ONLY device IP, device Name, and device status = up or down

I have discovered what may be a very useful feature in Cacti - in settings/Alerting/Thold called "Status Change Command"
I created a small script that sends and email if something happens setting the path to the email script. As shown below:
cacti_command.JPG
cacti_command.JPG (12.29 KiB) Viewed 391 times
If a device goes down or up - I get an email, but :
How can I create a script to access some of the variables listed in the rollover tip, like: <THOLD_HOSTNAME>,<THOLD_DESCRIPTION>,<THOLD_DOWNUP>, etc?

eholz1
Cacti user since 1.1.18
Last edited by eholz1 on Fri Oct 14, 2022 12:20 pm, edited 1 time in total.
eholz1
Cacti User
Posts: 254
Joined: Mon Oct 01, 2018 10:09 am

Re: How to use the "Status Change Command" in Cacti settings

Post by eholz1 »

Help please The Witness?? I have found this post:https://github.com/Cacti/plugin_thold/issues/372
Which is very very close to what I want: and this reply from TheWitness:
cacti_witness.JPG
cacti_witness.JPG (15.82 KiB) Viewed 385 times
I can get the vars in the test.out file, is there a way to use env in a script to get
certain variables? ;ole THOLD_HOSTNAME. THOLD_DATE etc

Please advise,
eholz1
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: How to use the "Status Change Command" in Cacti settings

Post by TheWitness »

Yes, this is primarily a shell scripting training issue. Depending on your language, you can reference the environment variables in your scripts...

bash, csh, zcsh, etc...

Variable name STUFF
Value is $STUFF

Perl

Variable name STUFF
Value is $ENV{'STUFF'}

PHP

Variable name STUFF
Value is getenv('STUFF')

It goes on and on for each of your preferred languages. Easy stuff actually. You'll figure it out.
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?
eholz1
Cacti User
Posts: 254
Joined: Mon Oct 01, 2018 10:09 am

Re: How to use the "Status Change Command" in Cacti settings

Post by eholz1 »

Greetings The Witness and others,

Thanks for this - got it a little simpler now.

Thanks for clarificaiton,

eholz1
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests