#!/usr/bin/env perl $|=1; use lib "../../lib"; use HotSaNICparser; use HotSaNICmod; my $MODLOGDIR="."; my $MODPIDFILE="running.pid"; my $MODNAME=HotSaNICparser::get_module_name(); checkargs(@ARGV); ###################################################################### # # wrapper # sub sample { if (-e "./read-data") { system ("nice -5 ./read-data"); } elsif (-e "./read-data.pl") { system ("nice -5 ./read-data.pl"); } } sub update { } ###################################################################### # # fork into background # sub daemonize { my ($MODPIDFILE,$MODNAME,$MODLOGDIR)=@_; # set signal handlers # $SIG{TERM} = \&terminate; $SIG{HUP} = \&configure; $SIG{USR1} = \&sample; $SIG{USR2} = \&update; $MODLOGDIR=""; # open STDIN,"/dev/null"; # open STDOUT,">>$MODLOGDIR"."/mod_$MODNAME.log"; # open STDERR,">>$MODLOGDIR"."/mod_$MODNAME.log"; # chdir "/"; fork && exit 0; } ###################################################################### # # terminate module daemon # sub terminate { HotSaNICmod::dupe_control("stop",$MODNAME,""); unlink $MODPIDFILE if -e $MODPIDFILE; # close STDIN; # close STDOUT; # close STDERR; exit 0; } ###################################################################### # # check cmdline arguments # sub checkargs { $args=join " ",@_; if ( $args eq "" ) { print "arguments missing!\n"; print "usage: $0 [start/stop/status/version]\n"; } if ( $args =~ /version/) { print "wrapper script\n"; } if ( $args =~ /start/) { my ($pid,$uptime)=HotSaNICmod::dupe_control("check",$MODNAME,""); if ($pid > 0) { print "$MODNAME already running on PID $pid\n"; } else { daemonize($MODPIDFILE,$MODNAME,$MODLOGDIR); HotSaNICmod::dupe_control("start",$MODNAME,""); while (1 == 1) { sleep; } } } if ( $args =~ /status/) { my ($pid,$uptime)=HotSaNICmod::dupe_control("check",$MODNAME,""); print "$MODNAME running on PID $pid for $uptime sec.\n"; } if ( $args =~ /sample/) { my ($pid,$uptime)=HotSaNICmod::dupe_control("check",$MODNAME,""); if ($pid > 0) { kill "SIGUSR1",$pid; } else { print "no process running.\n"; } } if ( $args =~ /stop/) { my ($pid,$uptime)=HotSaNICmod::dupe_control("check",$MODNAME,""); if ($pid > 0) { kill "SIGTERM",$pid; } else { print "no process running.\n"; } } }
WebSVN - hotsanic - Blame - Rev 26 - /branches/HotSaNIC-0.5.0-pre6/tools/read-data-wrapper.pl
Català-Valencià - Catalan
Česky - Cesky
Dansk - Dansk
Dutch - Dutch
English - English
Finnish - Finnish
Français - Francais
Deutsch - German
עברית - Hebrew
Magyar - Hungarian
Bahasa Indonesia - Indonesian
Italiano - Italian
日本語 - Japanese
한국어 - Korean
Norsk - Norwegian
Polski - Polish
Português - Portuguese
Português - Brazilian Portuguese
Русский - Russian
中文 - Simplified Chinese
Slovenčina - Slovak
Slovenčina - Slovenian
Español - Spanish
Svenska - Swedish
中文 - Traditional Chinese
Türkçe - Turkish
Oëzbekcha - Uzbek
hotsanic
Subversion Repositories:
banderdyn
centos.prosek.czf
crusader
czf4bfu
czf4bfu.prosek.czf
czfcentos
czfgmap
discover
fedora.prosek.czf
freenet-router
ftth
getonlineclouds
hotsanic
internet.prosek.czf
is
mapstats
meteolinger
netmap
qos
sedlo
sedlo.prosek.czf
switches
vbtobb
vlubnt
weathermap
weatherstats
websvn
wifidashboard
wifimon
www.prosek.czf
xenstats
[
/
] [
branches/
] [
HotSaNIC-0.5.0-pre6/
] [
tools/
] [
read-data-wrapper.pl
] - Blame information for rev
26
Line No.
Rev
Author
Line
Powered by
WebSVN
2.2.1