Re: [Linux] CPU sicakligi hangi program gosterir? (SUSE 10.0)

---------

New Message Reply About this list Date view Thread view Subject view Author view Attachment view

From: Ömer F. USTA (omerusta@gmail.com)
Date: Mon 05 Dec 2005 - 15:52:27 EET


Selam
Alin size 2 sn once yazdigim uyduruk kod :D
(Hayatimda belkide yazdigim en aceleye gelmiş kodlardan biridir :D )

/* Programmed by Ömer Fadıl USTA <omerusta@gmail.com>
    Licensed under GNU GPL v2 or above :D
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
    FILE *ptr_file;
    char s[100];
    char c_temp[10];
    int temp=0,count=1,ix=0;
    ptr_file= fopen("/proc/acpi/thermal_zone/THRM/temperature","r");
    if(!ptr_file)
        return 1;

    while(fgets(s,100,ptr_file)!=NULL);
    fclose (ptr_file);
    for (count=0;count< (strlen(s)-1);count++)
    {
        if(isdigit(s[count]))
        {
            c_temp[ix]=s[count];
            ix++;
        }
    }
    c_temp[ix]='\0';
    temp=atoi(c_temp);

    printf("%d",temp);

    return 0;
}

yukaridaki kodu sicaklik.c isminde kayit edin. sonra
gcc -Wall sicaklik.c -o sicaklik.elf
bu size sicaklik.elf isminde bir dosya olusturacaktir.
sonra ne zaman calistirirsaniz size o anki islemci sicakligini verecektir
./sicaklik.elf seklinde yani

şimdi bunu aliyoruz normal userlarin yazma yetkisinin olmadigi bir yere
koyuyoruz. ( uzerine abuk subuk seyler yazipta sistemi
hackletmeyek dimi ama :D )

chmod 700 sicaklik.elf yapiyoruz. sonra diger kullanicilarin uzerinde
oynama yapamayacagi bir yere sallayin

sonra
if [ `/abc/sicaklik.elf` -ge 75 ];then shutdown -h now ; fi
bu komut /abc altindaki sicaklik programimizin bize verecegi degeri 75 ile
karsilastirip bunun 75 e esit veya daha fazla olmasi durumunda
shutdown -h now
komutunu islediyor

Sonra isterseniz bu komutu 2 dk bir calistiran bir is haline getirmek icin
/etc/crontab icine
* */2 * * * if [ `/abc/sicaklik.elf` -ge 75 ];then shutdown -h now ; fi
seklinde ekleyebiliriz.

Not: Bu program ve anlatimda belki ufak hatalar olmustur. Uygulanmasi
durumunda hicbir mesuliyet kabul etmiyorum:D

--
Ömer Fadıl USTA
http://www.bilisimlab.com/

_______________________________________________
Linux mailing list
Linux@liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux


New Message Reply About this list Date view Thread view Subject view Author view Attachment view

---------

Bu arsiv hypermail 2.1.2 tarafindan uretilmistir.