Running external commands from a threshold
Moderators: Developers, Moderators
Running external commands from a threshold
hey.. from what i understand, you can use thold and syslog to POSSIBLY invoke an external command? is that correct? if so, any tips on setting it up?
what im really after right now is having cacti detect a service has stopped on a client, and then restart it, and alert us... is that at all possible?
im running cacti 1.2.22 on a windows server
what im really after right now is having cacti detect a service has stopped on a client, and then restart it, and alert us... is that at all possible?
im running cacti 1.2.22 on a windows server
- TheWitness
- Developer
- Posts: 16897
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Re: Running external commands from a threshold
Thold supports a Warning Command, Alert Command, and Restoral Command. You simply pass in an executable path, and then in the script, you can read all the alert details in variables labeled "THOLD*" in the environment of the script. It's pretty strait forward once you get the hang of it.
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?
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?
Re: Running external commands from a threshold
thanks.. in thold, i dont see a place to put in an executable should the thold be breached.
Re: Running external commands from a threshold
You may be running an old version.
Before history, there was a paradise, now dust.
Re: Running external commands from a threshold
currently running v 1.6
- TheWitness
- Developer
- Posts: 16897
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Re: Running external commands from a threshold
Look at the Threshold Template...
- Attachments
-
- TholdCommands.png (37.68 KiB) Viewed 1057 times
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?
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?
Re: Running external commands from a threshold
thanks for that.. do the commands\script i want to run have to live in the thold directory on the cacti server, or somewhere on the target system?
- TheWitness
- Developer
- Posts: 16897
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Re: Running external commands from a threshold
Everything path in that page is Cacti centric, if you want to run a command on a foreign host, SSH is your best option using a private key or whatever.
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?
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?
Re: Running external commands from a threshold
when you say cacti centric.. do you mean the commands and\or batch files and\or scripts need to reside somewhere on the cacti server for me to fire them off?TheWitness wrote: ↑Wed Dec 07, 2022 7:07 pm Everything path in that page is Cacti centric, if you want to run a command on a foreign host, SSH is your best option using a private key or whatever.
for example.. i have a server that im monitoring a service.. i get an alert when its not running, i want to fire off some type of command to remotely restart that service. can this be done?
Re: Running external commands from a threshold
Through ssh, yes.
Before history, there was a paradise, now dust.
Re: Running external commands from a threshold
hmm.. gonna have to figure that part out.
Re: Running external commands from a threshold
im still trying to get this working.
i have a server, and im monitoring the spooler service.
when its down, i want it to email me(it does)
then fire off this command
sc \\servername start spooler
ive verified i can run that command by hand, and via a batch file OUTSIDE of cacti so the command and syntax is good.
on my threshold for the low trigger warning i have this is that box
./service.bat
i have that bat file in both the thold plug in dir and the cacti root dir.
my cacti server is running on windows. i know im doing something wrong but I need a guide here if possible.
i have a server, and im monitoring the spooler service.
when its down, i want it to email me(it does)
then fire off this command
sc \\servername start spooler
ive verified i can run that command by hand, and via a batch file OUTSIDE of cacti so the command and syntax is good.
on my threshold for the low trigger warning i have this is that box
./service.bat
i have that bat file in both the thold plug in dir and the cacti root dir.
my cacti server is running on windows. i know im doing something wrong but I need a guide here if possible.
- TheWitness
- Developer
- Posts: 16897
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Re: Running external commands from a threshold
Windows "may" be a problem. First make sure that the account that Cacti scheduled task is running as can also run these commands. Second, if your binary includes a path with spaces, make sure you quote it. Lastly, you can add some additional tracing into where the command is being executed in thold.
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?
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?
Re: Running external commands from a threshold
ok i just changed my bat file to be
C:\Windows\System32\sc.exe \\<HOSTNAME> start spooler
im currently waiting to see if this works.
C:\Windows\System32\sc.exe \\<HOSTNAME> start spooler
im currently waiting to see if this works.
Re: Running external commands from a threshold
so far .. no joy on the burn.
i killed the service i was monitoring.. cacti did email me.. so i know the threshold is working.. but the command didnt fire.
i have it set on that threshold, for the low trigger to run
./service.bat im HOPING thats correct.
i put that file in the scripts folder on cacti
in that bat file is
C:\Windows\System32\sc.exe \\<HOSTNAME> start spooler ( as spooler is the service im monitoring)
ran outside of cacti, that works, but you substitute <HOSTNAME> with the name of the actual server.
Again, I may be doing this totally wrong, which is why I am asking for some education on the subject. getting this going will go a LONG way in cacti adoption at my employer..
i killed the service i was monitoring.. cacti did email me.. so i know the threshold is working.. but the command didnt fire.
i have it set on that threshold, for the low trigger to run
./service.bat im HOPING thats correct.
i put that file in the scripts folder on cacti
in that bat file is
C:\Windows\System32\sc.exe \\<HOSTNAME> start spooler ( as spooler is the service im monitoring)
ran outside of cacti, that works, but you substitute <HOSTNAME> with the name of the actual server.
Again, I may be doing this totally wrong, which is why I am asking for some education on the subject. getting this going will go a LONG way in cacti adoption at my employer..
Who is online
Users browsing this forum: No registered users and 1 guest