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"?

  On 06/01/2013 at 23:17, Majesticmerc said:

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

  On 07/01/2013 at 11:05, Haggis said:
can you post the output of

cat /etc/issue
[/CODE]

[code]Ubuntu 12.04.1 LTS \n \l

Ubuntu Server.

This is \n.\O (\s \m \r) \t

Gentoo's default, although I've long since changed it.

  On 07/01/2013 at 12:03, Haggis said:
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.)

  On 07/01/2013 at 14:56, Haggis said:
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...
  On 31/01/2013 at 07:49, Yorak said:

Hey man, forgot to test this earlier but it seems to work well. Nice job. Great script. :)

pmNlQA6l.jpg

 

What script is that you were running here? Is the 1st terminal an Arch linux thing, or script? (Or is that Haggis Script?)

  • 2 years later...
  On 22/05/2016 at 06:38, Haggis said:

Not used centos but it should work fine

 

It wont log anything though it just displays real time

Expand  

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

    • Yeah!!!! I was damn well shocked to see the tab with previous file open when I clicked on the new file. It had private info and I was opening another file to show another person. That was weird
    • The article says the whole setup is about the size of a pencil case which sounds pretty portable to me.
    • I thought router has to have 6 Ghz band to be called wifi-7, guess I was wrong...
    • I have the Pixel 9 Pro XL...Unless this thing is "leaps and bounds" faster than the 9, I'll pass. And by leaps and bounds, I don't mean on benchmarks. "Real world" faster. Most people don't even come close to topping out the performance of their phones. Tensor G5 is Google's most powerful chip to date, boasting a staggering 36 percent performance leap over G4.
    • MIT's stunning 'bubble wrap' device squeezes water out from thin air even in deserts by Sayan Sen Image by Matteo Roman via Pexels Massachusetts Institute of Technology (MIT) engineers have built a new kind of device that can pull clean drinking water straight out of the air—no electricity needed. It’s designed for areas where water is scarce and traditional sources like rivers or lakes aren’t reliable. Right now, more than 2.2 billion people globally don’t have access to safe drinking water. In the United States alone, 46 million face water insecurity, with either no running water or water that’s not safe to drink. This new device, called an Atmospheric Water Harvesting Window (AWHW), uses a unique hydrogel panel that looks like black bubble wrap. These dome-shaped bubbles soak up water vapor from the air, especially at night when humidity is higher. During the day, sunlight makes the vapor inside evaporate. That vapor then condenses on a glass surface and drips down through a tube, turning into drinkable water. The AWHW doesn’t rely on power sources like batteries or solar panels. It’s completely passive, meaning it works on its own. The team tested a meter-sized panel in Death Valley, California, one of the driest places in North America, and got between 57.0 and 161.5 milliliters of water per day even with humidity as low as 21 percent. That’s more than what other similar passive devices have managed. “We have built a meter-scale device that we hope to deploy in resource-limited regions, where even a solar cell is not very accessible,” said Xuanhe Zhao, a professor at MIT. “It’s a test of feasibility in scaling up this water harvesting technology. Now people can build it even larger, or make it into parallel panels, to supply drinking water to people and achieve real impact.” Another cool part of the design is how they kept the water safe to drink. Usually, these kinds of hydrogels use salts like lithium chloride to absorb more vapor but that can lead to salt leaking into the water, which isn’t ideal. To solve this, MIT’s team mixed in glycerol, a compound that helps keep salt locked inside the gel. In testing, the lithium ion concentration in the harvested water stayed below 0.06 ppm (parts per million), which is way below the safe limit. The hydrogel domes also give the material more surface area, letting it collect more vapor. The outer glass panel is coated with a special polymer film that helps cool the glass, making it easier for vapor to condense. “This is just a proof-of-concept design, and there are a lot of things we can optimize,” said lead author Chang Liu, now a professor at the National University of Singapore. “For instance, we could have a multipanel design. And we’re working on a next generation of the material to further improve its intrinsic properties.” Published in Nature Water, the study says the AWHW could last at least a year and shows promise for making safe, sustainable water in places with harsh climates. The researchers believe an array of vertical panels could one day supply water to individual households, especially in remote or off-grid locations. Source: MIT News, Nature This article was generated with some help from AI and reviewed by an editor. Under Section 107 of the Copyright Act 1976, this material is used for the purpose of news reporting. Fair use is a use permitted by copyright statute that might otherwise be infringing.
  • Recent Achievements

    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
    • Dedicated
      MacDaddyAz earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      ATLien_0
      209
    3. 3
      Michael Scrip
      204
    4. 4
      Xenon
      143
    5. 5
      +FloatingFatMan
      121
  • Tell a friend

    Love Neowin? Tell a friend!