RE: Cacti FreeBSD Jail CPU RAM monitoring
Hi, Based on answers of my first post, I wrote a small perl script in order to find out the CPU and MEMORY used by each jail. Here it is: -- - jls.ps -- #!/usr/bin/perl @jails = `jls`; $title = shift @jails; chomp $title; print $title . \t\t%CPU\t%MEM\n; foreach (@jails) { my ($jid) = /\s+(\S+)\s/; @jexec = `jexec $jid ps -afxu`; @mem = map {/\S+\s+\S+\s+\S+\s+(\S+)\s/} @jexec; shift @mem; $tot_mem = 0; foreach (@mem) { $tot_mem = $tot_mem + $_; } @cpu = map {/\S+\s+\S+\s+(\S+)\s/} @jexec; shift @cpu; $tot_cpu = 0; foreach (@cpu) { $tot_cpu = $tot_cpu + $_; } chomp $_; print $_ . \t$tot_cpu\t$tot_mem\n; } -- I still haven't connected anything to cacti yet, but I wanted to share that. I think it can be quite useful. Cheers, -- Philippe Lang, Ing. Dipl. EPFL Attik System rte de la Fonderie 2 1700 Fribourg Switzerland http://www.attiksystem.ch Tel: +41 (26) 422 13 75 Fax: +41 (26) 422 13 76 smime.p7s Description: S/MIME cryptographic signature
Re: Cacti FreeBSD Jail CPU RAM monitoring
On Aug 15, 2006, at 9:16 AM, Philippe Lang wrote: Hi, Based on answers of my first post, I wrote a small perl script in order to find out the CPU and MEMORY used by each jail. Here it is: -- - jls.ps -- #!/usr/bin/perl @jails = `jls`; $title = shift @jails; chomp $title; print $title . \t\t%CPU\t%MEM\n; foreach (@jails) { my ($jid) = /\s+(\S+)\s/; @jexec = `jexec $jid ps -afxu`; @mem = map {/\S+\s+\S+\s+\S+\s+(\S+)\s/} @jexec; shift @mem; $tot_mem = 0; foreach (@mem) { $tot_mem = $tot_mem + $_; } @cpu = map {/\S+\s+\S+\s+(\S+)\s/} @jexec; shift @cpu; $tot_cpu = 0; foreach (@cpu) { $tot_cpu = $tot_cpu + $_; } chomp $_; print $_ . \t$tot_cpu\t$tot_mem\n; } -- What are the units on the MEM? Chad --- Chad Leigh -- Shire.Net LLC Your Web App and Email hosting provider chad at shire.net ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
RE: Cacti FreeBSD Jail CPU RAM monitoring
[EMAIL PROTECTED] wrote: On Aug 15, 2006, at 9:16 AM, Philippe Lang wrote: Hi, Based on answers of my first post, I wrote a small perl script in order to find out the CPU and MEMORY used by each jail. Here it is: -- - jls.ps -- #!/usr/bin/perl @jails = `jls`; $title = shift @jails; chomp $title; print $title . \t\t%CPU\t%MEM\n; foreach (@jails) { my ($jid) = /\s+(\S+)\s/; @jexec = `jexec $jid ps -afxu`; @mem = map {/\S+\s+\S+\s+\S+\s+(\S+)\s/} @jexec; shift @mem; $tot_mem = 0; foreach (@mem) { $tot_mem = $tot_mem + $_; } @cpu = map {/\S+\s+\S+\s+(\S+)\s/} @jexec; shift @cpu; $tot_cpu = 0; foreach (@cpu) { $tot_cpu = $tot_cpu + $_; } chomp $_; print $_ . \t$tot_cpu\t$tot_mem\n; } -- What are the units on the MEM? Hi, Just like for a ps -u, but it's here the sum of the percentages of all the processes owned by the jail. The same for %CPU. This might not be very accurate, but it gives a very good idea of which jails are using a lot of memory or cpu. --- Philippe Lang Attik System smime.p7s Description: S/MIME cryptographic signature
RE: Cacti FreeBSD Jail CPU RAM monitoring
Here a better formatted version. #!/usr/bin/perl @jails = `jls`; $title = shift @jails; chomp $title; print $title . \t\t%CPU\t%MEM\n; foreach (@jails) { my ($jid) = /\s+(\S+)\s/; @jexec = `jexec $jid ps -afxu`; @mem = map {/\S+\s+\S+\s+\S+\s+(\S+)\s/} @jexec; shift @mem; $tot_mem = 0; foreach (@mem) { $tot_mem = $tot_mem + $_; } @cpu = map {/\S+\s+\S+\s+(\S+)\s/} @jexec; shift @cpu; $tot_cpu = 0; foreach (@cpu) { $tot_cpu = $tot_cpu + $_; } chomp $_; print $_ . \t; printf('%4.1f', $tot_cpu); print \t; printf ('%4.1f', $tot_mem); print \n; } --- Philippe Lang Attik System smime.p7s Description: S/MIME cryptographic signature
Re: Cacti FreeBSD Jail CPU RAM monitoring
On 8/14/06, Philippe Lang [EMAIL PROTECTED] wrote: Hi, I'd like to use Cacti for CPU and RAM usage monitoring on my FreeBSD Server. Is there a way to do monitoring for each jail independently? I guess the answer is no for CPU usage, but is there a way maybe to get the RAM usage of the processes of each jail? using cacti's scripting ability you actually may be able to get some sort of usefull info. for example, you can use ps auxwl to get some pretty detailed info on process which are in jails (third filed is %CPU, fourth %MEM). it may take a little work to sort out which jail a process resides in - . this method will only work from the master as well. similar tricks can be used inside a jail as well. HTH -pete -- ~~o0OO0o~~ Pete Wright www.nycbug.org NYC's *BSD User Group ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Cacti FreeBSD Jail CPU RAM monitoring
On Aug 14, 2006, at 10:28 AM, pete wright wrote: On 8/14/06, Philippe Lang [EMAIL PROTECTED] wrote: Hi, I'd like to use Cacti for CPU and RAM usage monitoring on my FreeBSD Server. Is there a way to do monitoring for each jail independently? I guess the answer is no for CPU usage, but is there a way maybe to get the RAM usage of the processes of each jail? using cacti's scripting ability you actually may be able to get some sort of usefull info. for example, you can use ps auxwl to get some pretty detailed info on process which are in jails (third filed is %CPU, fourth %MEM). it may take a little work to sort out which jail a process resides in - . this method will only work from the master as well. similar tricks can be used inside a jail as well. Remember you can do things like % jexec NUM /bin/ps from the master to do a ps command inside jail NUM you can get the jail number from the % jls command inside the master. Chad --- Chad Leigh -- Shire.Net LLC Your Web App and Email hosting provider chad at shire.net ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Cacti FreeBSD Jail CPU RAM monitoring
Philippe Lang [EMAIL PROTECTED] wrote: I'd like to use Cacti for CPU and RAM usage monitoring on my FreeBSD Server. Is there a way to do monitoring for each jail independently? I guess the answer is no for CPU usage, but is there a way maybe to get the RAM usage of the processes of each jail? You can monitor the numbers from the ps(1) output per jail, see the other answers in this thread. However, you should be aware of the fact that processes share memory, even when running in different jails. For example, most processes are linked against the standard C library (libc), and its size is included in the size of every process, as reported by ps(1) -- but the code of the library is only loaded once into memory, i.e. it is shared between processes, independent of jails. Best regards Oliver -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. What is this talk of 'release'? We do not make software 'releases'. Our software 'escapes', leaving a bloody trail of designers and quality assurance people in its wake. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]