Tag Info

Hot answers tagged

5

Don't reinvent the wheel :) The Monit utility is purpose-built to handle this sort of situation. It's well-documented and has plenty of examples here on ServerFault. check system kale.GreenLeaf.com if loadavg (5min) > 16 for 15 cycles then alert if memory usage > 92% then alert if swap usage > 10% then alert or for a process: ...


4

if fgrep -q 'reset adapter' /var/log/messages.log; then mail -s 'Flapping ethernet' alerts@OurAlertBoard.com fi Note the added ; before then Also, you need to keep grep quiet and only return an error code. This is done with -q On most systems, the log files is named /var/log/messages. Check if messages.log is correct on your system.


4

How about: [ $(free -m| grep Mem | awk '{ print int($3/$2*100) }') -gt "80" ] && echo "greater " || echo "lesser" And for the process consumption, here is a possible part of a solution: for p in $(pgrep bash); do total=$(($total + $(awk '/VmSize/ { print $2 }' /proc/$p/status))); done ; echo "Total memory usage: $total kb" ; unset total ...


2

What exactly are you trying to accomplish? You're probably trying to do it WRONG. [ $(free | perl -nE 'if (/Mem/) { (undef,$total,$used) = split; say int(100*$used/$total) }') -gt 80 ] && echo foo But note that whatever you are trying to accomplish with that is almost certainly useless (and probably even harmful). There is no such thing as ...


2

To fit with modern sysadmin best practices it would be good to add your configs as individual files in /etc/smb/smb.d and then reference them with an include. Sadly samba does not support wildcard includes so you have to do add something like: include = /etc/smb/includes.conf in your smb.conf and then generate the includes.conf with something like: ls ...


1

You could try using the following commands: (this is to disable all Internet Connections in Ubuntu) nmcli nm enable false and to enable it again: nmcli nm enable true Hope it helps! :)


1

Unless I misunderstand, how about you append cat filea >> fileb You can do a sort afterwards, if that's what you're after.


1

Use exit followed by the value you want. Zero is considered success, non-zero failure. This is typically used within a script, and terminates the (sub)shell it is exited from. If you want to capture the status of a command, assign $? to a variable. This allows you to save the value after displaying it.


1

I was with a issue like this, here what I did. The strace command will print all interactions the process are doing with external libraries, so with it we can see if our config is loaded or not. So, i do, like suggested above: root:/etc/pam.d$ strace -o ~/loglimit su - glaudiston glaudiston:~$ exit logout root:/etc/pam.d$ cat ~/loglimit | grep limits.conf ...


1

What you're after is findmnt. For example: $ findmnt -rn -S UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET /mnt/mountpoint or $ findmnt -rn -S PARTUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET /mnt/mountpoint If nothing is mounted matching that UUID, nothing is output and the return code is 1 (failure), otherwise, the mountpoint is output ...


1

Using date and expr can get you there i.e. X=$(expr \`date +%H\` \\* 3600 + \`date +%M\` \\* 60 + \`date +%S\`) echo $X Just expand on it to do whatever you want I realise this does not give milliseconds since epoch, but it might still be useful as an answer for some of the cases, it all depends on what you need it for really, multiply by 1000 if you ...


1

You can also use cut like this : for file in /a/dir/*/dir/* ; do echo \`echo $file | cut -d"." -f 1` >> textfile; done It will only work if you don't have any file or directories with a "." in the name



Only top voted, non community-wiki answers of a minimum length are eligible