I´m a newbie in Zabbix and I wanna to create a item which search a " problem " word in some log file. This item should search the file every 5 seconds and if there are some " problem " words, it´s trigger a problem.
I create a key with condition:
log[/var/log/test/test.log,problem]
After that, create a trigger:
{Log reader:log[/var/log/test/test.log,problem].strlen()}>0
I Create a fake .log file and fill it with some fake data:
asdasda
asdadad
problem
asadada
Everything works great, trigger works and show me a problem where last data was " problem ". After this a open the fake log again a write:
asdasda
asdadad
problem
asadada
problem 1
Save it, and zabbix shows me a 2 problems, both of these have last data " problem 1 ". When I write problem 3 to log, same again, 3 new reports all with " problem 3 " data.
This item should actaully read only latest data. I´m not 100 % sure if this is a real problem because every time when I edit .log file I re - save it so logically, item finds a 3 words, so it creates 3 reports. How will be this works if .log will be real and be filled with real data ? Does item read only news or it will works the same as I re - save whole file ?
Thanks a lot for your time :)
There's a dedicated page for log file monitoring in the documentation which is very useful, the "Important Notes" section covers most of the gotchas.
Your trigger is working as expected, for every "problem" added in your log you get an alarm, and your alarm stays forever.
You should define a time window for your trigger (i.e.: trigger in I've got at least one "problem" in 5 minutes) or a recovery expression to clear the trigger after a certain condition is met (i.e.: 5 minutes passed without "problem" or a "OK" string in your log).
According to the trigger functions documentation - strlen section, this should fire up one alert which stays up for 1 or more "problem" strings and clears out after 5 minutes:
{Log reader:log[/var/log/test/test.log,problem].strlen(,5m)}>0
Related
I'm hoping there's just some way to disable this in SQL Server Management Studio (v17.9.1). When I Script As->Alter a view or stored procedure to a new query window, I can hit Ctrl+Z and it deletes the last line of text! I realize as I'm trying to explain this exactly what's happening: Sql is opening a new window and "pasting" the query line by line. Therefore when you undo you're removing the last line and so on.
This becomes a problem when you say, alter a view, make changes and execute, then decide to undo them all so you just hold Ctrl+Z then realize you've erased half your script instead of just going back to the starting point.
Does anyone know how to disable this or an elegant way of preventing it from happening?
This started out as a comment, but it's getting too long, so...
I don't think you can disable ctrl+z, but just like Newton's third law of motion - for every undo there's an equal and opposite redo - so if you've held ctrl+z pressed for too long, you can always restore the lines that ctrl+z deleted simply by using ctrl+y.
Other options are suggested by GSerg in his comments - you can always keep a copy of the original code in a different query window, or even a simple text editor.
One more option is to first save the content of the new query to a file, so you can always reload it's original state if you've messed things up too much.
I have the following AppleScript that works fine when I step through each line one at a time using Script Debugger, but reports that the _doc variable has a missing value when it gets the the save as line.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Finder"
set _folder to choose folder
set _files to files of _folder
repeat with _file in _files
if creator type of _file is "MSWD" then
tell application "Microsoft Word"
open _file
set _doc to document of window 1
save as _doc file format format text
close _doc
end tell
end if
end repeat
end tell
I've tried pausing for as long as 5 seconds using delay 5 with no change in the behavior. Why might this be happening and what can I do about it?
The answer to "why might this be happening" seems to be "it probably is a timing problem" and "because there are a number of problems when automating Word from both AppleScript and VBA on Mac that Microsoft has not yet fixed". I don't think there's much you can do about it except report to Microsoft via the Smiley mechanism or via word.uservoice.com. On uservoice, best to add your vote than existing request if there is one. But there is no reason at all to believe that Microsoft will even acknowledge or fix quite serious automation problems at the moment.
I had not come across the problem where you couldn't even set _doc to document of window 1 successfully. I was always able to use
set _doc to open _file
Here, I found a "delay 5" was enough to solve the problem you report, but there has also long been a problem where the "_doc" variable becomes invalid after a save as. I had a solution to that that iterates through the windows, so have put together this script which
a. should reduce the delay as much as possible
b. works on simple test data here but could do with improvement, especially on error checking
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Finder"
set _folder to choose folder
set _files to files of _folder
repeat with _file in _files
if creator type of _file is "MSWD" then
tell application "Microsoft Word"
--activate
set doc_count to (count of documents)
open _file
-- You have to set the maximum no. of repeats
-- high enough for your system
set repeats to 50
repeat until (count of documents) > doc_count or repeats = 0
set repeats to repeats - 1
end repeat
if (count of documents) > doc_count then
set _doc to (document (doc_count + 1))
set _windows to the windows
repeat with _window in _windows
if the full name of the document of _window is the full name of _doc then
set _windowIndex to the entry_index of _window
exit repeat
end if
end repeat
-- you need to create a new file name for each file.
-- this is a temporary kludge
set _textfilename to (posix full name of _doc) & ".txt"
save as _doc file name _textfilename file format format text
-- _doc now invalid, we need to "reconnect"
set _windows to the windows
repeat with _window in _windows
if the entry_index of _window is _windowIndex then
set _doc to the document of _window
exit repeat
end if
end repeat
close _doc saving no
else
-- you can make this more informative, and you might still need to
-- try to close something.
display dialog "Could not open document: " & POSIX path of _file
end if
end tell
end if
end repeat
end tell
Incidentally, when I tested on a single document using open recent file instead, there was never any problem getting a reference to the document. But that's useless for the kind of thing you're trying to do.
I'm trying to close the open word document and delete it as part of my DocumentBeforeClose event. I keep running across the following code in my searches (+/- some error trapping statements):
Dim Killfile As String
Killfile = Dir$(ActiveDocument.FullName)
If Len(Dir$(Killfile)) > 0 Then
SetAttr Killfile, vbNormal
ActiveDocument.Close False
Kill Killfile
End if
I've found similar code (well, frankly almost identical code) in several places, and everyone seems to confirm that it works, but I cannot get it to run correctly in my own attempts, regardless of what module I have the code in. When run, the document always closes, but the code also stops there and never gets to the Kill command. In theory the instance of Word is supposed to keep running the script once the document closes; in my case the instance is open, but there's nothing running anymore at that point. Am I doing something obviously wrong here?
If it's helpful, in another version of the code I'm working with I have a Do While loop going through a directory and deleting documents containing "temp.doc" in the name. That code has no trouble running through and deleting closed files, but also will not delete the active/open document after closing.
Is this something I need to place in the Normal module in order for it to work? (Would reeeaally like to avoid that if possible). Thanks for any help!
Editing to add the top few relevant Search Results from Googling "MSWord VBA Delete Open Document":
http://word.tips.net/T001346_Deleting_the_Open_Document_File.html
http://geekgirls.com/2010/02/deleting-an-open-document-in-microsoft-word/
Delete doc when macro finishes
Again, the unifying factor appears to be:
Activedocument.close
Kill WhateverOpenFile
...which just plain doesn't seem to make sense.
I'll start off by saying that I've sat around trying to figure out this for a good 8hrs and now I'm coming here to ask for help.
I want to be able to have a text file that starts at 0 and will increase by 1 every time I press the hotkey. I want this to happen without having the file open. This will be used as a counter.
Ken made a point with regard to knowing the initial value. If you want to ADD a number at the bottom you can use:
fileappend, %Counter%`n, C:\Temp\Counter.txt
Or if you want to JUST have that one number:
filedelete, C:\Temp\Counter.txt
fileappend, %Counter%, C:\Temp\Counter.txt
If you want to store a variable, you can use the .ini files to store various variables.
IniWrite, %TextCounter%, %A_ScriptDir%\Counter.ini, Counter, Nr
IniRead, TextCounter, %A_ScriptDir%\Counter.ini, Counter, Nr
I see this is an old question but it never got answered correctly. If you want to store a single number in a file and then increment that number with a hotkey here is a simplified version of the process:
FileRead to store the current number from the file into a variable
FileDelete to delete the old file (if you don't delete the file each time, step 4 will turn the file into a list of numbers.
add 1 to the variable.
FileAppend to store the updated variable back in the file.
This seems like such a simple operation normally, but I can't seem to make FileMaker cooperate.
What I want to do:
1) Loop through each found record, one at a time.
2) Export the contents of this record to a filename based on a field within the record.
Loop
Set Variable[$path; Value:Get(FilePath) & "/../somefolder" & MyTable1::my_field_1]
Export Records [No dialog; "$path"; Unicode(UTF-8)]
End Loop
This script, however, appends every record to the same file. They don't seem to offer an 'Export Record' (singular), so I'm not sure how else to accomplish this.
Any help would be greatly appreciated.
I was able to find a solution:
Find All
Go to Record/Request/Page [First]
Loop
Omit
Find Omitted
Set Field ["HTML File Name","External("DM-Export", KeyField & ".html")"]
Export Records [Restore]
Find All
Go to Record/Request/Page [Exit After Last, Next]
End Loop
As per Step 7 on:
http://help.filemaker.com/app/answers/detail/a_id/3438/kw/exporting%20found%20set
FileMaker's "Export Records" script step always exports the entire found set. You must loop through the found set, and isolate each record one at a time prior to exporting:
Go to Record/Request/Page [First]
Loop
Set Variable[$path; Value:Get(FilePath) & "/../somefolder" & MyTable1::my_field_1]
New Window
Show All
Omit Record
Show Omitted
Export Records [No dialog; "$path"; Unicode(UTF-8)]
Close Window
Go to Record/Request/Page [Exit After Last, Next]
End Loop