Anonymous

Project:LHS Graphs and Visualizations: Difference between revisions

From London Hackspace Wiki
Line 82: Line 82:
   </api>
   </api>


Perl to generate the following output for cacti: '''<tt>pages:759 articles:215 views:229656 edits:7368 images:186 users:166 activeusers:22 admins:61 jobs:13</tt>'''


  #!/usr/bin/perl
A Perl script generates the following output for cacti: '''<tt>pages:759 articles:215 views:229656 edits:7368 images:186 users:166 activeusers:22 admins:61 jobs:13</tt>'''
 
 
  use strict;
'''Code:''' https://github.com/londonhackspace/monitoring
  use LWP::Simple;
  use XML::Simple;
 
  eval {
    my $file = get("http://wiki.hackspace.org.uk/w/api.php?action=query&meta=siteinfo&siprop=statistics&format=xml");
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
    my $first = 1;
 
    foreach my $key (keys (%{$doc->{query}->{statistics}})){
      if ($first eq 1) {
        $first = 0;
      } else {
        print " ";
      }
      print $key . ":" . $doc->{query}->{statistics}->{$key};
    }
    1;
  } or do {
    print "NaN";
  }


====IRC statistics====
====IRC statistics====
1,649

edits