(Resolved) enable/disable thold from command line?

Support questions about the Threshold plugin

Moderators: Developers, Moderators

User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

(Resolved) enable/disable thold from command line?

Post by _raindrop18 »

Hello All,

thold has Weekend exemptions but not time base like turn off at non business hrs. I have seen this question on the forum all the way back 2006 but didn't see this future yet. may be the developer busy on his life. is that possible enable and disable thold from command line? run php command to start and stop thold?if that work I can setup cronjob to run the command to stop and start. currently manually I am enable and disable from the setting every night not to send any alert. I want to do that option automatically. till this future added. thanks in advance for any suggestion.
Last edited by _raindrop18 on Tue Aug 10, 2010 9:01 am, edited 2 times in total.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

In rough method for Cacti 0.8.7e (at your own risk):

To disable

Code: Select all

% mysql -ucactiuser -pcactiuser -e "UPDATE settings SET value='on' WHERE name='thold_disable_all'" cacti
To enable

Code: Select all

% mysql -ucactiuser -pcactiuser -e "UPDATE settings SET value='' WHERE name='thold_disable_all'" cacti
That simulates clicking 'Disable all thresholds' checkbox in Alerting/Thold tab.
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

thanks a lot about your response although It didn't work. I have tried multiple times but didn't disable/enable thold.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

Post error messages.

NOTICE: '-ucactiuser -pcactiuser' is default username and password for cacti's database.
Use your settings. (see include/config.php)
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

there is no error (on sql or cacti log). the command execute without the problem but nothing change on the hold. yes I did use my sql user name and password. because of the command execute properly. I assume it was
working and waited for hours but thold continue working. I did other way around too. disable from GUI then try to start by using your command to enable but stayed as disable. I am really wondering the command you gave me executed properly but why not do nothing on the thold. thanks again!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

Hmm..
Try this command before and after enabling/disabling from CLI and GUI:

% mysql -uusername -ppassword -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

Does the value change?

I got a idea from these part of thold 0.4.1:

Code: Select all

[thold_functions.php]

432:	// Do not proceed if we have chosen to globally disable all alerts
433:	if (read_config_option('thold_disable_all') == 'on') {
434:		return;
435:	}
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

here is the out put on cli (it's say disabled) but thold keep running not bothered :(

# ./mysql -ucacti -pcacti -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti
+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | |
+-------------------+-------+

so, the sql command working but not affecting the the apps. operation. may be something else should run along with command. because very interested the sql said disabled but how thold keep running? weird.
I am really admire your effort. thanks
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

_raindrop18 wrote:# ./mysql -ucacti -pcacti -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti
+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | |
+-------------------+-------+
When you checked 'Disable all thresholds' in 'Alerting/Thold' tab, is this also the same output ?

If you can manually set the value of 'thold_disable_all' by any other ways (via SQL Buddy, phpMyAdmin, etc.), I hope thold's behavior will be changed..
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

When you checked 'Disable all thresholds' in 'Alerting/Thold' tab, is this also the same output ?
which output? when I checked manually on setting/thold. the thold disabled properly and I didn't get any alert. I am agree it's should work if the sql result say " disable' the thold should disable. but not so far. have you used this command on your system? and is working? thanks again!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

> which output?

Output that MySQL select command shows.

My cacti is 0.8.7e + PIA 2.4 + thold 0.4.1.
When I clicked the checkbox 'Disable all thresholds' in Settings > Alerting/Thold tab and saved,
Image
the database changed as follows:

Code: Select all

% mysql -ucactiuser -pcactiuser -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti
+-------------------+-------+
| name              | value |
+-------------------+-------+
| thold_disable_all | on    |
+-------------------+-------+
And when checkbox is turned off, thold_disable_all is changed to blank.

In addition, paradoxically, when I set 'on' to thold_disable_all, then the checkbox is turned 'checked' in GUI.
(and I set blank value to to thold_disable_all, the checkbox is turned 'unchecked' in GUI)

MySQL update command that I posted first simply emulates this action via CLI...
Both via CLI and GUI, thold's behavior is disabled and enabled properly in my cacti.
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

I have tested on 2 cacti server the result is the same. here is what happen,

1st - disable (checked) thold on "GUI" run the sql command

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti
+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | on |
+-------------------+-------+

2nd - enable (unchecked) thold on "GUI" runthe sql command

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | |
+-------------------+-------+

so everything is working as you said now, let me show you what happen when I run from "CLI
##############################################
1st - disable thold from " cli"
./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

result check=

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | |
+-------------------+-------+

2nd - enable thold from "cli"

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_enable_all'" cacti

result check =

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

+-------------------+-------+
| name | value |
+-------------------+-------+
| thold_disable_all | |
+-------------------+-------+

##########################################
do you see any error on my procuder?

both enable and disable didn't change the value. my Cacti setup is 0.8.7e + PIA 2.5 + thold 0.4.1 + mysql 5.0.67 and running on Solaris 10. your system is on windows? or Unix base OS? I am not sure this is even a factor.
Thanks so very much!!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

Oh...
_raindrop18 wrote:##############################################
1st - disable thold from " cli"
./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_disable_all'" cacti

--snip--

2nd - enable thold from "cli"

./mysql -ucacti2 -pcacti2 -e "SELECT * FROM settings WHERE name='thold_enable_all'" cacti

--snip--
##########################################
Please, please look again carefully at my first post.
The command you typed is not correct.
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

oh..shame on me :( . sorry taking your valuable time!! and thank you so very much about your patient with me!!! it's working perfectly!! you made my day!!!!! :P :P
if you don't mind can I ask you one more question since it's hard to get such help! I have looking for long time if any one modify thold to send snmp trap instead or email for threshold breach. have you tried that? one guy on this forum told me he did for thold v3. but didn't find for v4.1.
this is extra question.
once again thousends thakns to you!!!!!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

> it's working perfectly!! you made my day!!!!! :P :P

I'm glad to hear that.
I have looking for long time if any one modify thold to send snmp trap instead or email for threshold breach. have you tried that? one guy on this forum told me he did for thold v3. but didn't find for v4.1.
Ah, this topic.
Many users talk about sending traps from cacti... That is the interesting theme, but I don't have solutions.
How about this post?
User avatar
_raindrop18
Cacti User
Posts: 194
Joined: Thu Jan 29, 2009 5:52 pm
Location: US

Post by _raindrop18 »

I'll check it! many thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests