Zabbix: expand macros in the name of the trigger, when retrieving events - zabbix

I use event.get to retrieve events, and provide selectRelatedObject parameter to get what in my case is the corresponding triggers. The description for that trigger may contain macros, which arrive in non-expanded form. I haven't found any additional parameter I can provide to event.get to get these macros expanded.
Yes, I can call trigger.get with expandDescription on that particular trigger, but this will require sending additional request to Zabbix server.
So the question is: is it possible to get events with macros expanded for the corresponding triggers, with a single request? Thanks.

Unfortunately, that is not possible currently. A closely related feature request is https://support.zabbix.com/browse/ZBXNEXT-2768 - it is not completely clear whether it would result in a different value expansion support, or name expansion support for event.get.

Related

How do I filter out step count that user input manually from Google Fitness REST API

I can now retrieve step count data from Google Fitness REST API.
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
However, I can't tell which data is reliable (data not generate by user input).
After some research I found there is a orginalDataSourceId in document
https://developers.google.com/fit/rest/v1/reference/users/dataSources/datasets#resource
But the description say
WARNING: do not rely on this field for anything other than debugging. The value of this field, if it is set at all, is an implementation detail and is not guaranteed to remain consistent.
So I really don't know how to do. How do I filter out step count that user input manually from Google Fitness REST API?
I found a solution now. The originDataSourceId of dataset is not reliable when you get by aggregate. (You may get data that merged from differnt source)
So you can get the data source list first.
https://developers.google.com/fit/rest/v1/reference/users/dataSources/list
You can filter the Data Source by dataTypeName, device, ... etc.
Then you can use the dataStreamId of the Data Source as dataSourceId to aggregate data.
https://developers.google.com/fit/rest/v1/reference/users/dataset/aggregate
(aggregateBy)

GAS-built telegram bot: catching replies to bot

I wrote an bot on GAS to read from / write to a google sheet from telegram. I use the webhook method. I can address the bot with /read <args> and /write <args>. However, the less tech-savvy are not able to understand the principle of arguments...
So I want to make a conversational bot, like botfather. eg, if /read or /write are sent, then the bot ask in pm for the arguments, one by one.
The "reply in PM" part is easy, but I don't see how I can catch replies for arguments?
As far as I understand, the function doPost is called each time a command is sent to the bot which poses issues of interactivity, and requiring a slash-something command to run the script instead of a plain text reply (and as the GAS data is volatile, the ugly work-around of storing a variable to know the bot should do the 2nd action is impossible too).
Is it feasible with webhook method?
Should I switch to polling / getUpdates method? I'm guessing it could work that way, with a time-out to exit the script in case of no reply, but I'm also guessing the PM chat should be set to 'no privacy' mode. or maybe it is intrinsic to the bot?
Any help appreciated!
So, GAS does offer a not-so volatile storage: CacheService.getScriptCache() (see also https://developers.google.com/apps-script/reference/cache/cache)
The principle is simple: store the variable you want persistent in the cache (optionally, set a time out too - the default is 10min), and get the values when the script is called again. I found out that project that helped me understand how to use it: https://github.com/Milleus/tessara/blob/master/Code.gs
In a few words: the syntax is cache.put(key, value) to store the value, and value=cache.get(key) to fetch it back.
The beauty of it is that all required variables (if more than one) can be stored in an object, the key can be a unique identifier for the "user", and the value is the stringified object.
In my case, I was able to build a fully conversational telegram bot (exactly like BotFather, but for my usage). Using the id from the person sending messages to the bot as the key, the script can run in "parallel" for multiple users at once.
The doGet and doPost are the functions that get called when you follow a web app url. You can use them as an api if you use something like UrlFetchApp to access them or even an Http Request if you can handle the oauth.

Generate a code to each respondent after completing a form

I am conducting a survey among students and I want to measure their attitudes on the beginning and end of the semester.
However, I want the survey to be anonymous.
My question is: Is it possible to create a script in Google Forms which will generate a unique code for each respondent, save that code in the Google Sheets alongside the responses and most importantly, provide the respondent with the code so that in the next round of survey, he/she can insert the code so that I can link the responses from the two surveys.
Thank you so much for all the help!
Yes, you can achieve this with Apps Script. The workflow for getting such functionallity would be as follows:
Using Form Service every time a response is submitted generate a random number. If you want to track your codes so that two users don't end up with the same code (highly unlikely but possible) then store your codes with the responses in the Spreadsheet linked to your form using the Spreadsheet Service, specifically take a look at the methods for getting and setting values in a specific range. You can then compare your generated random number with the codes you already have and if it matches any generate a new random number and check again.
Either send this random number by email using Gmail Service or, in case it has to be completely anonymous set the submit message to display your code.
Then for providing a different form if the user already has an access code you can simply ask the user at the beggining of the form whether they have a code or they dont and depending on that redirect them to the section of the form that you wish. To verify this code you could then on the form response compare his code with the list of codes you already have to verify that this user actually did complete the form previously.
This generally takes several services working in tandem. However, an easy solution might be to have the first field on the form/survey simply ask the user to create and enter a codename for themselves, instructing them to save it (in their phone notes?) for use again at the end of the term. In fact, at the end of the term, you could even print out a full list of JUST the code names and post it for students to peruse, in case they forgot. Each person will certainly recognize the name they chose from a list, while no one else will know who's who. You could even ask them to submit the post-assessment right in class after checking the code name list. And actually, I'm sure most students will get a kick out of seeing (and wondering about) the weird code names that will turn up.

Import custom field options from one Infusionsoft app to another

I am trying to find a way to update a custom field automatically within multiple Partner Infusionsoft apps when I manually update the field with new options within our main Infusionsoft app.
The idea is to avoid manually logging into every Partner Infusionsoft app that we manage, individually, to update the custom field options so that they match our main app custom field options when it is updated. The custom field is constantly being updated with new options that need to be mirrored within all of our partner apps.
The process would not need to be entirely automatic. We could manage using a trigger to update the rest of the apps whenever we have manually updated the custom field in our main app.
Can anyone please steer me in the right direction or tell me if this isn't even possible?
Yes this is possible with the API. Unfortunately there isn't a REST webhook for when a custom field is modified, so it would require a constant poll against what you would consider the master application. Constantly check the custom field and see if it's values changed. This is the rest documentation for that:
https://developer.infusionsoft.com/docs/rest/#!/Contact/retrieveContactModelUsingGET
That will include all the possible options for the field.
Unfortunately you can't modify a custom field in the newer REST API so you will have to use xmlrpc. The rest API only let's you create according to the documentation.
Here are the docs for the endpoint you would use with xmlrpc to update all the other apps to match the master application.
https://developer.infusionsoft.com/docs/xml-rpc/#data
https://developer.infusionsoft.com/docs/table-schema/
DataFormField is the custom field information. You would use the data endpoint to modify the values.
Be careful when you are polling the master application to not go over usage limits and apply best practices.

Best way to hide a form input field from being accessed using firebug?

I have a form which is posted to an external API. There is a parameter called customer_token which is passed as an input field. It is used for authentication by the API and every customer is assigned one token. The input field is visible in Firefox's Firebug (even though it is a hidden field).
How do I hide it?
Options
Using javascript as I thought initially
I think using javascript to create that input field at the run time before submitting the form and immediately removing the field will work but still the field will appear momentarily. So, even if a person can't manually get it, I am afraid that a crawler or spider (I don't know the exact term - but some automated script) may get the customer token. Is there a better solution for this? After form submission, the same form remains displayed.
Using one-time token concept as suggested by Ikke
I am not sure how it will work? The API needs the correct customer token value to process any request. So, even to generate a one-time token and return, a request with the customer token has to be sent. This way anyone is able to see my customer token value and they can also send a request to get a one-time token and use it. So how does it solve the problem?
Resolved
Check How to post form to my server and then to API, instead of posting directly(for security reasons)?
Thanks,
Sandeepan
This is not possible. Firebug just reads the DOM in it's actual state, so even if it's added in a later stage, it can still be retrieved.
This way of security is called Security through obscurity and is a kind of non-security. You would have to solve it another way, like letting the server do the request in stead.
You let the user submit the form to the server. Then with curl, you make the call to the webservice with the correct user code.
I don't think this is possible I'm afraid.
Firebug will still see the element if it's inserted via Javascript, as it watches the DOM tree. If this input exposes a security vulnerability then it's the job of your server-side code to validate/fix it.
More details on the API might help somebody answer this question in more detail.
I hope this helps