I want to create trigger in zabbix which should get executed when the value for particular item is constant for the period of 5 min.
exa:- If value of item x is 20 and it remained as 20 for 5 min, then trigger should get executed. I don't want to use avg() function since it is uncertain for some of the situations. Does anyone has any idea how to create trigger for above?
Try this: {host:item.min(5m)}={host:item.max(5m)}.
I think you can use
{Java CPU Utilization:item.min(10m)}>90
Here what will happen is when minimum value in last 10min is above 90 then it will trigger. It simply means value of item was constantly above 90 in last 10 min.
I hope it serves your purpose.
Related
I am trying to do some automatic function on MySql.
I need that all arrows of a column named vipdays decrease by 1 on a daily basis.
I mean.. today the values of all arrows of the column vipdays = 30
Tomorrow all values = 29.. next day 28... and I need that this function
be automatic, that works without manually removing 1 day.
I have made some research and found some MySql Scheduler that automate
some functions but can't make it to work.
Any Ideas?
You should create EVENT that is executed once a day and enable scheduler (it is disabled by default).
It should work.
However, do you really want to do this?
You can store expire date in database instead of the number (ex: "DATE_ADD(CURDATE(), INVERVAL 30 DAYS)") and then compare it with CURDATE() to check if it is expired.
I am using c# winforms-MySql Server.
I have 12 values and in every hour I need to select one value from that 12 value list. Timer can easily select the number.
But the problem is I have 5 Terminal where the software is to be installed.
They all will select a value from the list. The value can be same or different.
But I need the select same value for all the terminal. I don't have any client-server facility because any terminal can be open or closed at any time.
Can MySql select a value from a list in every hour without any c# code?
Any concept will be helpful. I don't need any code if you have a problem.
Thanks
A solution can be:
Create a Table with only 1 Column and 1 Row. It will contain, in the single cell, the current synchronized value;
Create a Timer in mySql. You can get some useful infos here;
The Timer makes a Stored Procedure to run;
That Stored Procedure updates the synchronized value;
All the Terminals query the database looking for that value, whenever and however you want: they will always retrieve the a synchronized value.
name_id(INT)(PRIMARY) name(VARCHAR(50)) add_time(DATETIME)
1 stuff 2015-10-22 10:55:41
2 stuff 2015-11-25 14:54:20
I have table main as shown. User can add new stuff into this table.I want a trigger event that:
runs 10 minutes after the new row has been added into main
gets name_id for that new name
I now i need a MySql Event rather than a trigger since i want to wait 10 minutes. However i couldn't understand how i am gonna trigger this new event for a specific row rather than a whole table. Thanks.
You can write a trigger as usual but first call the sleep function, providing the number of seconds to sleep for (600 in your case) as an argument.
I'm creating a database table where rows need to be removed after a set time. That time is defined in minutes by the valid_time cell in that row. I found this answer though I am not sure how I can implement what I need to into it.
Is someone able to tell me how I can implement this time (as minutes) into the event in the previous answer or if it's not possible, another way to do so. Thanks.
Clarification, I have two columns in the table. One is created which is a TIMESTAMP of when the row is created, and the second is valid_time, an integer in minutes of how long the row is valid for.
DELETE FROM table WHERE created < DATE_SUB(NOW(), INTERVAL `valid_time` MINUTE)
You can try to use the MySQL event scheduler and attach a DELETE query to it. That DELETE will be a simple query that will delete all records where current_time is greater that the valid_time/valid_until fields.
You can configure the scheduler to run in a minute/hourly/daily/... basis as you wish to erase the registers.
Check here and here for more information. M0rtiis offered the query example.
I have one col in my database named position used for ordering. However, when some records is deleted, the sequence get messed up. I want to reorder this col when the table is changed(maybe use trigger).
position(old) -> position(new)
1 1
3 2
7 3
8 4
like this.
I think there will not exist equal number even in position(old), because I have already attach some function in PHP to reorder the column when updates occurs. However, when a record is deleted because of the deletion of its parent, function will not be called.
Thanks for help!
If you are using the column just for ordering, you do not need to update column on deletion, because the order will still be correct. And you will save some resources.
But if you really need to update by sequence, look at this answer:
updating columns with a sequence number mysql
I believe (as scrowler wrote) the better way in such case is to update rows from the application, after application deletes the parent record.
If you decide to update it in the application then...
If position = n is deleted, you logic should be set position = position - 1 where position > n
Please note that this will work only if you delete one record at a time from your application and before assuming that before the delete is triggered the data is already in sequence