how do I check the size of a directory and add "didnt change after time x" - linux

I am monitoring witch Check-MK and i know how to get this skript as a service right into Check-MK.
I need just the skript:
check the directory size and I want to get an alert if it didnt change after 1,5h
to check the folder size:
folder_size=$(du -bs /backup/log |
after the "|" i want to check this with time
am I right so far?
thx for help <3

You can write a simple local check, that does what you need, if Checkmk's built-in file age checks do not meet your requirement.

Related

Get a top level from Path object of pathlib

I use pathlib to match all files recursively to filter the files based on their content. Then I would like to find what is the top level of the folder of this file. Assume the following. I have a file in the folder:
a/b/c/file.log
I do the search from the level a:
for f in path_data.glob("**/*"):
if something inside file f:
# I would like to get in what folder this file is, i.e. 'b'
I now that I can get all parents levels using:
f.parents would give me b/c
f.parent would give me c
f.name would give me file.log
But how could I get b?
Just to precise: the number of levels where the file is stored is not known.
UPD: I know I could do it with split, but I would like to know if there is a proper API to do that. I couldn't find it.
The question was asked a while ago, but didn't quite get the attention. Nevertheless, I still would publish the answer:
f.parts[0]

Zebra RFD8500 : How to use read in ZETI

I have a Zebra RFD8500 here and I connected to it via the terminal. I am trying to use the ZETI command read to access epc's, but it does not read anything.
But if I use the ZETI command inventory it finds all the tags around.
Anyone knows how to use the read command properly? Also is there some kind of filter per default on?
I am using the developer example on page 174 Link to PDF
Not sure if you solved this problem, but I couldn't find anything else via Google. I had the same problem with using read in ZETI (Zebra RFD8500). The Zebra tech support told me that to use access operations like read and write, you have to turn off dynamic power (which I think is on by default).
Unfortunately, I am not using the iOS API/SDK (writing a custom one for another device), but here's the gist of what you'd be doing:
Turn off dynamic power
Do an inventory
Read some memory bank, like the EPC bank. Optionally, you can also specify access criteria to single out a tag.
To test how this worked in ZETI, I screened into the RFD8500 (on my Mac, doing ls /dev/tty.RFD* lists several ttys, I chose the one ending in "-R"):
screen /dev/tty.RFD8500{long number}-R
Then I issued these commands:
dp .disable
in
rd
Commands:
dp = setdynamicpower
in = inventory
rd = read
After issuing "rd", you should be able to see the user memory banks (the default bank for the "rd" command).

using and(&&) operator in for loop in linux

01) I am trying to use the && operator in a for loop as shown below in the script. However this does not seem to work. I was not able to see the error generated in the terminal window, since it closes as soon as it runs in to an error. Could someone please tell me what I'm doing wrong?
#!/bin/bash
cd ~/Documents/DTI/
#subj and subj1 contain folders which are located in the DTI directory
subj="ARN MT"
subj1="ARNpre1 ARNpre2"
for [[s in $subj] && [s1 in $subj1]]
02) And as you can see in my "subj1", the first two entries start with the letters ARN which means that they are sub directories of ARN(located in a different place.Not in ARN main directory). So I also want to run a command in which, if subj1 contains subj then it must perform a certain command.For this purpose I wrote the following,
if [[ ${s1} == *"${s}"* ]];then
would this be the right way to do such operation?
I would greatly appreciate any help.
Thank you in advance.
I think by for [[s in $subj] && [s1 in $subj1]] you mean this:
for s in $subj; do
for s1 in $subj1; do
# do something
done
done
By nesting the for loops you'll loop through every possible combination of s and s1, which sounds like what you're trying to do in part 1 of your question.
However, I can't make sense of what you're talking about in part 2, so I can't help you there.

Powershell: Formatting executable

I'm trying to create a script that will format the output of w32tm.exe /monitor and display in a table the server name, NTP offset, and RefID.
I'm a little unaware of how to go about getting the output from an executable file to format it and was wondering if someone here could help me. Right now I'm trying this:
$executable = w32tm.exe /monitor
$executable | Format-Table -View "Server Name", "NTP offset", "RefID"
How can I manage to get the executable to be formatted in a table to display those specific parts of the exe?
Hi I also needed to do this before I found a function someone made to do this have a look I am sure you can change it to suit your needs or just use it as is .
ps-function
Article on how it works

Increasing the number of suggests shown in omnibox

Is it in anyway possible to increase the number of suggests that your extension may show in the omnibox?
By default it looks like 5 rows is the limit. I've read about a command line switch to change the number of rows (--omnibox-popup-count) but I am really interested in dynamically being able to set this in my extension.
5 rows isn't really enough for the information my extension want to show.
[Update 2018 - thanx version365 & Aaron!]
» Not hardcoded anymore! chrome://flags/#omnibox-ui-max-autocomplete-matches . Credit goes to #version365 answering below: http://stackoverflow.com/a/47806290/234309 « – Aaron Thoma
..[historical] detail: since the removal of --omnibox-popup-count flag (http://codereview.chromium.org/2013008) in May 2010 the number [was] hardcoded:
const size_t AutocompleteResult::kMaxMatches = 6;
a discussion two years later on the chromium-discuss mailing list about the 'Omnibox default configuration' "concluded"
"On lower performing machines generating more result would slow down the result display. The current number look like a good balance."
[which is not a very valid argument, considering the probably infinitesimal overhead retrieving more items than the hard-wired number]
why the heck is there no chromium fork that removes stupid UX limitations like this (or the no tabbar in fullscreen mode)^^
Since there is no more --omnibox-popup-count flag; you can use another flag which is new.
chrome://flags/#omnibox-ui-max-autocomplete-matches lets you select a maximum of 12 rows.
In fact there is no more --omnibox-popup-count flag
http://code.google.com/p/chromium/issues/detail?id=40083
So I think there is no way to enlarge the omnibox.

Resources