I created a external check that returns a value formatted like :
File System Storage Percent:12.34
Is that possible to create a trigger that check if the value > 50% ?
{my_host:my_external_check.py.str(File System Storage Percent:50.00)}=1
I saw that regexp exists but it does not return the value found.
Change your script to return the value without the extra text - like 12.34. Then you can use the usual Zabbix trigger functions last(), min(), avg(), max() and others.
Related
I want to do some activity in an ADF pipeline, but only if a field in a JSON output is present. What kind of ADF expression can I use to check that?
I set up two json files for testing, one with a firstName attribute and one without:
I then created a Lookup activity to get the contents of the JSON file and a Set Variable activity for testing the expression. I often use these to test expressions and it's a good way to test and view expression results iteratively:
I then created a Boolean variable (which is one of the datatypes supported by Azure Data Factory and Synapse pipelines) and the expression I am using to check the existence of the attribute is this:
#bool(contains(activity('Lookup1').output.firstRow, 'firstName'))
You can then use that boolean variable in an If activity, to execute subsequent activities conditionally based on the value of the variable.
thank you for reading.
I use DBeaver tool for modifying functions made by pqsql.
But, when i modify the function.
Always, i need to set up the source of the return type.
For example,
i have a schema "test", then this is the create sql.
there is a data type "type_getdata" and, the function name is "getdata"
CREATE OR REPLACE FUNCTION test.getdata(p_userid "varchar")
RETURNS SETOF test.type_getdata
LANGUAGE plpgsql
VOLATILE
AS $$
then when i want to change the function.
i choose the button "View Function".
then, the data type is missing. like as follows:
CREATE OR REPLACE FUNCTION test.getdata(p_userid "varchar")
RETURNS SETOF type_getdata
LANGUAGE plpgsql
VOLATILE
AS $$
So, if i have some change, i need to modify "type_getdata" to "test.type_getdata"
is there any ways to solve this problem?
Thanks
That is not a problem, it is Postgres design. And it has nothing with returning setof.
When you login you get a default SEARCH PATH. The setting determines the available schemas and the order they are searched when database objects are referenced and NOT fully qualified. What is happening is the schema TEST is not in your search path, and you are being forced (by Postgtes not DBeaver) to specify the fully qualified. To see your current search path run
show search_path;
You can change this at the session level by changing with set command, assuming your current path is "$user",public you may want something like
set search_path="$user",public,test;
That last only for the current session, see your DBA for a permanent change. But be careful, if anyone later creates type_getdata in PUBLIC (or any other database object with corresponding name as in test) then you will use/change that one not the one in TEST.
In a multiple schema environment you are much better off using a fully qualified names. I.E. test.getdata(...) As you are also doing with your function name.
I use Firebird 2.5, and I want to retrieve the following values
Username:
I used SELECT rdb$get_context('SYSTEM', 'CURRENT_USER') FROM ...
Database name:
I used SELECT rdb$get_context('SYSTEM', 'DB_NAME') FROM ...
But for server name, I did not find any client API, do you know how can I retrieve the server name with a SELECT statement.
There is nothing built-in in Firebird to obtain the server host name (or host names, as a server can have multiple host names) through SQL.
The closest you can get is by requesting the isc_info_firebird_version information item through the isc_database_info API function. This returns version information that - if connecting through TCP/IP - includes a host name of the server.
But as your primary reason for this is to discern between environments in SQL, it might be better to look for a different solution. Some ideas:
Use an external table
You can create an external table to contain the environment information you need
In this example I just put in a short, fixed width name for the environment types, but you could include other information, just be aware the external table format is a binary format. When using CHAR it will look like a fixed width format, where values shorter than declared need to be padded with spaces.
You can follow these steps:
Configure ExternalFileAccess in firebird.conf (for this example, you'd need to set ExternalFileAccess = Restrict D:\data\DB\exttables).
You can then create a table as
create table environment
external file 'D:\data\DB\exttables\environment.dat' (
environment_type CHAR(3) CHARACTER SET ASCII NOT NULL
)
Next, create the file D:\data\DB\exttables\environment.dat and populate it with exactly three characters (eg TST for test, PRO for production, etc). You can also insert the value instead, the external table file will be created automatically. Inserting might be simpler if you want more columns, or data with varying length, etc. Just keep in mind it is binary, but using CHAR for all columns will make it look like text.
Do this for each environment, and make sure the file is read-only to avoid accidental inserts.
After this is done, you can obtain the environment information using
select environment_type
from environment
You can share the same file for multiple databases on the same host, and external files are - by default - not included in a gbak backup (they are only included if you apply the -convert backup option), so this would allow moving database between environments without dragging this information along.
Use an UDF or UDR
You can write an UDF (User-Defined Function) or UDR (User Defined Routine) in a suitable programming language to return the information you want and define this function in your database. Firebird can then call this function from SQL.
UDFs are considered deprecated, and you should use UDRs - introduced in Firebird 3 - instead if possible.
I have never written an UDF or UDR myself, so I can't describe it in detail.
I have one item extracted from a JMX interrogation and I want to compare it against another one extracted from a database. These values shouldn't be equal but first one should contain/include the second - if not then I need an alert.
Obviously I tried with str() function but this one doesn't accept an {item.last} as parameter for the V string:
{node1:ITEM1.str({node2:ITEM2.last()})}=0
Any other idea?
That is currently not possible with the built-in functionality. While it might be possible in Zabbix 3.4, that is not fully clear yet. Please also note that only numeric values can be compared in the Zabbix trigger expressions.
Since PostgreSQL 9.1 enum values can be added using
ALTER TYPE my_type ADD VALUE new_value;
However, trying to run this as part of a bigger script gives an error:
ALTER TYPE ... ADD cannot be executed from a function or multi-command string
This makes it a real hassle to script changes to be applied in production, because support staff have to remember that, while most scripts can be run "normally", there are a few "special" scripts that need to be opened in pgAdmin and run manually, piece by piece. I've Googled this and I understand the limitation - enum values cannot be added inside a transaction or part of a "multi-command string". That's OK. I don't need to do that. I just want to add multiple enum values and execute other, unrelated, SQL statements without having to feed Postgres one statement at a time.
In other words: I want to be able to run a single script, both from pgAdmin and from psql, that simply does the same thing that pgAdmin does when I highlight one line at a time and press F5 (run). Is there a way to do this, maybe with plpgsql?
Looks like this will finally be fixed in PostgreSQL 12.
https://www.postgresql.org/docs/12/sql-altertype.html says
If ALTER TYPE ... ADD VALUE (the form that adds a new value to an enum type) is executed inside a transaction block, the new value cannot be used until after the transaction has been committed.