diff options
| author | beatrice <beatrice@dangofactory.net> | 2026-11-22 20:00:14 +0900 |
|---|---|---|
| committer | beatrice <beatrice@dangofactory.net> | 2026-11-22 20:00:14 +0900 |
| commit | 8f68d02045982da8f00a559835b500caf3a1967d (patch) | |
| tree | c8d0e92969b92e1b6559a0e032b6aa710a8ae2d9 /contrib/ircstats2 | |
| parent | bb5ff95073e5001be7dbf58ffce80d7926deff0b (diff) | |
| download | mrtg-master.tar.gz mrtg-master.zip | |
Diffstat (limited to 'contrib/ircstats2')
| -rw-r--r-- | contrib/ircstats2/README | 38 | ||||
| -rwxr-xr-x | contrib/ircstats2/crontab.script | 45 | ||||
| -rw-r--r-- | contrib/ircstats2/example.cf | 38 | ||||
| -rwxr-xr-x | contrib/ircstats2/ircstats2.pl | 213 |
4 files changed, 334 insertions, 0 deletions
diff --git a/contrib/ircstats2/README b/contrib/ircstats2/README new file mode 100644 index 0000000..f8b2e9a --- /dev/null +++ b/contrib/ircstats2/README @@ -0,0 +1,38 @@ +ircstats2.pl v1.3 (06/04/2001) + +ircstats2.pl is a perl script I use to monitor +the user load of the Langochat.net IRC Network. +- Lucas Nussbaum <lucas@schickler.net> +Homepage : http://www.schickler.net/lucas/ircstats2/ + +Usage : + +All the configuration is done in ircstats2.pl. +You can look at example.cf to learn how to configure mrtg with this script. +To restart the script if it crashes (this soft is supposed to be bug-free, +so that shouldn't happen), you can use the crontab script included. + +Changes : + +1.3 (21/03/2001) + - Now counts servers and ircops too. +1.2 (25/01/2001) + - Better calculation of the global user load, when the list of servers + isn't up to date. + - Now counts the number of channels too :) + - Can display the global users and channels count in plain text file, + enabling those files to be used in other scripts. + +1.1 (24/08/2000) + - Initial public release + +Licence : + +This software is subject to the + + GNU GENERAL PUBLIC LICENCE version 2 or above + +It can be found on http://www.gnu.org/copyleft/gpl.html + +However, if you modify something in this script, I would strongly appreciate +that you send me a copy. diff --git a/contrib/ircstats2/crontab.script b/contrib/ircstats2/crontab.script new file mode 100755 index 0000000..b21f2f5 --- /dev/null +++ b/contrib/ircstats2/crontab.script @@ -0,0 +1,45 @@ +#! /bin/sh +# +# Crontab script for ircstats2 +#------------------------------ +# You can use that script to check whether the stats generation script is +# running. +# +# No bugs are known in this software. So if it crashes, please tell me, even if +# you don't know anything about the crash ! +# +# To check for your script every 10 minutes, put the following line in your +# crontab: +# 0,30 * * * * /home/mydir/crontab.script +# And if you don't want to get email from crontab when it checks you script, +# put the following in your crontab: +# 0,30 * * * * /home/mydir/crontab.script >/dev/null 2>&1 +# + +# change this to the directory you run the script from: +ircstatsdir="/home/lucas/ircstats2" + +########## you probably don't need to change anything below here ########## + +cd $ircstatsdir + +if test -r ircstats2.pid +then + pid=`cat ircstats2.pid` + if `kill -CHLD $pid >/dev/null 2>&1` + then + exit 0 + fi + echo "" + echo "Stale ircstats2.pid file, erasing..." + rm -f ircstats2.pid +fi + +echo "" +echo "ircstats2.pl restarting ..." +echo "This software is supposed to be bug-free. If the bot has to restart," +echo "and if that's not for a good reason (server reboot for example), please notify" +echo "the author (lucas@schickler.net) even if you don't know why the script crashed." + +./ircstats2.pl +exit 0 diff --git a/contrib/ircstats2/example.cf b/contrib/ircstats2/example.cf new file mode 100644 index 0000000..06bcdf3 --- /dev/null +++ b/contrib/ircstats2/example.cf @@ -0,0 +1,38 @@ +WorkDir: /home/lucas/public_html/mrtg + +Refresh: 300 +Interval: 5 +WriteExpires: Yes +IconDir: images/ +RunAsDaemon: Yes + +#..................................................................... +# Default settings + +MaxBytes[_]: 10000 +Options[_]: gauge, noinfo, nopercent, integer, growright +Background[_]: #FFFFC0 +YLegend[_]: Users +WithPeak[_]: wym +ShortLegend[_]: Users +Legend1[_]: Users +Legend2[_]: +Legend3[_]: Max Users +Legend4[_]: +LegendI[_]: Users : +Colours[_]: BLUE#0000FF,BLUE#0000FF,LIGHT BLUE#C0C0FF,LIGHT BLUE#C0C0FF + +Target[global]: `cat /home/lucas/ircstats2/temp/globalusersmrtg` +Title[global]: Irc.Kewl.Org User Load +LegendO[global]: +PageTop[global]: <H2>Irc.Kewl.Org User Load</H2><TABLE> + <TR><TD>Stats Maintainer :</TD><TD><A HREF="mailto:Lucas@Kewl.Org">Lucas@Kewl.Org</A></TD></TR> + </TABLE> + +Target[angers]: `cat /home/lucas/ircstats2/temp/angers.fr.eu.kewl.org` +Title[angers]: Angers.FR.EU.Kewl.Org User Load +LegendO[angers]: +PageTop[angers]: <H2>Angers.FR.EU.Kewl.Org User Load</H2><TABLE> + <TR><TD>Stats Maintainer :</TD><TD><A HREF="mailto:Lucas@Kewl.Org">Lucas@Kewl.Org</A></TD></TR> + </TABLE> + diff --git a/contrib/ircstats2/ircstats2.pl b/contrib/ircstats2/ircstats2.pl new file mode 100755 index 0000000..370aec0 --- /dev/null +++ b/contrib/ircstats2/ircstats2.pl @@ -0,0 +1,213 @@ +#!/usr/bin/perl +# ircstats2.pl v1.3 06 Apr 2001 Lucas Nussbaum <lucas@schickler.net> +# More info can be found on http://www.schickler.net/lucas/ircstats2.php +# based on ircstats from Matt Ramsey (MR227) mjr@geeks.org, mjr@nin.com +# Used to generate stats on the Kewl.Org IRC Network +# If you see something that should be changed, please notify me ! + +use Socket; + +# pseudo-client parameters +$nick = "StatsMaker234"; +$ident = "Stats"; +$realname = "http://www.schickler.net/lucas/"; + +# server and port to connect to +$ircserver = "127.0.0.1"; +$ircport = "6667"; + +# Where to store the output data (directory MUST exist) +# The number of users on each server will be in a file named like the server. +# An additionnal file named 'global' will be created, containing the sum of +# all servers' users. +# An example configuration file is included. +$datapath = "/home/lucas/ircstats2/temp"; + +# Where to put the PID file +$pidfile = "/home/lucas/ircstats2/ircstats2.pid"; + +# NOTE: Set those variables to 0 to enable, put a # in front of the +# lines to disable. +# Count the global number of users in "globalusersmrtg" file (MRTG format) +$globalusersmrtg=0; +# Count the channels in "channelsmrtg" file (MRTG format) +$channelsmrtg=0; +# Count the global number of ircops in "ircopsmrtg" file (MRTG format) +$ircopsmrtg=0; +# Count the number of servers in "serversmrtg" file (MRTG format) +$serversmrtg=0; +# Count the global number of users in "globalusersplain" file +# (Plain text, to be used with others scripts) +$globalusersplain=0; +# Count the channels in "channelsplain" file (Plain text, +# to be used with others scripts) +$channelsplain=0; +# Count the global number of ircops in "ircopsplain" file +# (Plain text, to be used with others scripts) +$ircopsplain=0; +# Count the number of servers in "serversmrtg file (MRTG format) +$serversplain=0; +# ircops number offset (not to count services, for example) +$ircopsoffset=0; +# servers number offset (not to count services, for example) +$serversoffset=0; + +# Servers to poll +$server{"cybernet.langochat.net"}=0; +$server{"sicfa.langochat.net"}=0; +$server{"free.langochat.net"}=0; +$server{"jeuxgroup.langochat.net"}=0; +$server{"diligo.langochat.net"}=0; + +############################################## +### DO NOT MODIFY ANYTHING BELOW THIS LINE ### +############################################## + +print "Now daemonizing ...\n"; +&daemonize; + +if (!(($globalusersmrtg eq "")&&($globalusersplain eq "")&&($channelsmrtg eq "")&&($channelsplain eq "")&&($ircopsmrtg eq "")&&($ircopsplain eq "")&&($serversplain eq "")&&($serversmrtg eq ""))) { + $needlusers=1; +} +($g, $g, $proto) = getprotobyname("tcp"); +while (true) { + ($g, $g, $g, $g, $rawserver) = gethostbyname($ircserver); + if ($rawserver) { + $serveraddr = pack("Sna4x8", 2, $ircport, $rawserver); + socket(SOCKET, AF_INET, SOCK_STREAM, $proto) || die "No socket: $!"; + if (connect(SOCKET, $serveraddr)){ + select(SOCKET); $| = 1; + select(STDOUT); $| = 1; + print SOCKET "USER $ident a b :$realname\n"; + print SOCKET "NICK $nick\n"; + while (<SOCKET>){ + @i = split(" ",$_); + if ($i[1] eq "433") {print SOCKET "NICK ".$nick.time()."\n";} + elsif ($i[1] eq "437") {print SOCKET "NICK ".$nick.time()."\n";} + elsif ($i[1] eq "376") {&getinfo;} + elsif ($i[1] eq "402") {$server{lc($i[3])}=0;} + elsif ($i[1] eq "265") { + $i[0]=~s/\://; + $server{lc($i[0])}=$i[6]; + } + elsif ($i[1] eq "266") { + if ($globalusersmrtg ne "") { + $globalusersmrtg=$i[6]; + } + if ($globalusersplain ne "") { + $globalusersplain=$i[6]; + } + } + elsif ($i[1] eq "254") { + if ($channelsmrtg ne "") { + $channelsmrtg=$i[3]; + } + if ($channelsplain ne "") { + $channelsplain=$i[3]; + } + } + elsif ($i[1] eq "251") { + if ($serversmrtg ne "") { + $serversmrtg=$i[11]-$serversoffset; + } + if ($serversplain ne "") { + $serversplain=$i[11]-$serversoffset; + } + } + elsif ($i[1] eq "252") { + if ($ircopsmrtg ne "") { + $ircopsmrtg=$i[3]-$ircopsoffset; + } + if ($ircopsplain ne "") { + $ircopsplain=$i[3]-$ircopsoffset; + } + } + elsif ($i[0] eq "PING") { + &saveinfo; + print SOCKET "PONG $i[1]\n"; + &getinfo; + } + } + } + close(SOCKET); + } + sleep(120); +} + +sub saveinfo { + foreach $s (keys %server){ + open(OUTPUT,">$datapath/$s"); + print OUTPUT "$server{$s}\n$server{$s}\n$time\n"; + close(OUTPUT); + } + if ($globalusersmrtg ne "") { + open(OUTPUT, ">$datapath/globalusersmrtg"); + print OUTPUT "$globalusersmrtg\n$globalusersmrtg\n$time\n"; + close(OUTPUT); + } + if ($channelsmrtg ne "") { + open(OUTPUT, ">$datapath/channelsmrtg"); + print OUTPUT "$channelsmrtg\n$channelsmrtg\n$time\n"; + close(OUTPUT); + } + if ($serversmrtg ne "") { + open(OUTPUT, ">$datapath/serversmrtg"); + print OUTPUT "$serversmrtg\n$serversmrtg\n$time\n"; + close(OUTPUT); + } + if ($ircopsmrtg ne "") { + open(OUTPUT, ">$datapath/ircopsmrtg"); + print OUTPUT "$ircopsmrtg\n$ircopsmrtg\n$time\n"; + close(OUTPUT); + $ircopsmrtg=0; # raw 252 pas disp si pas opers + + } + if ($globalusersplain ne "") { + open(OUTPUT,">$datapath/globalusersplain"); + print OUTPUT "$globalusersplain"; + close(OUTPUT); + } + if ($channelsplain ne "") { + open(OUTPUT, ">$datapath/channelsplain"); + print OUTPUT "$channelsplain"; + close(OUTPUT); + } + if ($serversplain ne "") { + open(OUTPUT, ">$datapath/serversplain"); + print OUTPUT "$serversplain"; + close(OUTPUT); + } + if ($ircopsplain ne "") { + open(OUTPUT, ">$datapath/ircopsplain"); + print OUTPUT "$ircopsplain"; + close(OUTPUT); + $ircopsplain=0; # raw 252 pas disp si pas opers + } +} + +sub getinfo { + foreach $s (keys %server) { + print SOCKET "lusers * $s\n"; + } + $time=time(); + if ($needlusers==1) { + print SOCKET "lusers\n"; + } +} + +sub daemonize () { + chdir "/" or die "Can't chdir to /: $!"; + open STDIN, "/dev/null" or die "Can't read /dev/null: $!"; + open STDOUT, ">/dev/null" or die "Can't write to /dev/null: $!"; + defined (my $pid = fork) or die "Can't fork: $!"; + if ($pid) { + if ($pidfile) { + open(PIDFILE,">$pidfile"); + print PIDFILE "$pid\n"; + close(PIDFILE); + } + exit; + } + setsid or die "Can't start a new session: $!"; + open STDERR, ">&STDOUT" or die "Can't dup stdout: $!"; +} |
