Application: Linux System Script


Recommended Posts

Hi Haggis, getting a couple of bugs on Arch:

First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.

Second, line 61 which greps for the "-release" files doesn't work right. It lists the contents of /etc okay, but seems to get stuck searching my entire home directory for something. Quick check seems that its trying to run the command:

grep -r -e -l -e -a -s -e

I've seen this before with grep, and I think it might be a bug thats there for historical reasons or something. Either way, the fix would be to use 'grep "\-release"' instead. The backslash stops grep from bugging out.

Here's the patch for the bugs, tested on Arch only, so others will need to test for their own OS...

*** stats.sh	2012-12-23 23:59:10.000000000 +0000
--- copy of stats.sh	2013-01-06 22:54:01.409394805 +0000
***************
*** 58,64 ****
  # Print a pretty logo for the Linux distribution the user is running.
  function print_logo
  {
! exists=`ls /etc/ | grep "-release" | wc -l`
  if [ "$exists" -gt "0" ]; then
  #if [ -e /etc/*-release ]; then
	  id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
--- 58,64 ----
  # Print a pretty logo for the Linux distribution the user is running.
  function print_logo
  {
! exists=`ls /etc/ | grep "\-release" | wc -l`
  if [ "$exists" -gt "0" ]; then
  #if [ -e /etc/*-release ]; then
	  id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
***************
*** 242,248 ****
	  res=$(xdpyinfo | grep dimensions | awk {'print $2'})
	  load=$(uptime | awk -F 'load average:' '{ print $2 }')
	  # AFAIK there is no standard identification strings between CPU architectures.
!	 case $(arch) in
		  x86_64|i386|i486|i586|i686)
			  cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
			  ;;
--- 242,248 ----
	  res=$(xdpyinfo | grep dimensions | awk {'print $2'})
	  load=$(uptime | awk -F 'load average:' '{ print $2 }')
	  # AFAIK there is no standard identification strings between CPU architectures.
!	 case $(uname -m) in
		  x86_64|i386|i486|i586|i686)
			  cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
			  ;;

Also, I have made for myself a PKGBUILD for this script so that I could install your script into the Arch package system. Would you like me to submit it as an AUR package that all Arch users can install and run it as the command "haggis-stats"?

First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.

I admit, that bug was introduced in a patch I submitted a while back. I do not run Arch Linux, and, therefore, didn't test my patch against it. I do find it slightly ironic that Arch Linux doesn't ship the arch utility, if for no other reason than their namesake!

Hey guys i have a problem

the lsb-release package is not on all distros so i need your help

can you post the output of


cat /etc/issue
[/CODE]

and also tell me the Distro your running

Max does my script pick up Gentoo ok?

Works for the most part, a few errors at the beginning, but it's not running an X server or DE either like my previous posts. (No lsb_release, xdpyinfo or mate-session.) Displays the Tux penguin for its ASCII art. The OS field comes up as blank however.

One more, finally got around to toying with the latest release. (Fine, I'll use one of these new fangled graphical thingies instead of my usual consoles.)

Chakra Linux (2013.01.03 - Claire) \r  (\n) (\l)

./stats.sh: line 245: arch: command not found


				 .88888888:.				
				88888888.88888.			
			  .8888888888888888.			
			  888888888888888888			
			  88| _`88|_  `88888			
			  88 88 88 88  88888			
			  88_88_::_88_:88888			
			  88:::,::,:::::8888			
			  88`:::::::::``8888			
			 .88  `::::`	8:88.		  
			8888			`8:888.		
		  .8888`			 `888888.	  
		 .8888:..  .::.  ...:`8888888:.	
		.8888.|	 :|	 `|::`88:88888	
	   .8888		`		 `.888:8888.  
	  888:8		 .		   888:88888  
	.888:88		.:		   888:88888:  
	8888888.	   ::		   88:888888  
	`.::.888.	  ::		  .88888888	
   .::::::.888.	::		 :::`8888`.:.  
  ::::::::::.888   |		 .::::::::::::  
  ::::::::::::.8	|	  .:8::::::::::::.
.::::::::::::::.		.:888:::::::::::::
:::::::::::::::88:.__..:88888:::::::::::`  
  ``.:::::::::::88888888888.88:::::::::`	
		``:::_:` -- `` -`-` ``:_::::``	  


	OS: Chakra Linux
	Hostname: vm12
	Uptime: 17 minutes
	CPU:Unknown
	RAM (used / total): 477 / 2006 Mb
	Desktop Enviroment: KDE 4.9.5
	Logged in as: maxnorris
	Kernel: 3.6.6-1-CHAKRA
	Resolution: 1680x944 pixels
	Load Averages: 0.63, 0.53, 0.23
	Top Process (by memory use): kdeinit4:

This run didn't pick up the CPU, even though /proc/cpuinfo has correct info. (*shrug* it's a VM, but it picked it up with other distros properly.)

ok so what does this give you

cat /proc/cpuinfo | grep 'model name[/CODE]

[code][maxnorris@vm12 ~]$ cat /proc/cpuinfo | grep 'model name'
model name	  : Intel(R) Core(TM)2 Duo CPU	 E8400  @ 3.00GHz
model name	  : Intel(R) Core(TM)2 Duo CPU	 E8400  @ 3.00GHz

  • 4 weeks later...

Despite the fact that OS X and GNU/Linux are both UNIX-ey, most of the stuff that Haggis implemented in the script are actually Linux specific. For example, OS X has no /proc/cpuinfo or lsb_release (Linux Standard Base release information).

Also, the script is implemented in BASH. While virtually every modern Linux distribution has BASH 4.0 or greater, OS X is stuck on the ancient BASH 3, which doesn't have many of the BASHisms modern scripts rely on. (For example, I have BASH 4.2 on Debian 7, but even Debian 6 has 4.1.)

That said, I didn't write the script; Haggis did. Its up to him whether he wants to support it. Although, if you patched it to work on OS X and submitted the diff, he would probably be willing to accept it.

Aren't there Mac OS X alternatives to accomplish the same tasks perhaps an alternative script as a port or something is in order; something could use "awk", "grep", and "tail" and such against "uname" and such to aquire info? Or against "system_profiler | more"

By the way...


Ryans-MacBook-Air:~ ryan$ uname -a
Darwin Ryans-MacBook-Air.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
Ryans-MacBook-Air:~ ryan$ bash -version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
Ryans-MacBook-Air:~ ryan$
[/CODE]

Glad you like it

As per above only issue i have with making it work on MAC etc is i have no way of testing it

Still working on making it better and more sleek too

  • 8 months later...
  • 2 years later...
28 minutes ago, Haggis said:

Not used centos but it should work fine

 

It wont log anything though it just displays real time

Would you be able to add a bandwidth logger? After 24 hours record it, at the end of the month it displays the total bandwidth used.

 

Trying to figure out how to do that, and have those stats posted on our website. I suck at coding right now :(

it would mean running the script in the back ground or taking a snapshot

 

sort of like a "bandwidth used since last run"

 

there are much better apps for this though :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Chrome is Google's commercial web browser product; it consists of their proprietary features (Googlified everything including profile sync) plus their chromium project barebones web browser. Google developers control the chromium project. The chromium project is the "core" for the web browser product from other vendors including Microsoft Edge (their own proprietary features), Opera (their own features), Brave (their own features), etc... The "downstream" teams at Microsoft, Opera, Brave, etc., can either integrate their original MV2-supporting code into future builds, or they can integrate chromium wholesale and simply add-on their own features/functionalities -- their 'current' build pipeline, so to speak. THIS is why changes at the chromium project affect so many products besides only Google's commercial Chrome browser. -- Edit to add: The chromium project is open-source, and is the piece that's Google's code contribution to the W3C and world wide web at large; there are no licensing fees for others to use the code in their own products... which is what they do. Other browser engines do exist (Firefox's for example) but it's nearly impossible to have both engines bundled into the same 1 browser product.
    • You're comparing settler colonies to colonized war torn nations. It's easy to become the richest by coming in and stealing other people's land, culture and resources.
    • ABP has become "old news" when MV3 started rolling out. They've gone downhill and is now simply irrelevant..... in my experience.
    • About two years ago, I switched to Brave and haven't looked back.
    • FWIW StatCounter has been trash for over 25+ years! Back in the day (circa 2000 and GeoCities pre-Blogger era), it was useful to paste a number on your webpage indicating how many visitors you had. In the ensuing 25+ years, they've grown in reputation and changed their ways... but their overall consumer value has remained abysmal. Serious marketing agencies only cite StatCounter when there's literally no other sources available to support any marketing claims! They are the absolute lowest threshold serious companies use to push any sort of narrative about this-or-that happening. Besides their credibility being what it is, they are forever subject to quality issues. They're so bad that my DNS-level ad-filter prevents me from even viewing their main website! HA!
  • Recent Achievements

    • Week One Done
      rubentuben8 earned a badge
      Week One Done
    • Week One Done
      ARaclen earned a badge
      Week One Done
    • One Year In
      jojodbn earned a badge
      One Year In
    • One Month Later
      jojodbn earned a badge
      One Month Later
    • Week One Done
      jojodbn earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      531
    2. 2
      PsYcHoKiLLa
      231
    3. 3
      +Edouard
      131
    4. 4
      ATLien_0
      88
    5. 5
      Steven P.
      81
  • Tell a friend

    Love Neowin? Tell a friend!