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

    • Those persons has complete control over the internet right now. They do see everything what we do regardless.
    • Everyone and every country who doesn't support Israel's aggression, terrorism and hypocrisy is their immediate enemy. You can definitely see how many innocent people they are killing almost everyday. In fact they're the actual Neo-Nazi who holds Hitler's ideology.
    • Just pull a 4Chan and ignore the UK gov, or better troll them. It's not like they can enforce the fine across border.
    • It has NEVER been shown that all these overreaching creepy methods of surveillance have ever saved a child or prevented a terrorist attack. Not a single one. It's the kind of people like you who just wave it away as "paranoid conspiracy" that makes big tech and governments this creepy mass data hoarding entities. Not only that, 3/4 of these surveillance ideas undermine the very foundations of safe online communication because they always want to have a backdoor in everything "just in case" they might need it to... checks the notes "save the children". If you put a backdoor into encryption chain there is no encryption chain anymore. You know what encryption keeps safe? Your medical records, your online shopping and credit card during payment, your photos in the cloud, your emails, your passwords, everything. There is ZERO guarantee only the good guys will use it. And if you think police suddenly can't apprehend child abusers because of encryption, Epstein was running his entire sex trafficking ring using GMail which is not even encrypted end to end. Or to make matters even worse, USA has a **** and a good buddy of Epstein as a president. Absolutely NOTHING has been done to address it. Maxwell just got a better "hotel" room as a reward. This clearly shows how they absolutely don't really care about the children but they care about the absolute control over all of us. And you're defending them here. Good grief. On top of constant attempts to insert backdoors into encryption chain, the entire age verification nonsense is again entirely over reaching, creepy, invades everyone's privacy with premise of yet again "protecting the children" instead of demanding device makers to provide simple and powerful tools for PARENTS to control how their children use devices and what they do on them. THIS would be the way, not the stupid age verification for everyone. Imagine if government would be dictating companies how their phones work and not the company's IT department. The parents should be the IT department to their children. And for everyone excusing "they are not knowledgeable enough" buuuuuulsheat. We live in a digital age, if you have children now, you absolutely are well versed in digital everything at least to basic extent. If you're not, how do you even function in these times then? Reality is that parents are just lazy and don't want to deal with this. They want government to raise their kids because they are too busy scrolling stupid Instagram and Tiktok or some bs.
    • You could make the argument that K should not be included, but FC, the fried chicken, is not the framework, it's the product. It's the Paint in Paint.NET. A closer analogy is if KFC included the name of the deep fryer they used. HennyPennyFC.
  • Recent Achievements

    • Very Popular
      Captain_Eric earned a badge
      Very Popular
    • One Month Later
      amusc earned a badge
      One Month Later
    • One Month Later
      DJC50PLUS earned a badge
      One Month Later
    • Week One Done
      DJC50PLUS earned a badge
      Week One Done
    • Proficient
      Eric Biran went up a rank
      Proficient
  • Popular Contributors

    1. 1
      +primortal
      507
    2. 2
      PsYcHoKiLLa
      221
    3. 3
      ATLien_0
      92
    4. 4
      +Edouard
      88
    5. 5
      Steven P.
      83
  • Tell a friend

    Love Neowin? Tell a friend!