[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Socket (vistnok) i python ..



On 2011-06-24 11:15, Henrik Jess Nielsen wrote:
> Hej,
>
> Jeg sider med en ide til at lave et lille script som overvåger min DSL
> linie.
>
> Iden går på at lave en ping reqest til en host, og så længe den kan
> pinge forøges en tæller. Nå den så ikke længere kan pinges nulstilles
> tælleren (Lidt ala uptime).
>
> Men jeg ville meget gerne kunne hive dette tal ud via 'cat
> /someSocket' (præcis som man kan med cat /proc/uptime).
>
> Mit problem er jeg ikke helt ved hvad det heder, eller hvad jeg skal
> søge efter - er der nogen som kender en howto eller kan smide et link
> til dokumentation til hvordan sådan noget lavet? (Python 2.6).
>
>
> Jeg har fundet masser sider til hvordan man laver webserver og jeg ved
> ikke hvad, men det virker som et fuldstændigt overkill.
>
> Venlig hilsen
>  Henrik Jess.
Du kan vel bare lade dit script skrive tallet til en fil. Her er et bud
i Bash:


#!/bin/bash

host=www.google.dk
resultfile=/tmp/uptime-counter
sleeptime=5

echo 0 >${resultfile}
while true; do
    if ping -c 1 ${host} >/dev/null 2>&1; then
        cur=$(cat ${resultfile})
        cur=$((cur+1))
        echo $cur >${resultfile}
    else
        echo 0 >${resultfile}
    fi
    sleep ${sleeptime}
done




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-07-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *