Showing posts with label cpu alarm. Show all posts
Showing posts with label cpu alarm. Show all posts

Wednesday, August 7, 2013

CPU Temperature Alarm System

Hi,  I want to write about Cpu Temperature Alarm System I have done by using advantages of linux kernel and linux shell. (I used bash shell in my script by the way.)

One of the biggest advantages of linux is to reach hardware components easily through kernel. The communication with hardware comes true as given in the following steps:

1. User writes his/her request as codes.
2. Shell converts these codes to be understand by kernel.
3. Kernel is a gui which can thought as an interface between hardware and shell. Kernel sends these requests to hardware components.

You can understand these simple steps and more from the following scheme:

I wrote down the following script which can control cpu temperature and if it is out of the condition I have determined, it plays an alarm.
       


The comments about the script are given in the following step by step:

1. I used acpi package to get temperature of cpu from sensors. Info: acpi - Shows battery status and other ACPI information
2. To edit the output of acpi -t command and get the cpu temperature only, I used gawk package. Info: gawk - pattern scanning and processing language
3. I wrote the cpu temperature with echo
4. I used an if-else-fi block for control part.
5. If it is lower than 90 C, I wrote down the message: "no dangere."
6. If it is higher than 90 C, I wrote down the message: "cpu is in dangere!" and play the alarm.

If you like this article, use the share buttons below to help my blog.
If you have any question or need some help, leave a comment below.

SPONSOR
-->
Read More

Thursday, July 25, 2013

CPU Sıcaklık Alarmı Sistemi



Merhabalar, bu yazımda linux kernel ve linux shell in verdiği harika avantajlardan faydalanarak yaptığım CPU Sıcaklık Alarmı Sistemini anlatmak istedim.

Linux un bize sağladığı en büyük avantajlardan biri kolaylıkla hardware bileşenlerine ulaşabilmemizdir. Hardware ile iletişim şu şekilde gerçekleşir :

1. Kullanıcı isteklerini kodlar halinde yazar.
2. Shell bu kodları linux kernel in anlayabileceği dile çevirir.
3. Kernel ise hardware ile shell arasındaki iletişimi sağlayan bir nevi arayüz diyebileceğimiz bir sistemdir. Kernel bu istekleri hardware bileşenlerine iletir.

Bu basit adımları ve daha fazlasını şema olarak aşağıdaki resimden anlayabilirsiniz..

Resimden görüldüğü gibi linuxtaki uygulamalarda çalışırken önce shell ve user ile iletişime geçerler. Daha sonra shell uygulamanın isteklerini kernel e anladığı dilde iletir. Kernel de bu istekleri hardware bileşenlerine iletir. 

Düşündüm ki madem böyle o zaman:

1. CPU nun sıcaklığı için önce cpu nun sıcaklığını ölçen bir hardware bileşenimiz olan sensörlere ulaşmam lazım. Linux ta bu işi yapan basit komut : 'acpi -t' komutudur.
2. Sensors komutu şu şekilde bir çıktı verecektir: 
Thermal 0: ok, 46.0 degrees C
Buradaki 46.0 değeri cpu nun santigrat cinsinden sıcaklığıdır. 
3. Bu cevapta benim ihtiyacım olan sadece 46.0 değeridir. Bu değeri bu satırdan çekmek için ise şu komutu kullandım: awk '{print $4}'.. Herhangi bir linux dağıtımı kullanıyorsunuz, illa ki awk ı duymuşsunuzdur. Awk dilleri ya da yazıları scan ve process etme pattern idir. Benim bu adımda yaptığım gibi.( 46.0 değerini şu cevaptan çektik>>Thermal 0: ok, 46.0 degrees C)
4. Daha sonraki adımda kendi belirleyeceğim bir değerle cpu sıcaklığını karşılaştırıp, bir alarm zili çaldırmak istedim. (Eğer cpu sıcaklığı benim belirlediğim değerden yüksek ise.). Bu basit karar verme bloku için tabiki 'if else fi ' blokları yardımımıza koşacaktır. 
5. Dördüncü adımda bir alarm zili çaldırmak istediğimi söylemiştim. Bunu sağlamak için sox paketini kullandım. Sox paketindeki play komutu .wav vb. dosyaları çalıştırmamızı sağlar.

Anlattığım bu adımları gerçekleştirdiğim scripti aşağıda görebilirsiniz. Script doğru bir şekilde çalışıyor..


 Herhangi bir sorunuz ya da yardıma ihtiyacınız varsa, aşağıya yorum bırakabilirsiniz.
 Yazıyı beğendiyseniz,  beğen butonlarını kullanarak bloguma destek verebilirsiniz.




Read More