Zabbix: how to parse error messages from web scenario checks as a macro - macros

I just setup dozens of web scenario checks in Zabbix. I also added triggers and one action for all the triggers. To test the action I deployed a test bad web scenario check, however an email message I got from the test only gave very high-level information:
Problem: Service "Jira-QAS" is DOWN
------------​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Status: PROBLEM
Value: 1
Original problem ID: 2314429
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
I want to parse "Last error message of scenario ..." as a macro and put it in the "default message" in "Action", so it would look something like this:
Problem: Service "Jira-QAS" is DOWN
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Issue: Couldn't connect to server: Failed connect to jira-qas.aws.ca:443; Connection refused
Original problem ID: 2314429
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
I tried different macros such as {ITEM.VALUE}, {EVENT.STATUS}, but neither of them were good enough.

You need to define Operational Data in the trigger, and add {EVENT.OPDATA} to the mail.
Operational data allow to define arbitrary strings along with macros. The macros will resolve dynamically to real time data in Monitoring → Problems. While macros in the trigger name (see above) will resolve to their values at the moment of a problem happening and will become the basis of a static problem name, the macros in the operational data maintain the ability to display the very latest information dynamically.
The same set of macros is supported as in the trigger name.
https://www.zabbix.com/documentation/current/manual/config/triggers/trigger

Related

core_user_create_user and moodle webservice setup not working

I have done everything needed to setup webservices on my moodle 3.11 instance, including roles/capabilities/user. However sending a test request always gives {
"exception": "dml_missing_record_exception",
"errorcode": "invalidrecord",
"message": "Can't find data record in database table external_functions."
}
The URL to access it is of the format https:///moodle/webservice/rest/server.php?wsfunction=core_user_create_user&service=mymoodleusermanage&moodlewsrestformat=json&users[0][username]=ABC&users[0][firstname]=VPTest&users[0][lastname]=None&users[0][email]=mail#xxx.com&users[0][password]=xxxxx&users[0][auth]=manual&wstoken=xxxxxxxxxxxxxx
The service parameter is correctly set to the shortname of the service. Does the service have to be defined anywhere additionally apart from Site Administration->Server->Web Services->External Services->Custom Services
Thanks for any help that can be given
The answer is very simple - you are trying to call a non-existent webservice function (hence the error message about being unable to find the database record for the function in the external_functions database table).
If you look in the Moodle code: https://github.com/moodle/moodle/blob/master/lib/db/services.php#L1717 you will see that the function is called core_user_create_users - with an "s" at the end of it.
If you add that extra "s" into the URL parameters you are using, then it should work.
https:///moodle/webservice/rest/server.php?wsfunction=core_user_create_user&service=mymoodleusermanage&moodlewsrestformat=json&users[0][username]=ABC&users[0][firstname]=VPTest&users[0][lastname]=None&users[0][email]=mail#xxx.com&users[0][password]=xxxxx&users[0][auth]=manual&wstoken=xxxxxxxxxxxxxx
you must change username all character small letter [username]=ABC like this [username]=abc and add s wsfunction=core_user_create_users

How to set Cadence test workflow id?

I'm following https://cadenceworkflow.io/docs/go-client/workflow-testing/#setup and seeing errors with Activity error. {"WorkflowID": "default-test-workflow-id".
How do I go about setting the WorkflowID (eg so that it contains the test name)? I'm using Go.
It's not supported directly to set a workflowID. we recently realized it and are actively working on this.
At the mean time, if you have to test with workflowID, a workaround is to use
ReplayWorkflowExecution(ctx context.Context, service workflowserviceclient.Interface, logger *zap.Logger, domain string, execution workflow.Execution) error
But you have to mock the service interface for fetching history.
See https://github.com/uber-go/cadence-client/blob/b31c3bbfb06a1f96c6ad911a48237cfbc4f9a565/worker/worker.go#L166
I will update this thread when this feature is implemented.

IoT Phone recipe connects but not sending data

I am working with Bluemix tutorial recipe "Real Time Data Analysis Using IBM Watson IoT Platform Analytics" presented here:
https://developer.ibm.com/recipes/tutorials/real-time-data-analysis-using-ibm-watson-iot-platform-analytics
I am not seeing the behavior in my Watson IoT dashboard as described; the phone device does connect and register itself but I see no events or data.
In the node server logs a couple things seem concerning:
404 on fetch of util.js; in fact that file is not in my code repository downloaded from the recipe's github.
Three deprecated warnings:
...deprecated multipart: use parser (multiparty, busboy, formidable) npm module instead at node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:56:20
...deprecated limit: Restrict request size at location of read at node_modules/express/node_modules/connect/lib/middleware/multipart.js:86:15
...deprecated methodOverride: use method-override npm module instead at app.js:63:17
The phone device shows some fluttering data values but stays in state "connecting". On the WatsonIoT dashboard it shows registered but "Disconnected".
Is the missing util.js a fatal condition? If not then how next to troubleshoot it as I am new to the whole package?
Solved. The recipe checks for whether it needs to create its cloudant database, unaware that I'm sharing my cloudant service instance with other apps; it finds a db exists, blithely assumes that's the one it needs, and skips the create. Change app.js from:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.length == 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create('device_credentials', function()
to e.g.:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.indexOf(dbName) < 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create(dbName, function()
[etc...]
With the db in place, WatsonIoT accepts events coming from phone and shows the data as expected.
I found this by following the print statements in log.

Drupal: How to automatically send (cck) node content + file attachment via email

I am still quite new to Drupal and have very limited programming skills.
I am trying to build a job board site using cck + views. I have created 2 related content types: a "job post" and a "job application" - both are related using a nodereference field.
The job application node has 4 fields: id of the job post to which the person is applying, email of the applicant, cover letter (body field) and attached cv (cck field that allows users to attach/upload a document).
Question: Once a job application is created I would like the content of the node (including the attached file) to be automatically sent via email to the person who posted the job (destination email address is in a cck field in the related "job post" node).
Thus my requirements are: (1) to automtically "transfer" the destination email address from the "job post" content type to the "job application" content type; and (2) to automatically send all the "job application" node contents + file attachment to the destination email.
Is there any module that can help me achieve this?
Thank you so much for your support.
My email address is: wedge.paul#gmail.com
To give it to you straight: No, there is no module that will do this. Largely because you have already made most content types and it is pretty unique to your project.
Still, you may not have limited programming skill, I would advice learning it when working with drupal. What you are asking is really not that hard to create by writing a custom module. Writing a custom module is really not that hard, and starting to write a custom module in Drupal is really well documented.
I can tell you what to use in the custom module, however it is better if you create it yourself (for future projects).
So you create your custom module:
function mymod_nodeapi{ //here all the action happens when a node is created
switch ($op) {
//if the node is inserted in the database
case 'insert':
//if node is a job application
if($node->type = "jobapplication"){
//using node_load function, you can load other nodes in a variable
$relatednode = node_load($node->nodereference);
//using drupal_mail function, you can mail people
drupal_mail();
}
break;
}
}
This code has not been tested and can't be copy pasted. However node_load and drupal_mail as well as hook_nodeapi... use those functions and you'll get there.
Lullabot's video tutorial "Learning CCK for Drupal" is based on the concept of a job application/posting site as a case study. It may be worth investigating.
no, I'm not connected in any way to Lullabot; just a fellow Drupaler

What is the best way to log errors in Zend Framework 1?

We built an app in Zend Framework (v1) and have not worked a lot in setting up error reporting and logging. Is there any way we could get some level or error reporting without too much change in the code? Is there a ErrorHandler plugin available?
The basic requirement is to log errors that happens within the controller, missing controllers, malformed URLs, etc.
I also want to be able to log errors within my controllers. Will using error controller here, help me identify and log errors within my controllers? How best to do this with minimal changes?
I would use Zend_Log and use the following strategy.
If you are using Zend_Application in your app, there is a resource for logging. You can read more about the resource here
My advice would be to choose between writing to a db or log file stream. Write your log to a db if you plan on having some sort of web interface to it, if not a flat file will do just fine.
You can setup the logging to a file with this simple example
resources.log.stream.writerName = "Stream"
resources.log.stream.writerParams.stream = APPLICATION_PATH "/../data/logs/application.log"
resources.log.stream.writerParams.mode = "a"
resources.log.stream.filterName = "Priority"
resources.log.stream.filterParams.priority = 4
Also, I would suggest sending Critical errors to an email account that is checked regularly by your development team. The company I work for sends them to errors#companyname.com and that forwards to all of the developers from production sites.
From what I understand, you can't setup a Mail writer via a factory, so the resource won't do you any good, but you can probably set it up in your ErrorController or Bootstrap.
$mail = new Zend_Mail();
$mail->setFrom('errors#example.org')
->addTo('project_developers#example.org');
$writer = new Zend_Log_Writer_Mail($mail);
// Set subject text for use; summary of number of errors is appended to the
// subject line before sending the message.
$writer->setSubjectPrependText('Errors with script foo.php');
// Only email warning level entries and higher.
$writer->addFilter(Zend_Log::WARN);
$log = new Zend_Log();
$log->addWriter($writer);
// Something bad happened!
$log->error('unable to connect to database');
// On writer shutdown, Zend_Mail::send() is triggered to send an email with
// all log entries at or above the Zend_Log filter level.
You will need to do a little work to the above example but the optimal solution would be to grab the log resource in your bootstrap file, and add the email writer to it, instead of creating a second log instance.
You can use Zend_Controller_Plugin_ErrorHandler . As you can see on the documentation page there is an example that checks for missing controller/action and shows you how to set the appropriate headers.
You can then use Zend_Log to log your error messages to disk/db/mail.