-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adding scripts contributed by Uwe Steinmann <uwe@steinmann.cx>
for monitoring linux load w/o SNMP and Apple systems battery status with a PMU - incorporating modifications to linux26diskaccess.pl (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=412549)
- Loading branch information
Douglas E. Warner
committed
May 29, 2007
1 parent
77087ad
commit 8b1ac12
Showing
5 changed files
with
190 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# Author: Uwe Steinmann <uwe@steinmann.cx> | ||
|
||
# usage linuxpmu.sh <battery number> <command> | ||
# battery number can be 0 or 1 | ||
# command can be 'charge', 'max_charge', 'current', 'voltage' | ||
|
||
if [ -f /proc/pmu/battery_$1 ]; then | ||
cat /proc/pmu/battery_$1 | grep "^$2 *:" | awk -F: '{print $2}' | ||
else | ||
echo "U" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,82 @@ | ||
#!/usr/bin/perl | ||
# | ||
# linux26diskaccess.pl | ||
# | ||
# reports some disk access counters | ||
# | ||
# # reads issued, # writes issued | ||
# | ||
|
||
use strict; | ||
|
||
### config variables | ||
my $sysblock = "/sys/block"; | ||
### status variables | ||
my $partition = ""; | ||
my $blockdev = ""; | ||
my @fields = (); | ||
my $blockdev = "/sys/block"; | ||
|
||
|
||
### argument processing | ||
if (scalar(@ARGV) != 2 | ||
|| ($ARGV[0] ne "-r" && $ARGV[0] ne "-w") | ||
|| ($ARGV[1] !~ /^\w+(\d+)?$/) | ||
) | ||
if (@ARGV != 2 or | ||
$ARGV[0] !~ /^-[rw]b?$/ or | ||
$ARGV[1] !~ /^\w+(?:\d+)?$/) | ||
{ | ||
print "U\n"; | ||
print "\n"; | ||
print "$0 [-r|-w] <blockDev(N)>\n"; | ||
print " -r: Report Reads\n"; | ||
print " -w: Report Writes\n"; | ||
print "$0 [-r|-rb|-w|-wb] <dev(N)>\n"; | ||
print "\n"; | ||
exit(1); | ||
} # end if not enough parameters | ||
print "Reports disk I/O statistics counters for use as a NetMRG test script.\n"; | ||
print "\n"; | ||
print "Options:\n"; | ||
print " -r Report the number of read operations\n"; | ||
print " -rb Report the number of read blocks\n"; | ||
print " -w Report the number of write operations\n"; | ||
print " -wb Report the number of written blocks\n"; | ||
print " dev(n) Is a relative block device or partition name.\n"; | ||
print " For instance hda, hda1 or md0\n"; | ||
print "\n"; | ||
exit 1; | ||
} | ||
|
||
|
||
### define partitions | ||
$partition = $ARGV[1]; | ||
$blockdev = $1 if ($partition =~ /^(\w+)\d+$/); | ||
### figure out device/partitions | ||
my ($hd, $partition); | ||
if ($ARGV[1] =~ /^(hd\w)\d+$/) | ||
{ | ||
$partition = $ARGV[1]; | ||
$hd = $1; | ||
} # end if hd has a partition | ||
else | ||
{ | ||
$hd = $ARGV[1]; | ||
} # end else hd is just the drive | ||
|
||
|
||
### read info from system block | ||
|
||
# read the data from the correct path | ||
my $path = ""; | ||
if (-e "$sysblock/$blockdev/$partition/stat") | ||
{ | ||
$path = "$sysblock/$blockdev/$partition/stat"; | ||
} | ||
elsif (-e "$sysblock/$partition/stat") | ||
my $path = "$blockdev/$hd"; | ||
$path .= "/$partition" if ($partition ne ""); | ||
$path .= "/stat"; | ||
open(STAT, $path) || die ("U\nERROR: couldn't open $path\n\n"); | ||
my $line = <STAT>; | ||
close(STAT); | ||
chomp($line); | ||
$line =~ s/^\s+//; | ||
my ($read, $readb, $write, $writeb); | ||
if ($partition eq "") | ||
{ | ||
$path = "$sysblock/$partition/stat"; | ||
($read, $readb, $write, $writeb)=(split /\s+/, $line)[0, 2, 4, 6]; | ||
} | ||
else | ||
{ | ||
die ("U\nERROR: couldn't find $partition\n\n"); | ||
($read, $readb, $write, $writeb)=split /\s+/, $line; | ||
} | ||
|
||
# open the path and read the status info | ||
open(STAT, $path) || die ("U\nERROR: couldn't open $path\n\n"); | ||
my $line = <STAT>; | ||
chomp($line); | ||
@fields = split /\s+/, $line; | ||
close(STAT); | ||
|
||
|
||
### output the data | ||
if ($ARGV[0] eq "-r") | ||
{ | ||
print $fields[1]."\n"; | ||
} # end if read statistics | ||
print "$read\n"; | ||
} | ||
elsif ($ARGV[0] eq "-w") | ||
{ | ||
print $fields[5]."\n" if ($partition eq ""); | ||
print $fields[3]."\n" if ($partition ne ""); | ||
} # end if write statistics | ||
else | ||
print "$write\n"; | ||
} | ||
elsif ($ARGV[0] eq "-rb") | ||
{ | ||
print "U\n"; | ||
} # else we don't know what happened | ||
|
||
|
||
print "$readb\n"; | ||
} | ||
elsif ($ARGV[0] eq "-wb") | ||
{ | ||
print "$writeb\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
# Author: Uwe Steinmann <uwe@steinmann.cx> | ||
|
||
# usage linuxload.sh <item> | ||
# item can be 1, 2, or 3 | ||
|
||
if [ -f /proc/loadavg -a "$1" != "" -a $1 -ge 1 -a $1 -le 3 ]; then | ||
cut -d' ' -f$1 /proc/loadavg | ||
else | ||
echo "U" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters