What to get the files older than today? Run
find /path/ -type f -daystart -mtime +0
it will return only the files older than today, no matter the time the command is executed (by default, -mtime counts multiples of 24 hours from now). Kinda nice when you want to archive yesterday log files.
Showing posts with label sysadmin. Show all posts
Showing posts with label sysadmin. Show all posts
2011-11-03
2011-09-19
Print a NUL-terminated string with awk
I thought it would have been easier to print a NUL-terminated string in awk (mawk as it's the default in Debian), but after some trial-and-fail I was able to come up with this kinda ugly solution:
$ echo -e "123\n456" | awk 'BEGIN { ORS="" } { print $0 ; printf("%c", "") }' | xargs -n1 -0 echo
123
456
That:
$ echo -e "123\n456" | awk 'BEGIN { ORS="" } { print $0 ; printf("%c", "") }' | xargs -n1 -0 echo
123
456
That:
- set the Output Records Separator (ORS) to the empty string (default is the \n, new line)
- print the input line (do your elaboration there, if you need)
- print the null character, as explained in the mawk manpage: "mawk cannot handle ascii NUL \0 in the source or data files. You can output NUL using printf with %c, and any other 8 bit character is acceptable input."
- show that it's actually emitting NUL-terminated strings
There's really no better way to do that?
2010-11-05
"multi-strace"
Thanks to a colleague, we hereby present the multi-strace:
strace $(pgrep httpd | awk '{ print "-p " $1 }' | tr '\n' ' ')
(it's left as exercise to the reader to understand what it does) if you want to save the output and the play with it, just add '-o <file>'.
Welcome, new handy tool!
2010-03-17
Check Nagios from the desktop: nagstamon
I just discovered nagstamon and all the team fallen in love with it!
I tried to use Nagios Checker, the Firefox plugin to notify of any Nagios alert, but that doesn't play nicely with several opened windows (alerts are multiplied for the number of windows, since it seems everyone does the checks, not just one) and it tends to slow down Firefox, that's already quite slow per se :)
The upstream author provides a Debian package, so promptly I wrote to him asking if he can consider maintain the package in Debian, with me as mentor/co-maintainer and so (it's in Python so I can that :) ); let's see how it goes.
Give it a try, it's really simple and awesome!
I tried to use Nagios Checker, the Firefox plugin to notify of any Nagios alert, but that doesn't play nicely with several opened windows (alerts are multiplied for the number of windows, since it seems everyone does the checks, not just one) and it tends to slow down Firefox, that's already quite slow per se :)
The upstream author provides a Debian package, so promptly I wrote to him asking if he can consider maintain the package in Debian, with me as mentor/co-maintainer and so (it's in Python so I can that :) ); let's see how it goes.
Give it a try, it's really simple and awesome!
2010-02-12
Italy has (again) a PHP.net mirror
After a long time of no Italy mirror, now PHP.net has enabled it.php.net, kindly sponsored by Register.it.
Why am I happy? Because I did it! :)
Why am I happy? Because I did it! :)
This RRD was created on another architecture
That is the message you'll receive when trying to open a RRD database created on a 32bit machine from a 64bit one (it's also true the reverse). It's due to the fact that RRD is an architecture-dependent file format: endianess and integer bits length matter.
That's quite boring, given it's quite common to let each machine generate its own RRDs and graph them from a central place, and the more machines you have, the more chances of the above problem.
So, for another example, if you migrate one machine from 32 to 64 bits, you'll have to:
So, can we haz an architecture independed RRD file format? Pretty please?
It was planned for 1.4, and now that 1.4 is release it's planned for 1.5. Let's hope it comes soon, it would be really nice! :)
That's quite boring, given it's quite common to let each machine generate its own RRDs and graph them from a central place, and the more machines you have, the more chances of the above problem.
So, for another example, if you migrate one machine from 32 to 64 bits, you'll have to:
- dump all the RRD databases from the 32 machine
- restore all the RRD databases on the 64 machine
So, can we haz an architecture independed RRD file format? Pretty please?
It was planned for 1.4, and now that 1.4 is release it's planned for 1.5. Let's hope it comes soon, it would be really nice! :)
2009-12-17
Remote Apache logging with syslog: is there anything better?
We're doing a pilot to do remote logging for some Apache logs (possibly other services in the future). We've heard of remote syslog capability (and since syslog is on all Linux system) we're giving it a try.
The configuration is quite simple:
rsyslog is quite flexible and it allows you to filter messages based on the tag in them, and log in different files, but it's still something very "home-made" and not that professional.
I don't we're the only one needing a remote logging tool, and while syslog is the classic solution, is very bind to the system logs and not to the applications logs: any suggestions for this task? I'd like to hear how you solved this task, possibly without a custom tool, but using something standard.
The configuration is quite simple:
- [srv] prepare a machine to do the log server
- [srv] open it's rsyslogd to receive messages on UDP (or TCP) port
- [srv] log the selected facility.level to a log file
- [cli] forward the above facility.level to @srv
- only 8 facilities for users custom log (local0-local7)
- only 8 levels for logs severity
rsyslog is quite flexible and it allows you to filter messages based on the tag in them, and log in different files, but it's still something very "home-made" and not that professional.
I don't we're the only one needing a remote logging tool, and while syslog is the classic solution, is very bind to the system logs and not to the applications logs: any suggestions for this task? I'd like to hear how you solved this task, possibly without a custom tool, but using something standard.
Subscribe to:
Posts (Atom)