Zabbix - Problem with count function and external item data - zabbix

Trying to setup Zabbix to show incomming login failures by syslog log files. I try to create an trigger which triggers when the last value occurs in the last 5 minutes of x amount of items.
The following expression is created:
Code:
count(/Syslog server/log[/var/log/failedlogin.log],5m,"like","last(/Syslog server/log[/var/log/failedlogin.log],#0)")>3
Also the following does not work:
Code:
count(/Syslog server/log[/var/log/failedlogin.log],5m,"like","{ITEM.LASTVALUE}")>3
I'm sure the count function works like it should be, when i fill in de variable manually the item does trigger.
But when i try to get a value out of an other items which is containing the data is seems to not work.
Could someone tell me if this is even possible? Thanks and greetings.

Related

Exception: The data validation rule has more items than the limit of 500. Use the "List from a range" criteria instead

I have a google sheet for Competitor backlink Audit. In previous, it was work perfectly. Last day I tried to use my sheet again and this time, it's not worked. It shows the message
Exception: The data validation rule has more items than the limit of
500.Use the "List from a range" criteria instead.
This sheet is working 4 step way.
merging various data using an app script, and it worked perfectly.
filtered merging data using various filter data.
create a data validation, and this step is not worked.
dependent on the 3rd step. So this also not worked.
I tried to fix this, but I can't figure it out.
Here is my sheet URL:
https://docs.google.com/spreadsheets/d/1T2Jsni659wK3m9ZDka875d8wIoNrxYYn55SaKsjPGrc/edit#gid=1602455067
Also, the Code is too long to share
1st URL is the main code set: https://pastebin.pl/view/4f445433
2nd URL is the helper of 1st code: https://pastebin.pl/view/99ccc65e
custom menu here
As the error message says:
You are trying to add too many options to the Dropdown.
If there are more than 500 rows in the sheet which your script tries to use as data validation options - the script will error.
Solution:
Do not use more than 500 options.
You have more values than this - try to break them down into a nested Dropdown e.g. into Main Categories and Sub categories.
Since you do not provide your script or public access to your spreadsheet, I can not give you more details, but make sure that your script does not try to assign more than 500 values for data validation.

zabbix - last 3 values of string

I have an Item scanning for the text in a log file which returns "Up". I want a trigger that if the last 3 times it looks the value isn't "Up" to alert.
Right now I have this:
{Template_App_SWIFT:vfs.file.regexp[D:/tmp/snl_status.log,"^Subsystem Connectivity is *([A-Z][a-z]*)",,9,9,”\1”].str(Up)}=0
However this only captures the most recent value.
{Template_App_SWIFT:vfs.file.regexp[D:/tmp/snl_status.log,"^Subsystem Connectivity is *([A-Z][a-z]*)",,9,9,”\1”].str("Up",#3)}=0
Use the count() trigger function, possibly like so:
count(#3, Up, ne)

Monitor multiple values within one Item in Zabbix

We need to monitor a database table for response time of an action within our system. If the response time is above a threshold, we need to send an alert with details of the action: action_type, action_name, and others.
Is this possible with Zabbix?
I tried creating a Database monitor item with the following sql:
select action_type, action_name, window_title, response_time from db.table order by action_timestamp desc limit 1;
I was hoping that Zabbix would be able to store and display all the fields in the select, but it just gets the first value (for action_type) and not all the fields.
Is there a way to do it with Zabbix? It's pretty much a must for us so if we can't do it we'd have to go with a different monitoring tool.
EDIT: here's the notification syntax from an Action that is created hoping to use multiple values - from multiple items - in a notification sent following a trigger. My question here is, is this the correct syntax? Is my attempt at using multiple items in Item values: below going to work?
Trigger: {TRIGGER.NAME}
Trigger status: {TRIGGER.STATUS}
Trigger severity: {TRIGGER.SEVERITY}
Trigger URL: {TRIGGER.URL}
Item values:
1. Action name: {"Item ##5 Name"} ("Zabbix_server"}:{ITEM.KEY1}): {ITEM.VALUE1}
2. Window type: {"Item ##2 Name"} ("Zabbix_server"}:{ITEM.KEY2}): {ITEM.VALUE2}
Original event ID: {EVENT.ID}
If a query returns more than one column, only the first column is
read.
Reference: https://www.zabbix.com/documentation/2.4/manual/config/items/itemtypes/odbc_checks
=> You can't process more than one value per item out of the box, because Zabbix design. You can still create one item/query per field.
You can use some workarounds (zabbix UserParameter return 2 or more values), but you will hit another limitations.

zabbix regex to trigger for wrong data type

I have an item of type float, but sometimes a string is received in case of error instead of a number. How can I make a trigger regexp to fire in this case?
I have no idea now to check for "wrong data type".
Actually this is by design and what I'm trying to do is this: if the data gathering fails, I send an error message in order to see it on zabbix end.
I tried with nodata(0), but this doesn't seem to work.
In you case zabbix will not store the "wrong" value for the item. And if you don't care what the string is then you can just setup a trigger for "nodata" for the period of your interval. Look in the triggers manual and search for the "nodata".
Edit: scratch that, didn't read the whole question ....
Edit2: if you are certain that this is not working by design and not because your trigger interval misses the data interval, then you can try to catch the unsupported status. There is an open request for the functionality, but you can setup a side script similar to this. Or you can wrap the monitored item on the node into a UserParameter script that reads the value and prints -1 or something if it is not a number. Then proceed with a normal numeric trigger.

Auto update prices in database, mysql

I am currently getting products from one site, storing them in a database, and then having their prices display on another site. I am trying to get the prices from the one site to update daily in my database so the new updated prices can be displayed onto my other site.
Right now I am getting the products using an item number but have to manually go in and update any prices that have changed.
I am guessing I am going to have to use some kind of cronjob but not sure how to do this. I have no experience with cronjobs and am a noob with php.
Any ideas?
Thanks!
I have done some reading on the foreach loop and have written some code. But my foreach loop is only running once for the first item number. The foreach loop runs then goes to the "api.php" page but then stops. It doesn't continually loop for each item number. How do I tell it to go through all of item numbers in my database?
Also if you see anything else wrong in my code please let me know.
Thanks
....
$itemnumber = array("".$result['item_number']."");
foreach ($itemnumber as $item_number) {
echo "<form method=\"post\" action=\"api.php\" name=\"ChangeSubmit\" id=\"ChangeSubmit\">";
echo "<input type=\"text\" name=\"item_number\" value=\"{$item_number}\" />";
echo "<script type=\"text/javascript\">
function myfunc () {
var frm = document.getElementById(\"ChangeSubmit\");
frm.submit();
}
window.onload = myfunc;
</script></form>";
}
}
If you already retrieve the product data from an external site and store it in a local database, updating the prices from the same source should be no problem to you. Just retrieve the data, iterate through it in a foreach loop or similar and update the prices to the database based on the item number.
Once you have created the update script and run it manually, adding it as a cronjob will be as simple as running the command `crontab -e´ and adding this row to execute your script every midnight:
0 0 * * * /usr/local/bin/php /path/to/your/script.php
Don't forget to use the correct path for PHP for your system, running which php in the shell will tell you the path.
If you have cronjob's on your server, it'll be very apparent- You make a PHP script that updates it, and throw it in a daily cronjob.
However, I do it this way:
Method 1: At the beginning of every page request, check the last "update" time (you choose how to store it). If it's been more than a day, do the update and set the "update" time to the current time.
This way, every time someone loads a page and it's been a day since the last update, it updates for them. However, this means it's slower for random users, once a day. If this isn't acceptable, there's a little change:
Method 2: If you need to update (via the above method of checking), start an asyncronous request for the data, handle the rest of the page, flush it to the user, then in a while loop wait until the request finishes and update it.
The downside to method 2 is that the user won't see the updated values, but, the benefit is that it won't be any more of a wait for them.