3

After seeing a question here

I want to have a configuration in my Ubuntu system so that if the cpu processing exceeds 90%, it gives a beep sound. Is this possible?

Also, where else can this beep sound be used? Can it be used if the hard disk utilisation exceeds 80% ?

Tarun
  • 4,245
  • 13
  • 50
  • 74

2 Answers2

5

I want to have a configuration in my Ubuntu system so that if the cpu processing exceeds 90% it gives a beep sound. Is this possible?

Yes. I wrote a script that plays a notification sound when CPU load average exceeds 90% (accounting for all cores).

The system speaker is, by default, disabled on Ubuntu systems, hence using one of the standard notification sound seems a better choice for this.

To run it, simply download the script (save it as notify-highload.sh), and copy to your home directory. Then, from a terminal, run chmod +x ./notify-highload.sh, followed by ./notify-highload.sh -ag &.

If you want it to run every time on start up, add the script to your Startup Applications.

Also, where else can this beep sound be used? like can it be used if the Hard Disk space exceeds 80%.

Yes, it can. I wrote a script available here.

I will add a few more later on.

asheeshr
  • 783
  • Thanks for the answer, this script when initiated will automatically run in the cycle of 5 seconds to check the cpu load? – Tarun Sep 23 '13 at 04:53
  • Yes. You can change the duration if you like. – asheeshr Sep 23 '13 at 04:55
  • Is there any other way as well other than using a shell script which sleeps for 5 seconds. I hope it wouldn't increase the cpu load due to it? – Tarun Sep 25 '13 at 06:18
  • Any way of checking will involve either some script or a daemon or a full fledged application. It will obviously have an overhead involved, but the overhead is almost negligible. – asheeshr Sep 25 '13 at 06:51
  • What's the use of set command here? why use it? Thanks – Tarun Sep 26 '13 at 08:10
  • @Tarun Its to extract the load averages from list. Also, I have extended the script by adding lots of customization options. I will write a similar utility for hard drive utilisation later today. You can find detailed instructions and the next script here. – asheeshr Sep 28 '13 at 06:03
  • @AsheeshR , 1 you've mentioned "The system speaker is, by default, disabled on Ubuntu systems," in your answer. Could you please elaborate on that? Is that why there's no longer the login sound? 2I will be trying your script a little later today. You haven't specified any OS or desktop environment in here. I want to try it in Lubuntu 13.04. –  Oct 09 '13 at 03:43
  • @AsheeshR, is there an alternative to paplay (line 92) and perhaps you could include a comment about the source of the sound file. For example, I have /usr/share/sounds/alsa and /usr/share/sounds/freedesktop/stereo but I don't have /usr/share/sounds/ubuntu/.... –  Oct 09 '13 at 05:07
  • @vasa1 I was referring to the inbuilt PC speaker/beeper. The login sound is not connected to that. Added OS settings. I have a netbook running single boot Ubuntu 12.04, so thats the only config for which its been tested. paplay is the frontend for Pulse Audio which is a almost a POSIX standard audio server running on all POSIX compliant distros. Its unlikely that any distro wont have it. – asheeshr Oct 09 '13 at 10:27
  • As far as the specific audio file is concerned, I really cant find the exact location on multiple distros. I can incorporate it into the script if you tell me the exact location for the audio files, and any one audio file which is suitable as a notification sound. If it works on your distro, then do mention it on the repo. – asheeshr Oct 09 '13 at 10:43
  • @AsheeshR, https://github.com/AsheeshR/Bash-Scripts/issues/1 –  Oct 09 '13 at 11:37
0

Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

What Monit can do

You can use Monit to monitor daemon processes or similar programs running on localhost. Monit is particular useful for monitoring daemon processes, such as those started at system boot time from /etc/init.d/. For instance sendmail, sshd, apache and mysql.

In difference to many monitoring systems, Monit can act if an error situation should occur, e.g.; if sendmail is not running, Monit can start sendmail again automatically or if apache is using too much resources (e.g. if a DoS attack is in progress) Monit can stop or restart apache and send you an alert message. Monit can also monitor process characteristics, such as; how much memory or cpu cycles a process is using.

You can also use Monit to monitor files, directories and filesystems on localhost. Monit can monitor these items for changes, such as timestamps changes, checksum changes or size changes. This is also useful for security reasons - you can monitor the md5 or sha1 checksum of files that should not change and get an alert or perform an action if they should change.

Monit can monitor network connections to various servers, either on localhost or on remote hosts. TCP, UDP and Unix Domain Sockets are supported. Network test can be performed on a protocol level; Monit has built-in tests for the main Internet protocols, such as HTTP, SMTP etc. Even if a protocol is not supported you can still test the server as you can configure Monit to send any data and test the response from the server.

Monit can be used to test programs or scripts at certain times, much like cron, but in addition, you can test the exit value of a program and perform an action or send an alert if the exit value indicates an error. This means that you can use Monit to perform any type of check you can write a script for.

Finally, Monit can be used to monitor general system resources on localhost such as overall CPU usage, Memory and Load Average.

Download: Install via the software center

Install with Ubuntu Software Center: Monit Install monit

Rinzwind
  • 299,756