Nagios: Can I output HTML in my custom plugins? - nagios

Is it possible to output HTML in my nagios plugins?
I'd just like a <br/> (new line) to show up in status of my plugin (I'd like error messages to include a reasonable amount of useful information in the case of a multiple transaction jmeter script).
I tried outputting <br/> in my plugin, but nagios converts it to text rather than displaying it as HTML.

As default no. But you could modify the code of the display page to parse the output for line breaks?

Related

HTMLpurifier remove cc email between tags

I'm using HTMLpurifier to sanitize inputs in my PHP application:
I have CC and BCC inputs something like:
Test Admin <test#domain.com>
when I do purify this string, it only keeps: Test Admin (without email between tags)
Please advise!
This probably means you've got an escaping issue somewhere in your pipeline before HTML Purifier - something that's putting E-Mail text into an HTML context without HTML escaping it. HTML you need to purify that looks like this:
<p><label for "id">Email</label><span id="email">Test Admin <test#domain.com></span></p>
...should really look like this:
<p><label for "id">Email</label><span id="email">Test Admin <test#domain.com></span></p>
If you have no control over the step that's inserting data into the HTML you ultimately want to purify before displaying, you can use this to preprocess your HTML before feeding it to HTML Purifier:
$htmlWithEmail = preg_replace('/<([^<>#]*#[^<>#]*)>/', '<${1}>', $htmlWithEmail);
On the other hand - and I mention this because I know only a little bit about your use-case right now - if you're not actually trying to preserve HTML, if the string you're purifying is literally just Test Admin <test#domain.com> with nothing else (unlike the example I crafted above), htmlspecialchars() should be your weapon of choice when outputting into HTML, not HTML Purifier.
HTML Purifier's purpose is not all-purpose data sanitation, it really does exist only for the use-case where you have HTML, you want to preserve it if it's well-behaved, and then output it as HTML. You can find some more info about escaping for context here: https://stackoverflow.com/a/37641037/245790

How do i save exact values as displayed in JMeter test results including min, Max, avg values...?

I am trying to save test results as displayed in Summary, Aggregate report table but the results are not saved as the results displayed in the GUI while running jmx script.
I already tried to use Synthesis report too to get the results but still it does not work.
No error messages are displayed though.
I am assuming that you are running in non-gui mode. Please check the below CLI sample:-
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
This will generate the jtl file at the end of the execution. You can then import this file in different listeners (Summary, Aggregate etc).
If in GUI mode. Then, use simple data writer or view result tree to generate the jtl file. Once completed, use summary report "Filename" field to point generated file as input as shown below:-
Then, use "Save Table Data" button to generate a summary.csv file.
Hope this helps.

DotNetNuke parse HTML before display

Could anyone tell me if there's some way of "hooking in" to DotNetNuke so that I can, for example, search and replace text for ALL HTML modules on the site?
e.g. if I use an HTML editor and enter the text {{replace_me}}, then I could have some code that detects "{{replace_me}}" every time a page is rendered and replace it with something else.
Please note that this is a simple example - there may be other ways of "replacing" text - however the actual use case we have is very specific and there will be some significant processing to decide what to replace :) - so whatever solution we implement should basically be:
Get HTML from DB -> Process it however we wish in full C# -> Deliver the modified string.
Thanks!
I believe you can do this with the use of an HTTPModule. Ifinity.com.au used to sell a module that did this, looks like you might be able to download it now for free (maybe?) at http://www.ifinity.com.au/Products/Inline_Link_Master/Product_Details

DotNetNuke Event Logging format

Using DotNetNuke 5.
I am using the EventLogController along with LogInfo to add custom messages to the event logs in dot net nuke.
Within LogInfo we have a method to Add a Property/Value. I am under the assumption that the Controller.AddLog(logInfo) converts the properties & vlaues into XML using the LogInfo->Serialize method for DNN to store it.
My problem is that I want linebreaks in my message. Is there anyway I can add a newline. "\r\n" wouldn't work, wouldn't work, CDATA escaped wouldn't work. Everything gets escaped through the Log function.
How do I pretty print the log message myself?
Regards, V
Sadly, due to the HTML encoding that is done on all messages, you are going to be out of luck trying to do this in the DNN event Log.
Depending on what/where you are, you have a few options.
You can add them as individual detail lines using properties, see my example below.
You could report on something yourself, using a custom log table or something similar
If you are in the context of a Scheduled Job, you can log to that history, which is NOT escaped.
Examples
Log Properties
objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
objLog.AddProperty("SecureMyInstall", "Phase 2 Error Processing User Accounts");
objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
objLogger.AddLog(objLog);
The content of the logs is displayed as HTML, so you should be able to put <br /> to add line breaks.

Receive multi file post with google app engine

I want to receive multi file post from image uploader.(i use this)
Most examples show how to receive one image from post.
I tried many ways but never got the results.
For example
self.request.POST['Filename']
gives only first filename.
What to do when there are multiple files/images in post?
The reason for this is to resize before upload images, that are too big for google app engine
to upload.
EDIT:
self.request.POST.multi.__dict__
shows
{'_items':
[('Filename', 'camila1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'camila1.jpg')),
('Upload', 'Submit Query\r\n--negpwjpcenudkacqrxpleuuubfqqftwm----negpwjpcenudkacqrxpleuuubfqqftwm\r\nContent-Disposition: form-data; name="Filename"\r\n\r\nbornToBeWild1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'bornToBeWild1.jpg')),
('Upload', 'Submit Query')]}
Your flash uploader is designed to work with PHP and sends multiple Filedata[] fields (php interprets this as an array for easy access)
So you need to iterate and get them all:
def post(self):
for file_data in self.request.POST.getall('Filedata[]'):
logging.info(file_data.filename)
data should be file_data.value
Are you using the Django libraries available to you? If so, check this out.
Call self.request.POST.getall('Filename') to get a list of FieldStorage objects; each one contains one file. You can access the file data with .value, the name with .name, and the mimetype with .type.
I have no idea how that multi uploader works, I have made one in the past however and I just added a number on the end of input field name, then hide it. Then add a new file input field to add another file. The reason for this is that they don't let you play around with input file fields to much because you could make it upload files they didn't want you uploading.
Using my conventions, in your example the 2 files in your example would be "Filename0" and "Filename1". You could also use firebug to see what it renaming the input file fields to.
Edit: I had a look, and it's using flash. So i have no idea how it works.

Resources